Commit f5320ad6 authored by Jonathan Wilkes's avatar Jonathan Wilkes

remove unused MA_DRAGTEXT code paths, fix some formatting

parent 6316a9c5
......@@ -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
......
......@@ -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;
......
......@@ -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);
}
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment