From 4511ba85c9953ad988fc95d50ccc972c7eb99874 Mon Sep 17 00:00:00 2001 From: user <user@user-ThinkPad-X60.(none)> Date: Sat, 23 May 2015 01:19:36 -0400 Subject: [PATCH] oops... use binbuf_restore instead of binbuf_add to get dollargs to do the "right thing". Also fixed a debugging comment to keep it from printing garbage --- pd/nw/pd_canvas.html | 15 ++++++++++++--- pd/src/g_editor.c | 3 +-- pd/src/m_binbuf.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pd/nw/pd_canvas.html b/pd/nw/pd_canvas.html index 7414dacef..412024500 100644 --- a/pd/nw/pd_canvas.html +++ b/pd/nw/pd_canvas.html @@ -41,6 +41,15 @@ function add_keymods(key, evt) { return shift + ctrl + key; } +function text_to_fudi(text) { + text = text.trim(); + text = text.replace(/(\$[0-9]+)/g, '\\$1'); // escape dollar signs + text = text.replace(/(?!\\)(,|;)/g, ' \\$1 '); // escape ',' and ';' + text = text.replace(/\{|\}/g, ''); // filter '{' and '}' + text = text.replace(/\s+/g, ' '); // filter consecutive /s + return text; +} + var canvas_events = (function() { var name, textbox = function () { @@ -141,9 +150,9 @@ var canvas_events = (function() { }, text_mousedown: function(evt) { if (textbox() !== evt.target) { - pdgui.gui_post("my content was " + textbox().textContent); - pdgui.pdsend(name + " stringforobj " - + textbox().textContent); + var fudi_msg = text_to_fudi(textbox().textContent); + pdgui.pdsend(name + " stringforobj " + fudi_msg); + pdgui.gui_post("formatted content is " + fudi_msg); events.mousedown(evt); canvas_events.normal(); } diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 59b6fa615..6bf045f70 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -7624,9 +7624,8 @@ static void canvas_stringforobj(t_canvas *x, t_symbol *s, int argc, t_atom *argv { if (glist_isselected(x, y) && (rtext = glist_findrtext(x, (t_text *)y))) { - rtext_gettext(rtext, &buf, &length); t_binbuf *b = binbuf_new(); - binbuf_add(b, argc, argv); + binbuf_restore(b, argc, argv); binbuf_gettext(b, &buf, &length); rtext_settext(rtext, buf, length); binbuf_free(b); diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c index 66d7612a5..3b234d01c 100644 --- a/pd/src/m_binbuf.c +++ b/pd/src/m_binbuf.c @@ -82,7 +82,7 @@ void binbuf_clear(t_binbuf *x) /* convert text to a binbuf */ void binbuf_text(t_binbuf *x, char *text, size_t size) { - //fprintf(stderr, "current text: %s\n", text); + //fprintf(stderr, "current text: %.*s\n", size, text); char buf[MAXPDSTRING+1], *bufp, *ebuf = buf+MAXPDSTRING; const char *textp = text, *etext = text+size; t_atom *ap; -- GitLab