[PD-cvs] pd/src desire.c,1.1.2.112,1.1.2.113

Mathieu Bouchard matju at users.sourceforge.net
Sun Aug 20 22:20:21 CEST 2006


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

Modified Files:
      Tag: devel_0_39
	desire.c 
Log Message:
deleted 500 lines


Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.112
retrieving revision 1.1.2.113
diff -C2 -d -r1.1.2.112 -r1.1.2.113
*** desire.c	20 Aug 2006 20:07:45 -0000	1.1.2.112
--- desire.c	20 Aug 2006 20:20:19 -0000	1.1.2.113
***************
*** 2232,2237 ****
      canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd))));
      canopen = (y && zgetfn(&y->g_pd, gensym("menu-open")));
- //    sys_vgui("pdtk_canvas_popup .x%lx %d %d %d %d\n",
- //        x, xpos, ypos, canprop, canopen);
  }
  
--- 2232,2235 ----
***************
*** 2368,2428 ****
  char *class_gethelpdir(t_class *c);
  
-     /* called from the gui when a popup menu comes back with "properties,"
-         "open," or "help." */
- static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
- {
-     char namebuf[MAXPDSTRING];
-     t_gobj *y;
-     for (y = x->gl_list; y; y = y->g_next)
-     {
-         int x1, y1, x2, y2;
-         if (canvas_hitbox(x, y, xpos, ypos, &x1, &y1, &x2, &y2))
-         {
-             if (which == 0)     /* properties */
-             {
-                 if (!class_getpropertiesfn(pd_class(&y->g_pd)))
-                     continue;
-                 (*class_getpropertiesfn(pd_class(&y->g_pd)))(y, x);
-                 return;
-             }
-             else if (which == 1)    /* open */
-             {
-                 if (!zgetfn(&y->g_pd, gensym("menu-open")))
-                     continue;
-                 vmess(&y->g_pd, gensym("menu-open"), "");
-                 return;
-             }
-             else    /* help */
-             {
-                 char *dir;
-                 if (pd_class(&y->g_pd) == canvas_class &&
-                     canvas_isabstraction((t_canvas *)y))
-                 {
-                     t_object *ob = (t_object *)y;
-                     int ac = binbuf_getnatom(ob->te_binbuf);
-                     t_atom *av = binbuf_getvec(ob->te_binbuf);
-                     if (ac < 1)
-                         return;
-                     atom_string(av, namebuf, MAXPDSTRING);
-                     dir = canvas_getdir((t_canvas *)y)->s_name;
-                 }
-                 else
-                 {
-                     strcpy(namebuf, class_gethelpname(pd_class(&y->g_pd)));
-                     dir = class_gethelpdir(pd_class(&y->g_pd));
-                 }
-                 if (strcmp(namebuf + strlen(namebuf) - 3, ".pd"))
-                     strcat(namebuf, ".pd");
-                 open_via_helppath(namebuf, dir);
-                 return;
-             }
-         }
-     }
-     if (which == 0)
-         canvas_properties(x);
-     else if (which == 2)
-         sys_vgui("menu_opentext %s%s\n", sys_libdir->s_name,"/doc/5.reference/0.INTRO.txt");
- }
- 
  #define NOMOD 0
  #define SHIFTMOD 1
--- 2366,2369 ----
***************
*** 2466,2769 ****
  }
  
