diff --git a/pd/nw/pd_canvas.html b/pd/nw/pd_canvas.html index 7414dacef92cf2cd630d45368be5e4f20cd3484c..412024500b4eddacef45116ab0ed8102f2816a08 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 59b6fa615e70284a266b1b5d09897f61b627353e..6bf045f709925d999449188c0742a59276b7f161 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 66d7612a5b0999d32e62edb66c117c31dd545038..3b234d01cde916179535cc04ac5c3db3505de192 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;