From f5320ad64b292783afc8a6e347c61de7818e4951 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Thu, 31 Jan 2019 00:39:41 -0500 Subject: [PATCH] remove unused MA_DRAGTEXT code paths, fix some formatting --- pd/src/g_canvas.h | 7 ++-- pd/src/g_editor.c | 88 ++++++++++++++--------------------------------- pd/src/g_rtext.c | 62 +-------------------------------- pd/src/s_inter.c | 8 ++--- 4 files changed, 32 insertions(+), 133 deletions(-) diff --git a/pd/src/g_canvas.h b/pd/src/g_canvas.h index 2c776f2b2..a3b5f7cd5 100644 --- a/pd/src/g_canvas.h +++ b/pd/src/g_canvas.h @@ -137,7 +137,8 @@ typedef struct _editor #define MA_CONNECT 2 /* make a connection */ #define MA_REGION 3 /* selection region */ #define MA_PASSOUT 4 /* send on to e_grab */ -#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */ +/* Text edition handled completely in the GUI now */ +//#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */ #define MA_RESIZE 6 /* drag to resize */ #define MA_SCROLL 7 /* scroll with middle click onto empty canvas */ @@ -498,10 +499,6 @@ EXTERN int text_xpix(t_text *x, t_glist *glist); EXTERN int text_ypix(t_text *x, t_glist *glist); /* -------------------- functions on rtexts ------------------------- */ -#define RTEXT_DOWN 1 -#define RTEXT_DRAG 2 -#define RTEXT_DBL 3 -#define RTEXT_SHIFT 4 // number in comment is the number in grep -w|wc EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who); //5 diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index cc5381aa0..92f03ded8 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3399,28 +3399,9 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, //selection (only if we are not hovering above an outlet) if (doit) { - t_rtext *rt; - if (ob && (rt = x->gl_editor->e_textedfor) && - rt == glist_findrtext(x, ob)) - { - rtext_mouse(rt, xpos - x1, ypos - y1, RTEXT_SHIFT); - x->gl_editor->e_onmotion = MA_DRAGTEXT; - x->gl_editor->e_xwas = x1; - x->gl_editor->e_ywas = y1; - } - else - { - //t_undo_redo_sel *buf = - // (t_undo_redo_sel *)getbytes(sizeof(*buf)); - //buf->u_undo = (t_undo_sel *)canvas_undo_set_selection(x); - - if (glist_isselected(x, y)) - glist_deselect(x, y); - else glist_select(x, y); - - //buf->u_redo = (t_undo_sel *)canvas_undo_set_selection(x); - //canvas_undo_add(x, 11, "selection", buf); - } + if (glist_isselected(x, y)) + glist_deselect(x, y); + else glist_select(x, y); } } else @@ -3636,45 +3617,33 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, t_rtext *rt; /* check if the box is being text edited */ nooutletafterall: - if (ob && (rt = x->gl_editor->e_textedfor) && - rt == glist_findrtext(x, ob)) + /* otherwise select and drag to displace */ + if (!glist_isselected(x, y)) { - rtext_mouse(rt, xpos - x1, ypos - y1, - (doublemod ? RTEXT_DBL : RTEXT_DOWN)); - x->gl_editor->e_onmotion = MA_DRAGTEXT; - x->gl_editor->e_xwas = x1; - x->gl_editor->e_ywas = y1; + //t_undo_redo_sel *buf = + // (t_undo_redo_sel *)getbytes(sizeof(*buf)); + //buf->u_undo = + // (t_undo_sel *)canvas_undo_set_selection(x); + + glist_noselect(x); + glist_select(x, y); + //buf->u_redo = + // (t_undo_sel *)canvas_undo_set_selection(x); + //canvas_undo_add(x, 11, "selection", buf); } else { - /* otherwise select and drag to displace */ - if (!glist_isselected(x, y)) - { - //t_undo_redo_sel *buf = - // (t_undo_redo_sel *)getbytes(sizeof(*buf)); - //buf->u_undo = - // (t_undo_sel *)canvas_undo_set_selection(x); - - glist_noselect(x); - glist_select(x, y); - //buf->u_redo = - // (t_undo_sel *)canvas_undo_set_selection(x); - //canvas_undo_add(x, 11, "selection", buf); - } - else - { - canvas_check_nlet_highlights(x); - } - //toggle_moving = 1; - //sys_vgui("pdtk_update_xy_tooltip .x%lx %d %d\n", - // x, (int)xpos, (int)ypos); - //sys_vgui("pdtk_toggle_xy_tooltip .x%lx %d\n", x, 1); - x->gl_editor->e_onmotion = MA_MOVE; - /* once the code for creating a new object looks sane - we'll leave rendering the tooltips to the GUI. */ - //if (tooltips) - // sys_vgui("pdtk_tip .x%x.c 0 0\n", x); + canvas_check_nlet_highlights(x); } + //toggle_moving = 1; + //sys_vgui("pdtk_update_xy_tooltip .x%lx %d %d\n", + // x, (int)xpos, (int)ypos); + //sys_vgui("pdtk_toggle_xy_tooltip .x%lx %d\n", x, 1); + x->gl_editor->e_onmotion = MA_MOVE; + /* once the code for creating a new object looks sane + we'll leave rendering the tooltips to the GUI. */ + //if (tooltips) + // sys_vgui("pdtk_tip .x%x.c 0 0\n", x); } else // jsarlo @@ -5351,13 +5320,6 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, x->gl_editor->e_xwas = xpos; x->gl_editor->e_ywas = ypos; } - else if (x->gl_editor->e_onmotion == MA_DRAGTEXT) - { - t_rtext *rt = x->gl_editor->e_textedfor; - if (rt) - rtext_mouse(rt, xpos - x->gl_editor->e_xwas, - ypos - x->gl_editor->e_ywas, RTEXT_DRAG); - } else if (x->gl_editor->e_onmotion == MA_RESIZE) { int x11=0, y11=0, x12=0, y12=0; diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c index 348bad8dd..b82f34701 100644 --- a/pd/src/g_rtext.c +++ b/pd/src/g_rtext.c @@ -42,7 +42,6 @@ struct _rtext int x_selstart; /*-- byte offset --*/ int x_selend; /*-- byte offset --*/ int x_active; - int x_dragfrom; int x_drawnwidth; int x_drawnheight; t_text *x_text; @@ -575,7 +574,7 @@ void rtext_activate(t_rtext *x, int state) //sys_vgui(".x%lx.c focus %s\n", canvas, x->x_tag); glist->gl_editor->e_textedfor = x; glist->gl_editor->e_textdirty = 0; - x->x_dragfrom = x->x_selstart = 0; + x->x_selstart = 0; x->x_selend = x->x_bufsize; x->x_active = 1; } @@ -1045,62 +1044,3 @@ be printable in whatever 8-bit character set we find ourselves. */ } rtext_senditup(x, SEND_UPDATE, &w, &h, &indx); } - -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); -} diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c index 29acc4de2..d6f9f3b1a 100644 --- a/pd/src/s_inter.c +++ b/pd/src/s_inter.c @@ -717,8 +717,8 @@ void blargh(void) { static int lastend = -1; void sys_vvgui(const char *fmt, va_list ap) { - va_list aq; - va_copy(aq,ap); + va_list aq; + va_copy(aq, ap); int msglen; if (sys_nogui) @@ -738,7 +738,7 @@ void sys_vvgui(const char *fmt, va_list ap) { msglen = vsnprintf(sys_guibuf + sys_guibufhead, sys_guibufsize - sys_guibufhead, fmt, ap); va_end(ap); - if(msglen < 0) + if (msglen < 0) { fprintf(stderr, "Pd: buffer space wasn't sufficient for long GUI string\n"); return; @@ -749,7 +749,7 @@ void sys_vvgui(const char *fmt, va_list ap) { (msglen > GUI_ALLOCCHUNK ? msglen : GUI_ALLOCCHUNK); sys_trytogetmoreguibuf(newsize); - va_copy(ap,aq); + va_copy(ap, aq); msglen2 = vsnprintf(sys_guibuf + sys_guibufhead, sys_guibufsize - sys_guibufhead, fmt, ap); va_end(ap); -- GitLab