- void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
- {
-     int x11=0, y11=0, x12=0, y12=0;
-     t_gobj *y1;
-     int x21=0, y21=0, x22=0, y22=0;
-     t_gobj *y2;
-     int xwas = x->gl_editor->e_xwas,
-         ywas = x->gl_editor->e_ywas;
-     if (doit) sys_vgui(".x%lx.c delete x\n", (long)x);
-     else sys_vgui(".x%lx.c coords x %d %d %d %d\n",
-             (long)x, x->gl_editor->e_xwas, x->gl_editor->e_ywas, xpos, ypos);
- 
-     if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
-         && (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
-     {
-         t_object *ob1 = pd_checkobject(&y1->g_pd);
-         t_object *ob2 = pd_checkobject(&y2->g_pd);
-         int noutlet1, ninlet2;
-         if (ob1 && ob2 && ob1 != ob2 &&
-             (noutlet1 = obj_noutlets(ob1))
-             && (ninlet2 = obj_ninlets(ob2)))
-         {
-             int width1 = x12 - x11, closest1, hotspot1;
-             int width2 = x22 - x21, closest2, hotspot2;
-             int lx1, lx2, ly1, ly2;
-             t_outconnect *oc;
- 
-             if (noutlet1 > 1)
-             {
-                 closest1 = ((xwas-x11) * (noutlet1-1) + width1/2)/width1;
-                 hotspot1 = x11 +
-                     (width1 - IOWIDTH) * closest1 / (noutlet1-1);
-             }
-             else closest1 = 0, hotspot1 = x11;
- 
-             if (ninlet2 > 1)
-             {
-                 closest2 = ((xpos-x21) * (ninlet2-1) + width2/2)/width2;
-                 hotspot2 = x21 +
-                     (width2 - IOWIDTH) * closest2 / (ninlet2-1);
-             }
-             else closest2 = 0, hotspot2 = x21;
- 
-             if (closest1 >= noutlet1)
-                 closest1 = noutlet1 - 1;
-             if (closest2 >= ninlet2)
-                 closest2 = ninlet2 - 1;
- 
-             if (canvas_isconnected (x, ob1, closest1, ob2, closest2))
-             {
-                 canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
-                 return;
-             }
-             if (obj_issignaloutlet(ob1, closest1) &&
-                 !obj_issignalinlet(ob2, closest2))
-             {
-                 if (doit)
-                     error("can't connect signal outlet to control inlet");
-                 canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
-                 return;
-             }
-             if (doit)
-             {
-                 oc = obj_connect(ob1, closest1, ob2, closest2);
-                 lx1 = x11 + (noutlet1 > 1 ?
-                         ((x12-x11-IOWIDTH) * closest1)/(noutlet1-1) : 0)
-                              + IOMIDDLE;
-                 ly1 = y12;
-                 lx2 = x21 + (ninlet2 > 1 ?
-                         ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0)
-                             + IOMIDDLE;
-                 ly2 = y21;
-                 sys_vgui(".x%lx.c create line %d %d %d %d -width %d -tags l%lx\n",
-                     (long)glist_getcanvas(x), lx1, ly1, lx2, ly2,
-                             (obj_issignaloutlet(ob1, closest1) ? 2 : 1), (long)oc);
-                 canvas_setundo(x, canvas_undo_connect,
-                     canvas_undo_set_connect(x, 
-                         canvas_getindex(x, &ob1->ob_g), closest1,
-                         canvas_getindex(x, &ob2->ob_g), closest2),
-                         "connect");
-             }
-             else 
- 			{
- 				canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
- 				canvas_inlettip(x,ob2,closest2,xpos,ypos);
- 			}
-             return;
-         }
-     }
-     canvas_setcursor(x, CURSOR_EDITMODE_NOTHING);
- }
- 
- void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy)
- {
-     t_gobj *y;
-     for (y = x->gl_list; y; y = y->g_next)
-     {
-         int x1, y1, x2, y2;
-         gobj_getrect(y, x, &x1, &y1, &x2, &y2);
-         if (hix >= x1 && lox <= x2 && hiy >= y1 && loy <= y2
-             && !glist_isselected(x, y))
-                 glist_select(x, y);
-     }
- }
- 
- static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
- {
-     if (doit)
-     {
-         int lox, loy, hix, hiy;
-         if (x->gl_editor->e_xwas < xpos)
-             lox = x->gl_editor->e_xwas, hix = xpos;
-         else hix = x->gl_editor->e_xwas, lox = xpos;
-         if (x->gl_editor->e_ywas < ypos)
-             loy = x->gl_editor->e_ywas, hiy = ypos;
-         else hiy = x->gl_editor->e_ywas, loy = ypos;
-         canvas_selectinrect(x, lox, loy, hix, hiy);
-         sys_vgui(".x%lx.c delete x\n", (long)x);
-         x->gl_editor->e_onmotion = 0;
-     }
-     else sys_vgui(".x%lx.c coords x %d %d %d %d\n",
-             (long)x, x->gl_editor->e_xwas, x->gl_editor->e_ywas, xpos, ypos);
- }
- 
- void canvas_mouseup(t_canvas *x,
-     t_floatarg fxpos, t_floatarg fypos, t_floatarg fwhich)
- {
-     int xpos = fxpos, ypos = fypos, which = fwhich;
-     /* post("mouseup %d %d %d", xpos, ypos, which); */
-     if (!x->gl_editor)
-     {
-         bug("editor");
-         return;
-     }
- 
-     canvas_upclicktime = sys_getrealtime();
-     canvas_upx = xpos;
-     canvas_upy = ypos;
- 
-     if (x->gl_editor->e_onmotion == MA_CONNECT)
-         canvas_doconnect(x, xpos, ypos, which, 1);
-     else if (x->gl_editor->e_onmotion == MA_REGION)
-         canvas_doregion(x, xpos, ypos, 1);
-     else if (x->gl_editor->e_onmotion == MA_MOVE)
-     {
-             /* after motion, if there's only one item selected, activate it */
-         if (x->gl_editor->e_selection &&
-             !(x->gl_editor->e_selection->sel_next))
-                 gobj_activate(x->gl_editor->e_selection->sel_what,
-                     x, 1);
-     }
-     if (x->gl_editor->e_onmotion != MA_NONE)
-         sys_mgui(x,"getscroll","");
-     x->gl_editor->e_onmotion = MA_NONE;
- }
- 
-     /* displace the selection by (dx, dy) pixels */
- static void canvas_displaceselection(t_canvas *x, int dx, int dy)
- {
-     t_selection *y;
-     int resortin = 0, resortout = 0;
-     if (!canvas_undo_already_set_move)
-     {
-         canvas_setundo(x, canvas_undo_move, canvas_undo_set_move(x, 1),
-             "motion");
-         canvas_undo_already_set_move = 1;
-     }
-     for (y = x->gl_editor->e_selection; y; y = y->sel_next)
-     {
-         t_class *cl = pd_class(&y->sel_what->g_pd);
-         gobj_displace(y->sel_what, x, dx, dy);
-         if (cl == vinlet_class) resortin = 1;
-         else if (cl == voutlet_class) resortout = 1;
-     }
-     if (resortin) canvas_resortinlets(x);
-     if (resortout) canvas_resortoutlets(x);
-     canvas_dirty(x, 1);
- }
- 
-     /* this routine is called whenever a key is pressed or released.  "x"
-     may be zero if there's no current canvas.  The first argument is true or
-     false for down/up; the second one is either a symbolic key name (e.g.,
-     "Right" or an Ascii key number.  The third is the shift key. */
- void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
- {
-     static t_symbol *keynumsym, *keyupsym, *keynamesym;
-     int keynum, fflag;
-     t_symbol *gotkeysym;
-         
-     int down, shift;
-     
-     if (ac < 3)
-         return;
-     if (!x || !x->gl_editor)
-         return;
-     canvas_undo_already_set_move = 0;
-     down = (atom_getfloat(av) != 0);  /* nonzero if it's a key down */
-     shift = (atom_getfloat(av+2) != 0);  /* nonzero if shift-ed */
-     if (av[1].a_type == A_SYMBOL)
-         gotkeysym = av[1].a_w.w_symbol;
-     else if (av[1].a_type == A_FLOAT)
-     {
-         char buf[3];
-         sprintf(buf, "%c", (int)(av[1].a_w.w_float));
-         gotkeysym = gensym(buf);
-     }
-     else gotkeysym = gensym("?");
-     fflag = (av[0].a_type == A_FLOAT ? av[0].a_w.w_float : 0);
-     keynum = (av[1].a_type == A_FLOAT ? av[1].a_w.w_float : 0);
-     if (keynum == '\\' || keynum == '{' || keynum == '}')
-     {
-         post("%c: dropped", (int)keynum);
-         return;
-     }
- #if 0
-     post("keynum %d, down %d", (int)keynum, down);
- #endif
-     if (keynum == '\r') keynum = '\n';
-     if (av[1].a_type == A_SYMBOL &&
-         !strcmp(av[1].a_w.w_symbol->s_name, "Return"))
-             keynum = '\n';
-     if (!keynumsym)
-     {
-         keynumsym = gensym("#key");
-         keyupsym = gensym("#keyup");
-         keynamesym = gensym("#keyname");
-     }
- #ifdef MACOSX
-         if (keynum == 30)
-             keynum = 0, gotkeysym = gensym("Up");
-         else if (keynum == 31)
-             keynum = 0, gotkeysym = gensym("Down");
-         else if (keynum == 28)
-             keynum = 0, gotkeysym = gensym("Left");
-         else if (keynum == 29)
-             keynum = 0, gotkeysym = gensym("Right");
- #endif
-     if (keynumsym->s_thing && down)
-         pd_float(keynumsym->s_thing, (float)keynum);
-     if (keyupsym->s_thing && !down)
-         pd_float(keyupsym->s_thing, (float)keynum);
-     if (keynamesym->s_thing)
-     {
-         t_atom at[2];
-         at[0] = av[0];
-         SETFLOAT(at, down);
-         SETSYMBOL(at+1, gotkeysym);
-         pd_list(keynamesym->s_thing, 0, 2, at);
-     }
-     if (!x->gl_editor)  /* if that 'invis'ed the window, we'd better stop. */
-         return;
-     if (x && down)
-     {
-             /* if an object has "grabbed" keys just send them on */
-         if (x->gl_editor->e_grab
-             && x->gl_editor->e_keyfn && keynum)
-                 (* x->gl_editor->e_keyfn)
-                     (x->gl_editor->e_grab, (float)keynum);
-             /* if a text editor is open send the key on, as long as
-             it is either "real" (has a key number) or else is an arrow key. */
-         else if (x->gl_editor->e_textedfor && (keynum
-             || !strcmp(gotkeysym->s_name, "Up")
-             || !strcmp(gotkeysym->s_name, "Down")
-             || !strcmp(gotkeysym->s_name, "Left")
-             || !strcmp(gotkeysym->s_name, "Right")))
-         {
-             if (!x->gl_editor->e_textdirty)
-             {
-                 canvas_setundo(x, canvas_undo_cut,
-                     canvas_undo_set_cut(x, UCUT_TEXT), "typing");
-             }
-             rtext_key(x->gl_editor->e_textedfor,
-                 (int)keynum, gotkeysym);
-             if (x->gl_editor->e_textdirty)
-                 canvas_dirty(x, 1);
-         }
-             /* check for backspace or clear */
-         else if (keynum == 8 || keynum == 127)
-         {
-             if (x->gl_editor->e_selectedline)
-                 canvas_clearline(x);
-             else if (x->gl_editor->e_selection)
-             {
-                 canvas_setundo(x, canvas_undo_cut,
-                     canvas_undo_set_cut(x, UCUT_CLEAR), "clear");
-                 canvas_doclear(x);
-             }
-         }
-                 /* check for arrow keys */
-         else if (!strcmp(gotkeysym->s_name, "Up"))
-             canvas_displaceselection(x, 0, shift ? -10 : -1);
-         else if (!strcmp(gotkeysym->s_name, "Down"))
-             canvas_displaceselection(x, 0, shift ? 10 : 1);
-         else if (!strcmp(gotkeysym->s_name, "Left"))
-             canvas_displaceselection(x, shift ? -10 : -1, 0);
-         else if (!strcmp(gotkeysym->s_name, "Right"))
-             canvas_displaceselection(x, shift ? 10 : 1, 0);
-     }
- }
- 
  void canvas_startmotion(t_canvas *x)
  {
--- 2407,2410 ----
***************
*** 3000,3033 ****
  }
  
