From bda78d82ee765497beb15eff4a9411028f04f3e4 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Mon, 28 Dec 2015 00:08:55 -0500
Subject: [PATCH] remove some old sys_vgui commands

---
 pd/nw/css/c64.css              |  5 +++++
 pd/nw/css/default.css          |  5 +++++
 pd/nw/css/extended.css         |  5 +++++
 pd/nw/css/inverted.css         |  5 +++++
 pd/nw/css/strongbad.css        |  5 +++++
 pd/nw/css/subdued.css          |  5 +++++
 pd/nw/css/vanilla.css          |  5 +++++
 pd/nw/css/vanilla_inverted.css |  5 +++++
 pd/nw/index.js                 |  1 -
 pd/src/g_editor.c              |  8 +++++---
 pd/src/g_rtext.c               | 35 ++++++++++++++++++----------------
 pd/src/g_text.c                | 21 ++++++++++----------
 12 files changed, 75 insertions(+), 30 deletions(-)

diff --git a/pd/nw/css/c64.css b/pd/nw/css/c64.css
index c50d43984..c9c12fee2 100644
--- a/pd/nw/css/c64.css
+++ b/pd/nw/css/c64.css
@@ -195,6 +195,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: #cc9933;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: #3e32a2;
diff --git a/pd/nw/css/default.css b/pd/nw/css/default.css
index 263fbc127..3a2b530e7 100644
--- a/pd/nw/css/default.css
+++ b/pd/nw/css/default.css
@@ -226,6 +226,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: blue;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: #f7f7f7;
diff --git a/pd/nw/css/extended.css b/pd/nw/css/extended.css
index df5e84a07..bb4838b29 100644
--- a/pd/nw/css/extended.css
+++ b/pd/nw/css/extended.css
@@ -188,6 +188,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: blue;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: #f7f7f7;
diff --git a/pd/nw/css/inverted.css b/pd/nw/css/inverted.css
index 9c93459e2..f13e64c49 100644
--- a/pd/nw/css/inverted.css
+++ b/pd/nw/css/inverted.css
@@ -198,6 +198,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: #ffff00;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: #002222;
diff --git a/pd/nw/css/strongbad.css b/pd/nw/css/strongbad.css
index 1737eeb92..09cc9a386 100644
--- a/pd/nw/css/strongbad.css
+++ b/pd/nw/css/strongbad.css
@@ -196,6 +196,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: green;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: transparent;
diff --git a/pd/nw/css/subdued.css b/pd/nw/css/subdued.css
index ca36e375b..0c137fa20 100644
--- a/pd/nw/css/subdued.css
+++ b/pd/nw/css/subdued.css
@@ -190,6 +190,11 @@ text {
     display: inline;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: blue;
+}
+
 /* for an object that didn't create */
 .obj .border.broken_border {
     fill: transparent;
diff --git a/pd/nw/css/vanilla.css b/pd/nw/css/vanilla.css
index 07c22908e..278ec23f7 100644
--- a/pd/nw/css/vanilla.css
+++ b/pd/nw/css/vanilla.css
@@ -171,6 +171,11 @@ text {
     stroke: black;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: black;
+}
+
 .graph .border {
     stroke: black;
     fill: none;
diff --git a/pd/nw/css/vanilla_inverted.css b/pd/nw/css/vanilla_inverted.css
index 11840c591..fbd09877a 100644
--- a/pd/nw/css/vanilla_inverted.css
+++ b/pd/nw/css/vanilla_inverted.css
@@ -182,6 +182,11 @@ text {
     stroke: white;
 }
 
+/* text inside selected objects */
+:not(.gop).selected text {
+    fill: white;
+}
+
 .graph .border {
     stroke: white;
     fill: none;
diff --git a/pd/nw/index.js b/pd/nw/index.js
index 16b78edc6..01349ef86 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -79,7 +79,6 @@ function open_external_doc(target) {
 }
 
 function nw_window_focus_callback() {
-    pdgui.post("pd window was focused");
     if (process.platform === "darwin") {
         nw_create_pd_window_menus(gui, window);
     }
diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 5a2639288..46b20cd13 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -546,7 +546,8 @@ void glist_select(t_glist *x, t_gobj *y)
         gobj_select(y, x, 1);
         c_selection = x;
 
-        sys_vgui("pdtk_canvas_update_edit_menu .x%lx 1\n", x);
+        /* Not sure if this is still needed */
+        //sys_vgui("pdtk_canvas_update_edit_menu .x%lx 1\n", x);
         canvas_draw_gop_resize_hooks(x);
     }
     //fprintf(stderr,"select done\n");
@@ -646,8 +647,9 @@ void glist_deselect(t_glist *x, t_gobj *y)
         }
         if (fixdsp)
             canvas_resume_dsp(1);
-        if (!x->gl_editor->e_selection)
-            sys_vgui("pdtk_canvas_update_edit_menu .x%lx 0\n", x);
+        /* Not sure if this is still needed */
+        //if (!x->gl_editor->e_selection)
+        //    sys_vgui("pdtk_canvas_update_edit_menu .x%lx 0\n", x);
         canvas_draw_gop_resize_hooks(x);
     }
     //reenter = 0;
diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c
index 57a776d3c..629b7ccee 100644
--- a/pd/src/g_rtext.c
+++ b/pd/src/g_rtext.c
@@ -544,24 +544,27 @@ void rtext_displace(t_rtext *x, int dx, int dy)
     //    x->x_tag, dx, dy);
 }
 
