[PD-cvs] pd/src desire.c,1.1.2.117,1.1.2.118

Mathieu Bouchard matju at users.sourceforge.net
Mon Aug 21 02:41:15 CEST 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24089

Modified Files:
      Tag: devel_0_39
	desire.c 
Log Message:
removing selection-related code (300 lines)


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.117
retrieving revision 1.1.2.118
diff -C2 -d -r1.1.2.117 -r1.1.2.118
*** desire.c	21 Aug 2006 00:04:29 -0000	1.1.2.117
--- desire.c	21 Aug 2006 00:41:13 -0000	1.1.2.118
***************
*** 777,781 ****
  static void editor_free(t_editor *x, t_glist *y)
  {
-     glist_noselect(y);
      guiconnect_notarget(x->e_guiconnect, 1000);
      binbuf_free(x->e_connectbuf);
--- 777,780 ----
***************
*** 858,862 ****
          }
          sys_mgui(x,"getscroll","");
-         glist_noselect(x);
          if (glist_isvisible(x)) canvas_map(x, 0);
          canvas_create_editor(x, 0);
--- 857,860 ----
***************
*** 914,918 ****
      int dspstate = canvas_suspend_dsp();
      if (canvas_whichfind == x) canvas_whichfind = 0;
-     glist_noselect(x);
      while ((y = x->gl_list)) glist_delete(x, y);
      canvas_vis(x, 0);
--- 912,915 ----
***************
*** 1080,1092 ****
  }
  
- void canvas_logerror(t_object *y)
- {
- #ifdef LATER
-     canvas_vis(x, 1);
-     if (!glist_isselected(x, &y->ob_g))
-         glist_select(x, &y->ob_g);
- #endif
- }
- 
  /* -------------------------- subcanvases ---------------------- */
  
--- 1077,1080 ----
***************
*** 1477,1634 ****
  /* ------------------------ managing the selection ----------------- */
  