- static void canvas_copy(t_canvas *x)
- {
-     if (!x->gl_editor || !x->gl_editor->e_selection)
-         return;
-     binbuf_free(copy_binbuf);
-     copy_binbuf = canvas_docopy(x);
-     if (x->gl_editor->e_textedfor)
-     {
-         char *buf;
-         int bufsize;
-         rtext_getseltext(x->gl_editor->e_textedfor, &buf, &bufsize);
- 
- #ifdef UNIX
-             /* in X windows (i.e., UNIX) the selection already went to the
-             clipboard when it was made; here we "copy" it to our own buffer
-             as well, because, annoyingly, the clipboard will usually be 
-             destroyed by the time the user asks to "paste". */
-         if (canvas_textcopybuf)
-             t_freebytes(canvas_textcopybuf, canvas_textcopybufsize);
-         canvas_textcopybuf = (char *)getbytes(bufsize);
-         memcpy(canvas_textcopybuf, buf, bufsize);
-         canvas_textcopybufsize = bufsize;
- #else /* UNIX */
-             /* otherwise just copy the text to the clipboard here */
-         sys_vgui("clipboard clear\n", bufsize, buf);
-         sys_vgui("clipboard append {%.*s}\n", bufsize, buf);
- #endif /* UNIX */
-     }
- }
- 
  static void canvas_clearline(t_canvas *x)
  {
--- 2641,2644 ----
***************
*** 3105,3133 ****
  }
  
