From 686d2b745cf8a83096b628c227105c599d3a3904 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Wed, 20 Aug 2014 15:17:27 -0400
Subject: [PATCH] *removed redundant redraw from numbox *added ability to have
 spaces in iemgui properties dialog

---
 pd/src/g_all_guis.c | 13 +++++++++++++
 pd/src/g_numbox.c   |  3 ---
 pd/src/pd.tk        |  7 +++++--
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c
index f6b53ac3b..89e8d3382 100644
--- a/pd/src/g_all_guis.c
+++ b/pd/src/g_all_guis.c
@@ -572,6 +572,19 @@ int iemgui_dialog(t_iemgui *x, int argc, t_atom *argv)
     if(iemgui_has_rcv(x)) oldsndrcvable |= IEM_GUI_OLD_RCV_FLAG;
     if(iemgui_has_snd(x)) oldsndrcvable |= IEM_GUI_OLD_SND_FLAG;
     iemgui_all_raute2dollar(srl);
+
+    // replace ascii code 11 (\v or vertical tab) with spaces
+    // we do this so that the string with spaces can survive argc,argv
+    // conversion when coming from dialog side of things where it is parsed
+    char *c;
+    for(c = srl[2]->s_name; c != NULL && *c != '\0'; c++)
+    {
+        if(*c == '\v')
+        {
+            *c = ' ';
+        }
+    }
+
     x->x_snd_unexpanded=srl[0]; srl[0]=canvas_realizedollar(x->x_glist, srl[0]);
     x->x_rcv_unexpanded=srl[1]; srl[1]=canvas_realizedollar(x->x_glist, srl[1]);
     x->x_lab_unexpanded=srl[2]; srl[2]=canvas_realizedollar(x->x_glist, srl[2]);
diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c
index 86e267293..d69ef2f4a 100644
--- a/pd/src/g_numbox.c
+++ b/pd/src/g_numbox.c
@@ -473,10 +473,7 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
     //iemgui_draw_config(&x->x_gui);
     scalehandle_draw(&x->x_gui);
     if (x->x_gui.x_selected)
-    {
-        scalehandle_draw(&x->x_gui);
         iemgui_select((t_gobj *)x,x->x_gui.x_glist,1);
-    }
     //canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x,"bogus",-1);
     scrollbar_update(x->x_gui.x_glist);
 }
diff --git a/pd/src/pd.tk b/pd/src/pd.tk
index aca861e90..5c740e981 100644
--- a/pd/src/pd.tk
+++ b/pd/src/pd.tk
@@ -1088,10 +1088,13 @@ proc pdtk_enquote {x} {
     concat $foo2
 }
 
-#enquote a string to send it to Pd.  Blow off semi and comma; alias spaces
+interp alias {} chr {} format %c
+
+#enquote a string to send it to Pd.  Blow off semi and comma; replace spaces with VT (ascii dec. 11)
 #we also blow off "{", "}", "\" because they'll just cause bad trouble later.
 proc pdtk_unspace {x} {
-    set y [string map {" " "_" ";" "" "," "" "{" "" "}" "" "\\" ""} $x]
+	set space [chr 11]
+    set y [string map [list " " $space ";" "" "," "" "{" "" "}" "" "\\" ""] $x]
     if {$y == ""} {set y "empty"}
     concat $y
 }
-- 
GitLab