- void glist_selectline(t_glist *x, t_outconnect *oc, int index1,
-     int outno, int index2, int inno)
- {
-     if (x->gl_editor)
-     {
-         glist_noselect(x);
-         x->gl_editor->e_selectedline = 1;
-         x->gl_editor->e_selectline_index1 = index1;
-         x->gl_editor->e_selectline_outno = outno;
-         x->gl_editor->e_selectline_index2 = index2;
-         x->gl_editor->e_selectline_inno = inno;
-         x->gl_editor->e_selectline_tag = oc;
-         sys_vgui(".x%lx.c itemconfigure l%lx -fill blue\n",
-             (long)x, (long)x->gl_editor->e_selectline_tag);
-     }    
- }
- 
- void glist_deselectline(t_glist *x)
- {
-     if (x->gl_editor)
-     {
-         x->gl_editor->e_selectedline = 0;
-         sys_vgui(".x%lx.c itemconfigure l%lx -fill black\n",
-             (long)x, (long)x->gl_editor->e_selectline_tag);
-     }    
- }
- 
- int glist_isselected(t_glist *x, t_gobj *y)
- {
-     if (x->gl_editor)
-     {
-         t_selection *sel;
-         for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
-             if (sel->sel_what == y) return (1);
-     }
-     return (0);
- }
- 
-     /* call this for unselected objects only */
- void glist_select(t_glist *x, t_gobj *y)
- {
-     if (x->gl_editor)
-     {
-         t_selection *sel = (t_selection *)getbytes(sizeof(*sel));
-         if (x->gl_editor->e_selectedline)
-             glist_deselectline(x);
-             /* LATER #ifdef out the following check */
-         if (glist_isselected(x, y)) bug("glist_select");
-         sel->sel_next = x->gl_editor->e_selection;
-         sel->sel_what = y;
-         x->gl_editor->e_selection = sel;
-         gobj_select(y, x, 1);
-     }
- }
- 
-     /* call this for selected objects only */
- void glist_deselect(t_glist *x, t_gobj *y)
- {
-     int fixdsp = 0;
-     static int reenter = 0;
-     if (reenter) return;
-     reenter = 1;
-     if (x->gl_editor)
-     {
-         t_selection *sel, *sel2;
-         t_rtext *z = 0;
-         if (!glist_isselected(x, y)) bug("glist_deselect");
-         if (x->gl_editor->e_textedfor)
-         {
-             t_rtext *fuddy = glist_findrtext(x, (t_text *)y);
-             if (x->gl_editor->e_textedfor == fuddy)
-             {
-                 if (x->gl_editor->e_textdirty)
-                 {
-                     z = fuddy;
-                     canvas_stowconnections(glist_getcanvas(x));
-                 }
-                 gobj_activate(y, x, 0);
-             }
-             if (zgetfn(&y->g_pd, gensym("dsp")))
-                 fixdsp = canvas_suspend_dsp();
-         }
-         if ((sel = x->gl_editor->e_selection)->sel_what == y)
-         {
-             x->gl_editor->e_selection = x->gl_editor->e_selection->sel_next;
-             gobj_select(sel->sel_what, x, 0);
-             freebytes(sel, sizeof(*sel));
-         }
-         else
-         {
-             for (sel = x->gl_editor->e_selection; (sel2 = sel->sel_next);
-                 sel = sel2)
-             {
-                 if (sel2->sel_what == y)
-                 {
-                     sel->sel_next = sel2->sel_next;
-                     gobj_select(sel2->sel_what, x, 0);
-                     freebytes(sel2, sizeof(*sel2));
-                     break;
-                 }
-             }
-         }
-         if (z)
-         {
-             char *buf;
-             int bufsize;
- 
-             rtext_gettext(z, &buf, &bufsize);
-             text_setto((t_text *)y, x, buf, bufsize);
-             canvas_fixlinesfor(glist_getcanvas(x), (t_text *)y);
-             x->gl_editor->e_textedfor = 0;
-         }
-         if (fixdsp)
-             canvas_resume_dsp(1);
-     }
-     reenter = 0;
- }
- 
- void glist_noselect(t_glist *x)
- {
-     if (x->gl_editor)
-     {
-         while (x->gl_editor->e_selection)
-             glist_deselect(x, x->gl_editor->e_selection->sel_what);
-         if (x->gl_editor->e_selectedline)
-             glist_deselectline(x);
-     }
- }
- 
- void glist_selectall(t_glist *x)
- {
-     if (x->gl_editor)
-     {
-         glist_noselect(x);
-         if (x->gl_list)
-         {
-             t_selection *sel = (t_selection *)getbytes(sizeof(*sel));
-             t_gobj *y = x->gl_list;
-             x->gl_editor->e_selection = sel;
-             sel->sel_what = y;
-             gobj_select(y, x, 1);
-             while ((y = y->g_next))
-             {
-                 t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2));
-                 sel->sel_next = sel2;
-                 sel = sel2;
-                 sel->sel_what = y;
-                 gobj_select(y, x, 1);
-             }
-             sel->sel_next = 0;
-         }
-     }
- }
- 
      /* get the index of a gobj in a glist.  If y is zero, return the
      total number of objects. */
--- 1465,1468 ----
***************
*** 1640,1657 ****
  }
  
-     /* get the index of the object, among selected items, if "selected"
-     is set; otherwise, among unselected ones.  If y is zero, just
-     counts the selected or unselected objects. */
- int glist_selectionindex(t_glist *x, t_gobj *y, int selected)
- {
-     t_gobj *y2;
-     int indx;
- 
-     for (y2 = x->gl_list, indx = 0; y2 && y2 != y; y2 = y2->g_next)
-         if (selected == glist_isselected(x, y2))
-             indx++;
-     return (indx);
- }
- 
  static t_gobj *glist_nth(t_glist *x, int n)
  {
--- 1474,1477 ----
***************
*** 1702,1712 ****
              int j = glist_getindex(gl, g);
              int hadwindow = gl->gl_havewindow;
!             if (!hadwindow)
!                 canvas_vis(glist_getcanvas(gl), 1);
!             glist_noselect(gl);
!             glist_select(gl, g);
              canvas_doclear(gl);
-             /*FIXME (gl); */
-             glist_noselect(gl);
              g = glist_nth(gl, j);
              if (!hadwindow)
--- 1522,1527 ----
              int j = glist_getindex(gl, g);
              int hadwindow = gl->gl_havewindow;
!             if (!hadwindow) canvas_vis(glist_getcanvas(gl), 1);
              canvas_doclear(gl);
              g = glist_nth(gl, j);
              if (!hadwindow)
***************
*** 1980,1987 ****
                          canvas_find_index1 = myindex1;
                          canvas_find_index2 = myindex2;
-                         glist_noselect(x);
                          vmess(&x->gl_pd, gensym("menu-open"), "");
                          canvas_editmode(x, 1.);
-                         glist_select(x, y);
                          return (1);
                      }
