Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14495
Modified Files: Tag: devel_0_39 desire.c desire.h Log Message: more failed attempts at object insertion for undoing delete
Index: desire.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.h,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** desire.h 21 Aug 2006 02:37:39 -0000 1.1.2.6 --- desire.h 21 Aug 2006 03:13:05 -0000 1.1.2.7 *************** *** 203,206 **** --- 203,209 ---- unsigned int gl_goprect:1; /* draw rectangle for graph-on-parent */ unsigned int gl_isgraph:1; /* show as graph on parent */ + #ifdef DESIRE + long gl_next_add; /* insertion point for next call to glist_add */ + #endif };
Index: desire.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v retrieving revision 1.1.2.118 retrieving revision 1.1.2.119 diff -C2 -d -r1.1.2.118 -r1.1.2.119 *** desire.c 21 Aug 2006 00:41:13 -0000 1.1.2.118 --- desire.c 21 Aug 2006 03:13:05 -0000 1.1.2.119 *************** *** 556,559 **** --- 556,560 ---- x->gl_font = sys_nearestfontsize(font); pd_pushsym(&x->gl_pd); + x->gl_next_add = -1; return(x); } *************** *** 1396,1400 **** // from g_editor.c
- static void canvas_doclear(t_canvas *x); static void glist_setlastxy(t_glist *gl, int xval, int yval); static void glist_donewloadbangs(t_glist *x); --- 1397,1400 ---- *************** *** 1474,1485 **** }
! static t_gobj *glist_nth(t_glist *x, int n) ! { t_gobj *y; ! int indx; ! for (y = x->gl_list, indx = 0; y; y = y->g_next, indx++) ! if (indx == n) ! return (y); ! return (0); }
--- 1474,1513 ---- }
! static t_gobj *glist_nth(t_glist *x, int n) { t_gobj *y; ! glist_each(y,x) if (!n) return y; else n--; ! return 0; ! } ! ! #define glist_each2(CHILD,GLIST) for(CHILD=&(GLIST)->gl_list; *CHILD; CHILD=&(*CHILD)->g_next) ! /* just a raw remove, no other business */ ! /* doesn't work (why?) */ ! static t_gobj *glist_remove_nth(t_glist *x, int n) { ! t_gobj **y; ! t_gobj *z; ! glist_each2(y,x) { ! fprintf(stderr,"n=%i *y=%p\n",n,*y); ! if (!n) { ! z = *y; ! *y = z->g_next; ! z->g_next = 0; ! return z; ! } else n--; ! } ! return 0; ! } ! ! /* just a raw insert, no other business */ ! /* doesn't work (why?) */ ! static void glist_insert_nth(t_glist *x, int n, t_gobj *new) { ! t_gobj **y; ! t_gobj *z; ! glist_each2(y,x) if (!n) { ! z = *y; ! *y = new; ! new->g_next = z; ! return; ! } else n--; ! *y = new; }
*************** *** 1523,1527 **** int hadwindow = gl->gl_havewindow; if (!hadwindow) canvas_vis(glist_getcanvas(gl), 1); - canvas_doclear(gl); g = glist_nth(gl, j); if (!hadwindow) --- 1551,1554 ---- *************** *** 1899,1919 **** }
- extern t_pd *newest; - static void canvas_doclear(t_canvas *x) - { - t_gobj *y, *y2; - int dspstate; - dspstate = canvas_suspend_dsp(); - if (x->gl_editor->e_selectedline) - { - canvas_disconnect(x, x->gl_editor->e_selectline_index1, - x->gl_editor->e_selectline_outno, - x->gl_editor->e_selectline_index2, - x->gl_editor->e_selectline_inno); - } - canvas_resume_dsp(dspstate); - canvas_dirty(x, 1); - } - static int paste_onset; static t_canvas *paste_canvas; --- 1926,1929 ---- *************** *** 3421,3427 **** };
! void glist_add(t_glist *x, t_gobj *y) ! { ! if (!y->g_pd->c_patchable) { printf("glist_add %p %p class=%s (non-t_text)\n",x,y,y->g_pd->c_name->s_name); --- 3431,3436 ---- };
! void glist_add(t_glist *x, t_gobj *y) { ! /* if (!y->g_pd->c_patchable) { printf("glist_add %p %p class=%s (non-t_text)\n",x,y,y->g_pd->c_name->s_name); *************** *** 3437,3440 **** --- 3446,3450 ---- } } + */
gobj_subscribe(y,(t_gobj *)x); *************** *** 3450,3456 **** y->g_next = 0; if (!x->gl_list) x->gl_list = y; else { ! t_gobj *y2; ! for (y2 = x->gl_list; y2->g_next; y2 = y2->g_next) {} ! y2->g_next = y; } gobj_changed(x,0); --- 3460,3474 ---- y->g_next = 0; if (!x->gl_list) x->gl_list = y; else { ! if (x->gl_next_add<0) { ! t_gobj *y2; ! for (y2 = x->gl_list; y2->g_next; y2=y2->g_next) {} ! y2->g_next = y; ! } else { ! int i=0; ! t_gobj *y2, *y3; ! for (y2 = x->gl_list; y2->g_next; y2=y2->g_next, i++) if (i==x->gl_next_add) break; ! y->g_next = y2->g_next; ! y2->g_next = y; ! } } gobj_changed(x,0); *************** *** 3476,3480 **** }
! /* delete an object from a glist and free it */ void glist_delete(t_glist *x, t_gobj *y) { --- 3494,3499 ---- }
! ! /* delete an object from a glist and free it */ void glist_delete(t_glist *x, t_gobj *y) { *************** *** 3499,3510 **** }
! if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) ! rtext_new(x, ob); ! if (x->gl_list == y) x->gl_list = y->g_next; ! else for (g = x->gl_list; g; g = g->g_next) ! if (g->g_next == y) ! { ! g->g_next = y->g_next; ! break; } pd_free(&y->g_pd); --- 3518,3526 ---- }
! if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) rtext_new(x, ob); ! if (x->gl_list == y) { ! x->gl_list = y->g_next; ! } else { ! glist_each(g,x) if (g->g_next == y) {g->g_next = y->g_next; break;} } pd_free(&y->g_pd); *************** *** 3517,3547 **** }
! /* remove every object from a glist. Experimental. */ ! void glist_clear(t_glist *x) ! { t_gobj *y; int dspstate = 0, suspended = 0; t_symbol *dspsym = gensym("dsp"); ! while ((y = x->gl_list)) ! { ! /* to avoid unnecessary DSP resorting, we suspend DSP ! only if we hit a patchable object. */ ! if (!suspended && pd_checkobject(&y->g_pd) && zgetfn(&y->g_pd, dspsym)) ! { dspstate = canvas_suspend_dsp(); suspended = 1; } ! /* here's the real deletion. */ glist_delete(x, y); } ! if (suspended) ! canvas_resume_dsp(dspstate); }
! void glist_retext(t_glist *glist, t_text *y) ! { ! /* check that we have built rtexts yet. LATER need a better test. */ ! if (glist->gl_editor && glist->gl_editor->e_rtext) ! { t_rtext *rt = glist_findrtext(glist, y); if (rt) rtext_retext(rt); --- 3533,3555 ---- }
! void glist_clear(t_glist *x) { t_gobj *y; int dspstate = 0, suspended = 0; t_symbol *dspsym = gensym("dsp"); ! while ((y = x->gl_list)) { ! /* to avoid unnecessary DSP resorting, we suspend DSP ! only if we hit a patchable object. */ ! if (!suspended && pd_checkobject(&y->g_pd) && zgetfn(&y->g_pd, dspsym)) { dspstate = canvas_suspend_dsp(); suspended = 1; } ! /* here's the real deletion. */ glist_delete(x, y); } ! if (suspended) canvas_resume_dsp(dspstate); }
! void glist_retext(t_glist *glist, t_text *y) { ! if (glist->gl_editor && glist->gl_editor->e_rtext) { t_rtext *rt = glist_findrtext(glist, y); if (rt) rtext_retext(rt); *************** *** 9081,9089 **** }
! extern t_pd *newest; ! void canvas_getargs(int *argcp, t_atom **argvp); ! ! /* i = insertion point; -1 = end */ ! static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected, t_binbuf *b, int i) { t_text *x=0; int argc, n; --- 9089,9093 ---- }
! static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected, t_binbuf *b) { t_text *x=0; int argc, n; *************** *** 9123,9132 **** binbuf_restore(b, argc-2, argv+2); canvas_objtext(gl, atom_getintarg(0, argc, argv), ! atom_getintarg(1, argc, argv), 0, b, -1); } else { int xpix, ypix; pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1); glist_getnextxy(gl, &xpix, &ypix); ! canvas_objtext(gl, xpix, ypix, 1, b, -1); canvas_startmotion(glist_getcanvas(gl)); } --- 9127,9136 ---- binbuf_restore(b, argc-2, argv+2); canvas_objtext(gl, atom_getintarg(0, argc, argv), ! atom_getintarg(1, argc, argv), 0, b); } else { int xpix, ypix; pd_vmess(&gl->gl_pd, gensym("editmode"), "i", 1); glist_getnextxy(gl, &xpix, &ypix); ! canvas_objtext(gl, xpix, ypix, 1, b); canvas_startmotion(glist_getcanvas(gl)); } *************** *** 9141,9145 **** binbuf_restore(b, 1, &at); glist_getnextxy(gl, &xpix, &ypix); ! canvas_objtext(gl, xpix, ypix, 1, b, -1); canvas_startmotion(glist_getcanvas(gl)); } --- 9145,9149 ---- binbuf_restore(b, 1, &at); glist_getnextxy(gl, &xpix, &ypix); ! canvas_objtext(gl, xpix, ypix, 1, b); canvas_startmotion(glist_getcanvas(gl)); } *************** *** 9663,9667 **** int xwas = x->te_xpix, ywas = x->te_ypix; glist_delete(glist, &x->te_g); ! canvas_objtext(glist, xwas, ywas, 0, b, -1); /* if it's an abstraction loadbang it here */ if (newest && pd_class(newest) == canvas_class) --- 9667,9671 ---- int xwas = x->te_xpix, ywas = x->te_ypix; glist_delete(glist, &x->te_g); ! canvas_objtext(glist, xwas, ywas, 0, b); /* if it's an abstraction loadbang it here */ if (newest && pd_class(newest) == canvas_class) *************** *** 9699,9710 **** }
! /* static void canvas_reorder_last(t_canvas *x, int dest) { ! t_gobj *y = x->gl_list; ! for (y = x->gl_list; y->g_next; y = y2->g_next) {} ! if (y==x->gl_list) return; ! y->g_next = y; } - */
/* this supposes that $2=#X and $3=obj */ --- 9703,9721 ---- }
! static long canvas_children_count(t_canvas *x) { ! long n; ! t_gobj *y; ! glist_each(y,x) n++; ! return n; ! } ! static void canvas_reorder_last(t_canvas *x, int dest) { ! int n = canvas_children_count(x); ! fprintf(stderr,"canvas_reorder_last(x=%p,dest=%d) n=%d\n",x,dest,n); ! t_gobj *foo = glist_remove_nth(x,n-1); ! fprintf(stderr,"foo=%p\n",foo); ! if (!foo) {bug("glist_remove_nth returned NULL"); return;} ! glist_insert_nth(x,dest,foo); }
/* this supposes that $2=#X and $3=obj */ *************** *** 9716,9724 **** if (argv[0].a_type != A_FLOAT) {error("$1 must be float"); return;} i = atom_getfloat(argv); ! printf("canvas_object_insert: HELLO\n"); ! b = binbuf_new(); binbuf_restore(b, argc-5, argv+5); ! canvas_objtext(x,atom_getintarg(3,argc,argv),atom_getintarg(4,argc,argv),0,b,-1); ! /*canvas_reorder_last(x,i);*/ gobj_changed(x,0); /*err: canvas_unsetcurrent(x);*/ --- 9727,9739 ---- if (argv[0].a_type != A_FLOAT) {error("$1 must be float"); return;} i = atom_getfloat(argv); ! /* ! b = binbuf_new(); binbuf_restore(b, argc-5, argv+5); ! canvas_objtext(x,atom_getintarg(3,argc,argv),atom_getintarg(4,argc,argv),0,b); ! */ ! x->gl_next_add = i; ! canvas_obj(x,gensym("obj"),argc-3,argv+3); ! x->gl_next_add = -1; ! /* canvas_reorder_last(x,i); */ gobj_changed(x,0); /*err: canvas_unsetcurrent(x);*/