- static void canvas_cut(t_canvas *x)
- {
-     if (x->gl_editor && x->gl_editor->e_selectedline)
-         canvas_clearline(x);
-     else if (x->gl_editor->e_textedfor)
-     {
-         char *buf;
-         int bufsize;
-         rtext_getseltext(x->gl_editor->e_textedfor, &buf, &bufsize);
-         if (!bufsize)
-             return;
-         canvas_copy(x);
-         rtext_key(x->gl_editor->e_textedfor, 127, &s_);
-         canvas_dirty(x, 1);
-     }
-     else if (x->gl_editor && x->gl_editor->e_selection)
-     {
-         canvas_setundo(x, canvas_undo_cut,
-             canvas_undo_set_cut(x, UCUT_CUT), "cut");
-         canvas_copy(x);
-         canvas_doclear(x);
-         sys_mgui(x,"getscroll","");
-     }
- }
- 
  static int paste_onset;
  static t_canvas *paste_canvas;
--- 2716,2719 ----
***************
*** 3198,3217 ****
  }
  
- static void canvas_duplicate(t_canvas *x)
- {
-     if (x->gl_editor->e_onmotion == MA_NONE)
-     {
-         t_selection *y;
-         canvas_copy(x);
-         canvas_setundo(x, canvas_undo_paste, canvas_undo_set_paste(x),
-             "duplicate");
-         canvas_dopaste(x, copy_binbuf);
-         for (y = x->gl_editor->e_selection; y; y = y->sel_next)
-             gobj_displace(y->sel_what, x,
-                 10, 10);
-         canvas_dirty(x, 1);
-     }
- }
- 
  static void canvas_selectall(t_canvas *x)
  {
--- 2784,2787 ----
***************
*** 3397,3406 ****
  }
  