--- 1795,1800 ----
***************
*** 2054,2061 ****
          {
              /* got it... now show it. */
-             glist_noselect(gl);
              canvas_vis(glist_getcanvas(gl), 1);
              canvas_editmode(glist_getcanvas(gl), 1.);
-             glist_select(gl, g);
              return (1);
          }
--- 1867,1872 ----
***************
*** 2081,2119 ****
  }
  
- void canvas_stowconnections(t_canvas *x)
- {
-     t_gobj *selhead = 0, *seltail = 0, *nonhead = 0, *nontail = 0, *y, *y2;
-     t_linetraverser t;
-     t_outconnect *oc;
-     if (!x->gl_editor) return;
-         /* split list to "selected" and "unselected" parts */ 
-     for (y = x->gl_list; y; y = y2)
-     {
-         y2 = y->g_next;
-         if (glist_isselected(x, y)) {
-             if (seltail) {seltail->g_next = y; seltail = y; y->g_next = 0;} else {selhead = seltail = y; seltail->g_next = 0;}
-         } else {
-             if (nontail) {nontail->g_next = y; nontail = y; y->g_next = 0;} else {nonhead = nontail = y; nontail->g_next = 0;}
-         }
-     }
-         /* move the selected part to the end */
-     if (!nonhead) x->gl_list = selhead;
-     else x->gl_list = nonhead, nontail->g_next = selhead;
- 
-         /* add connections to binbuf */
-     binbuf_clear(x->gl_editor->e_connectbuf);
-     linetraverser_start(&t, x);
-     while ((oc = linetraverser_next(&t)))
-     {
-         int s1 = glist_isselected(x, &t.tr_ob->ob_g);
-         int s2 = glist_isselected(x, &t.tr_ob2->ob_g);
-         if (s1 != s2)
-             binbuf_addv(x->gl_editor->e_connectbuf, "ssiiii;",
-                 gensym("#X"), gensym("connect"),
-                     glist_getindex(x, &t.tr_ob->ob_g), t.tr_outno,
-                         glist_getindex(x, &t.tr_ob2->ob_g), t.tr_inno);
-     }
- }
- 
  void canvas_restoreconnections(t_canvas *x)
  {
--- 1892,1895 ----
***************
*** 2128,2132 ****
      t_gobj *y, *y2;
      int dspstate;
- 
      dspstate = canvas_suspend_dsp();
      if (x->gl_editor->e_selectedline)
--- 1904,1907 ----
***************
*** 2137,2172 ****
               x->gl_editor->e_selectline_inno);
      }
-         /* if text is selected, deselecting it might remake the
-         object. So we deselect it and hunt for a "new" object on
-         the glist to reselect. */
-     if (x->gl_editor->e_textedfor)
-     {
-         newest = 0;
-         glist_noselect(x);
-         if (newest)
-         {
-             for (y = x->gl_list; y; y = y->g_next)
-                 if (&y->g_pd == newest) glist_select(x, y);
-         }
-     }
-     while (1)   /* this is pretty wierd...  should rewrite it */
-     {
-         for (y = x->gl_list; y; y = y2)
-         {
-             y2 = y->g_next;
-             if (glist_isselected(x, y))
-             {
-                 glist_delete(x, y);
- #if 0
-                 if (y2) post("cut 5 %lx %lx", y2, y2->g_next);
-                 else post("cut 6");
- #endif
-                 goto next;
-             }
-         }
-         goto restore;
-     next: ;
-     }
- restore:
      canvas_resume_dsp(dspstate);
      canvas_dirty(x, 1);
--- 1912,1915 ----
***************
*** 2176,2181 ****
--- 1919,1927 ----
  static t_canvas *paste_canvas;
  
+ /* FIXME */
  static void glist_donewloadbangs(t_glist *x)
  {
+     error("glist_donewloadbangs called but selections aren't server-side");
+ /*
      if (x->gl_editor)
      {
***************
*** 2185,2188 ****
--- 1931,1935 ----
                  canvas_loadbang((t_canvas *)(&sel->sel_what->g_pd));
      }
+ */
  }
  
***************
*** 2260,2268 ****
          return;
      x->gl_edit = !x->gl_edit;
-     if (x->gl_edit && glist_isvisible(x) && glist_istoplevel(x))
-     {} else
-     {
-         glist_noselect(x);
-     }
      sys_mgui(glist_getcanvas(x),"editmode=","i",x->gl_edit);
  }
--- 2007,2010 ----
***************
*** 3743,3753 ****
      int drawcommand = class_isdrawcommand(y->g_pd);
      int wasdeleting = canvas_setdeleting(canvas, 1);
!     if (x->gl_editor)
!     {
!         if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0;
!         if (glist_isselected(x, y)) glist_deselect(x, y);
!     }
!         /* if we're a drawing command, erase all scalars now, before deleting
!         it; we'll redraw them once it's deleted below. */
      if (drawcommand)
          canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(
--- 3485,3492 ----
      int drawcommand = class_isdrawcommand(y->g_pd);
      int wasdeleting = canvas_setdeleting(canvas, 1);
!     if (x->gl_editor && x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0;
! 
!     /* if we're a drawing command, erase all scalars now, before deleting
!        it; we'll redraw them once it's deleted below. */
      if (drawcommand)
          canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym(
***************
*** 4764,4769 ****
  }
  
! int glist_readscalar(t_glist *x, int natoms, t_atom *vec,
!     int *p_nextmsg, int selectit)
  {
      int message, nline;
--- 4503,4508 ----
  }
  
! /* FIXME: remove references to the selection, which isn't server-side */
! int glist_readscalar(t_glist *x, int natoms, t_atom *vec, int *p_nextmsg, int selectit)
  {
      int message, nline;
***************
*** 4805,4809 ****
          gobj_vis(&sc->sc_gobj, x, 1);
      }
-     if (selectit) glist_select(x, &sc->sc_gobj);
      return 1;
  }
--- 4544,4547 ----
***************
*** 5102,5108 ****
      for (y = x->gl_list; y; y = y->g_next)
      {
!         if ((pd_class(&y->g_pd) == scalar_class) &&
!             (wholething || glist_isselected(x, y)))
!         {
              canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
                  ((t_scalar *)y)->sc_vec,  &ntemplates, &templatevec);
--- 4840,4844 ----
      for (y = x->gl_list; y; y = y->g_next)
      {
!         if ((pd_class(&y->g_pd) == scalar_class) && wholething) {
              canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
                  ((t_scalar *)y)->sc_vec,  &ntemplates, &templatevec);
***************
*** 5137,5145 ****
      binbuf_addsemi(b);
          /* now write out the objects themselves */
!     for (y = x->gl_list; y; y = y->g_next)
!     {
!         if ((pd_class(&y->g_pd) == scalar_class) &&
!             (wholething || glist_isselected(x, y)))
!         {
              canvas_writescalar(((t_scalar *)y)->sc_template,
                  ((t_scalar *)y)->sc_vec,  b, 0);
--- 4873,4878 ----
      binbuf_addsemi(b);
          /* now write out the objects themselves */
!     for (y = x->gl_list; y; y = y->g_next) {
!         if (pd_class(&y->g_pd) == scalar_class && wholething) {
              canvas_writescalar(((t_scalar *)y)->sc_template,
                  ((t_scalar *)y)->sc_vec,  b, 0);
***************
*** 5236,5245 ****
      for (y = x->gl_list; y; y = y->g_next)
      {
!         if ((pd_class(&y->g_pd) == scalar_class) &&
!             (wholething || glist_isselected(x, y)))
                  canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
                      ((t_scalar *)y)->sc_vec,  ntemplatesp, templatevecp);
!         else if ((pd_class(&y->g_pd) == canvas_class) &&
!             (wholething || glist_isselected(x, y)))
                  canvas_collecttemplatesfor((t_canvas *)y,
                      ntemplatesp, templatevecp, 1);
--- 4969,4976 ----
      for (y = x->gl_list; y; y = y->g_next)
      {
!         if (pd_class(&y->g_pd) == scalar_class && wholething)
                  canvas_addtemplatesforscalar(((t_scalar *)y)->sc_template,
                      ((t_scalar *)y)->sc_vec,  ntemplatesp, templatevecp);
!         else if (pd_class(&y->g_pd) == canvas_class && wholething)
                  canvas_collecttemplatesfor((t_canvas *)y,
                      ntemplatesp, templatevecp, 1);
***************
*** 6190,6198 ****
              dy * (glist_pixelstoy(glist, 1) - glist_pixelstoy(glist, 0));
      scalar_redraw(x, glist);
-     if (glist_isselected(glist, z))
-     {
-         scalar_select(z, glist, 0);
-         scalar_select(z, glist, 1);
-     }
  }
  
--- 5921,5924 ----
***************
*** 6302,6307 ****
      int bufsize;
      t_binbuf *b;
-     glist_noselect(owner);
-     glist_select(owner, z);
      b = glist_writetobinbuf(owner, 0);
      binbuf_gettext(b, &buf, &bufsize);
--- 6028,6031 ----
***************
*** 8519,8525 ****
      if (!gobj) gobj = glist->gl_list;
      else gobj = gobj->g_next;
!     while (gobj && ((pd_class(&gobj->g_pd) != scalar_class) ||
!         (wantselected && !glist_isselected(glist, gobj))))
!             gobj = gobj->g_next;
      if (gobj) {
          t_typedout *to;
--- 8243,8247 ----
      if (!gobj) gobj = glist->gl_list;
      else gobj = gobj->g_next;
!     while (gobj && (pd_class(&gobj->g_pd) != scalar_class || wantselected)) gobj = gobj->g_next;
      if (gobj) {
          t_typedout *to;
***************
*** 9350,9354 ****
  	pd_vmess((t_pd *)glist_getcanvas(gl), gensym("editmode"), "i", 1);
      	SETSYMBOL(&at, gensym("comment"));
-     	glist_noselect(gl);
      	glist_getnextxy(gl, &xpix, &ypix);
      	x->te_xpix = glist_pixelstox(gl, xpix-3);
--- 9072,9075 ----
***************
*** 9356,9361 ****
      	binbuf_restore(x->te_binbuf, 1, &at);
      	glist_add(gl, &x->te_g);
-     	glist_noselect(gl);
-     	glist_select(gl, &x->te_g);
      	canvas_startmotion(glist_getcanvas(gl));
      }
--- 9077,9080 ----
***************
*** 9393,9400 ****
      x->te_type = T_OBJECT;
      glist_add(gl, &x->te_g);
!     if (selected) {
!     	glist_select(gl, &x->te_g);
!     	gobj_activate(&x->te_g, gl, 1);
!     }
      if (pd_class(&x->ob_pd) ==  vinlet_class)  canvas_resortinlets(glist_getcanvas(gl));
      if (pd_class(&x->ob_pd) == voutlet_class) canvas_resortoutlets(glist_getcanvas(gl));
--- 9112,9116 ----
      x->te_type = T_OBJECT;
      glist_add(gl, &x->te_g);
!     if (selected) gobj_activate(&x->te_g, gl, 1);
      if (pd_class(&x->ob_pd) ==  vinlet_class)  canvas_resortinlets(glist_getcanvas(gl));
      if (pd_class(&x->ob_pd) == voutlet_class) canvas_resortoutlets(glist_getcanvas(gl));
***************
*** 9411,9415 ****
      	int xpix, ypix;
  	pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
-     	glist_noselect(gl);
      	glist_getnextxy(gl, &xpix, &ypix);
      	canvas_objtext(gl, xpix, ypix, 1, b, -1);
--- 9127,9130 ----
***************
*** 9423,9427 ****
      int xpix, ypix;
      pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
-     glist_noselect(gl);
      SETSYMBOL(&at, guiobjname);
      binbuf_restore(b, 1, &at);
--- 9138,9141 ----
***************
*** 9557,9567 ****
      	int xpix, ypix;
  	pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
-     	glist_noselect(gl);
      	glist_getnextxy(gl, &xpix, &ypix);
      	x->m_text.te_xpix = xpix-3;
      	x->m_text.te_ypix = ypix-3;
      	glist_add(gl, &x->m_text.te_g);
-     	glist_noselect(gl);
-     	glist_select(gl, &x->m_text.te_g);
      	gobj_activate(&x->m_text.te_g, gl, 1);
      	canvas_startmotion(glist_getcanvas(gl));
--- 9271,9278 ----
***************
*** 9829,9839 ****
  	inlet_new(&x->a_text, &x->a_text.te_pd, 0, 0);
  	pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1);
-     	glist_noselect(gl);
      	glist_getnextxy(gl, &xpix, &ypix);
      	x->a_text.te_xpix = xpix;
      	x->a_text.te_ypix = ypix;
      	glist_add(gl, &x->a_text.te_g);
-     	glist_noselect(gl);
-     	glist_select(gl, &x->a_text.te_g);
      	canvas_startmotion(glist_getcanvas(gl));
      }
--- 9540,9547 ----
***************
*** 11655,11660 ****
      binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize);
      glist->gl_editor->e_rtext = x;
!     sprintf(x->x_tag, ".x%lx.t%lx", (t_int)glist_getcanvas(x->x_glist),
!         (t_int)x);
      return (x);
  }
--- 11363,11367 ----
      binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize);
      glist->gl_editor->e_rtext = x;
!     sprintf(x->x_tag, ".x%lx.t%lx", (t_int)glist_getcanvas(x->x_glist), (t_int)x);
      return (x);
  }
***************
*** 11662,11677 ****
  static t_rtext *rtext_entered;
  
! void rtext_free(t_rtext *x)
! {
      if (x->x_glist->gl_editor->e_textedfor == x)
          x->x_glist->gl_editor->e_textedfor = 0;
      if (x->x_glist->gl_editor->e_rtext == x)
          x->x_glist->gl_editor->e_rtext = x->x_next;
!     else
!     {
          t_rtext *e2;
!         for (e2 = x->x_glist->gl_editor->e_rtext; e2; e2 = e2->x_next)
!             if (e2->x_next == x)
!         {
              e2->x_next = x->x_next;
              break;
--- 11369,11380 ----
  static t_rtext *rtext_entered;
  
! void rtext_free(t_rtext *x) {
      if (x->x_glist->gl_editor->e_textedfor == x)
          x->x_glist->gl_editor->e_textedfor = 0;
      if (x->x_glist->gl_editor->e_rtext == x)
          x->x_glist->gl_editor->e_rtext = x->x_next;
!     else {
          t_rtext *e2;
!         for (e2 = x->x_glist->gl_editor->e_rtext; e2; e2 = e2->x_next) if (e2->x_next == x) {
              e2->x_next = x->x_next;
              break;
***************
*** 11683,11688 ****
  }
  
! void rtext_gettext(t_rtext *x, char **buf, int *bufsize)
! {
      *buf = x->x_buf;
      *bufsize = x->x_bufsize;
--- 11386,11390 ----
  }
  
! void rtext_gettext(t_rtext *x, char **buf, int *bufsize) {
      *buf = x->x_buf;
      *bufsize = x->x_bufsize;





More information about the Pd-cvs mailing list