-/* Not sure if this is still used */
+/* This is no longer used-- we do this with CSS now. But keeping the code
+   here until we test a bit more. */
 void rtext_select(t_rtext *x, int state)
 {
-    t_glist *glist = x->x_glist;
-    t_canvas *canvas = glist_getcanvas(glist);
-    if (glist_istoplevel(glist))
-        sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
-            x->x_tag, (state? "$pd_colors(selection)" : "$pd_colors(text)"));
-    if (x->x_text->te_pd->c_wb && x->x_text->te_pd->c_wb->w_displacefnwtag)
-    {
-        if (state)
-            sys_vgui(".x%lx.c addtag selected withtag %s\n",
-                   glist_getcanvas(glist), x->x_tag);
-        else
-            sys_vgui(".x%lx.c dtag %s selected\n",
-                   glist_getcanvas(glist), x->x_tag);
-    }
-    canvas_editing = canvas;
+//    t_glist *glist = x->x_glist;
+//    t_canvas *canvas = glist_getcanvas(glist);
+//    if (glist_istoplevel(glist))
+//        sys_vgui(".x%lx.c itemconfigure %s -fill %s\n", canvas, 
+//            x->x_tag, (state? "$pd_colors(selection)" : "$pd_colors(text)"));
+//    if (x->x_text->te_pd->c_wb && x->x_text->te_pd->c_wb->w_displacefnwtag)
+//    {
+//        if (state)
+//            sys_vgui(".x%lx.c addtag selected withtag %s\n",
+//                   glist_getcanvas(glist), x->x_tag);
+//        else
+//            sys_vgui(".x%lx.c dtag %s selected\n",
+//                   glist_getcanvas(glist), x->x_tag);
+//    }
+    /* Not sure the following is needed anymore either-- commenting it
+       out to test what (if any) side-effects there are */
+//    canvas_editing = canvas;
 }
 
 void rtext_activate(t_rtext *x, int state)
diff --git a/pd/src/g_text.c b/pd/src/g_text.c
index 19afdc7a6..1b0b402cb 100644
--- a/pd/src/g_text.c
+++ b/pd/src/g_text.c
@@ -1639,10 +1639,10 @@ static void text_select(t_gobj *z, t_glist *glist, int state)
                              glist_istoplevel(glist))
                 {
                     /* Not sure yet what this is doing... */
-                    sys_vgui(".x%lx.c itemconfigure %sR -strokewidth 1 "
-                             "-strokedasharray {} "
-                             "-fill $pd_colors(box)\n",
-                        glist_getcanvas(glist), rtext_gettag(y));
+                    //sys_vgui(".x%lx.c itemconfigure %sR -strokewidth 1 "
+                    //         "-strokedasharray {} "
+                    //         "-fill $pd_colors(box)\n",
+                    //    glist_getcanvas(glist), rtext_gettag(y));
                 }
 
                 t_object *ob = pd_checkobject(&x->te_pd);
@@ -1678,12 +1678,13 @@ static void text_select(t_gobj *z, t_glist *glist, int state)
                 if (pd_class(&x->te_pd) == text_class &&
                     x->te_type != T_TEXT)
                 {
-                    /* This might be for broken objects... */
-                    sys_vgui(".x%lx.c itemconfigure %sR -strokewidth 2 "
-                        "-strokelinecap projecting -strokedasharray {2 3} "
-                        "-fill %s\n",
-                        glist_getcanvas(glist), 
-                        rtext_gettag(y), invalid_fill);
+                    /* This is for broken objects, but we're doing
+                       it in CSS now... */
+                    //sys_vgui(".x%lx.c itemconfigure %sR -strokewidth 2 "
+                    //    "-strokelinecap projecting -strokedasharray {2 3} "
+                    //    "-fill %s\n",
+                    //    glist_getcanvas(glist),
+                    //    rtext_gettag(y), invalid_fill);
                 }
 
                 t_object *ob = pd_checkobject(&x->te_pd);
-- 
GitLab