- void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av)
- {
-         /* canvas_editing can be zero; canvas_key checks for that */
-     canvas_key(canvas_editing, s, ac, av);
- }
- 
  void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
  {
--- 2967,2970 ----
***************
*** 12648,12659 ****
      class_addcreator((t_newmethod)table_new, gensym("table"), A_DEFSYM, A_DEFFLOAT, 0);
  
-     class_addmethod3(c,canvas_key,"key","*");
      class_addmethod3(c,canvas_close,"close","F");
  
  /* should die: */
-     class_addmethod3(c,canvas_cut,      "cut","");
-     class_addmethod3(c,canvas_copy,     "copy","");
-     class_addmethod3(c,canvas_paste,    "paste","");
-     class_addmethod3(c,canvas_duplicate,"duplicate","");
      class_addmethod3(c,canvas_selectall,"selectall","");
      class_addmethod3(c,canvas_undo,     "undo","");
--- 12212,12218 ----
***************
*** 12663,12673 ****
  /* end die */
  
- /* <dead>
-   class_addmethod3(c,canvas_click,    "click",  "fffff");
-   class_addmethod3(c,canvas_motion,   "motion", "fff");
-   class_addmethod3(c,canvas_mousedown,"mouse",  "ffff");
-   class_addmethod3(c,canvas_mouseup,  "mouseup","fff");
- </dead> */
- 
      class_addmethod3(c,canvas_editmode, "editmode","F");
  
--- 12222,12225 ----
***************
*** 12678,12682 ****
      class_addmethod3(c,canvas_find_again, "findagain","");
      class_addmethod3(c,canvas_find_parent,"findparent","");
-     class_addmethod3(c,canvas_done_popup, "done-popup","fff");
      class_addmethod3(c,canvas_donecanvasdialog,"donecanvasdialog","*");
      class_addmethod3(c,glist_arraydialog,"arraydialog","sfff");
--- 12230,12233 ----
***************
*** 13396,13456 ****
  }
  
- void rtext_mouse(t_rtext *x, int xval, int yval, int flag)
- {
-     int w = xval, h = yval, indx;
-     rtext_senditup(x, SEND_CHECK, &w, &h, &indx);
-     if (flag == RTEXT_DOWN)
-     {
-         x->x_dragfrom = x->x_selstart = x->x_selend = indx;
-     }
-     else if (flag == RTEXT_DBL)
-     {
-         int whereseparator, newseparator;
-         x->x_dragfrom = -1;
-         whereseparator = 0;
-         if ((newseparator = lastone(x->x_buf, ' ', indx)) > whereseparator)
-             whereseparator = newseparator+1;
-         if ((newseparator = lastone(x->x_buf, '\n', indx)) > whereseparator)
-             whereseparator = newseparator+1;
-         if ((newseparator = lastone(x->x_buf, ';', indx)) > whereseparator)
-             whereseparator = newseparator+1;
-         if ((newseparator = lastone(x->x_buf, ',', indx)) > whereseparator)
-             whereseparator = newseparator+1;
-         x->x_selstart = whereseparator;
-         
-         whereseparator = x->x_bufsize - indx;
-         if ((newseparator =
-             firstone(x->x_buf+indx, ' ', x->x_bufsize - indx)) >= 0 &&
-                 newseparator < whereseparator)
-                     whereseparator = newseparator;
-         if ((newseparator =
-             firstone(x->x_buf+indx, '\n', x->x_bufsize - indx)) >= 0 &&
-                 newseparator < whereseparator)
-                     whereseparator = newseparator;
-         if ((newseparator =
-             firstone(x->x_buf+indx, ';', x->x_bufsize - indx)) >= 0 &&
-                 newseparator < whereseparator)
-                     whereseparator = newseparator;
-         if ((newseparator =
-             firstone(x->x_buf+indx, ',', x->x_bufsize - indx)) >= 0 &&
-                 newseparator < whereseparator)
-                     whereseparator = newseparator;
-         x->x_selend = indx + whereseparator;
-     }
-     else if (flag == RTEXT_SHIFT)
-     {
-         if (indx * 2 > x->x_selstart + x->x_selend)
-             x->x_dragfrom = x->x_selstart, x->x_selend = indx;
-         else
-             x->x_dragfrom = x->x_selend, x->x_selstart = indx;
-     }
-     else if (flag == RTEXT_DRAG)
-     {
-         if (x->x_dragfrom < 0)
-             return;
-         x->x_selstart = (x->x_dragfrom < indx ? x->x_dragfrom : indx);
-         x->x_selend = (x->x_dragfrom > indx ? x->x_dragfrom : indx);
-     }
-     rtext_senditup(x, SEND_UPDATE, &w, &h, &indx);
- }
- 
--- 12947,12948 ----





More information about the Pd-cvs mailing list