From f06fe8bef4964656f56975a97b448c1c788e7cf3 Mon Sep 17 00:00:00 2001 From: Miller Puckette Date: Tue, 6 Jan 2009 19:36:42 +0000 Subject: 0.42-2 (bug fixes) svn path=/trunk/; revision=10477 --- pd/src/g_text.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'pd/src/g_text.c') diff --git a/pd/src/g_text.c b/pd/src/g_text.c index 30184fcf..b8680e87 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -136,23 +136,39 @@ static void canvas_objtext(t_glist *gl, int xpix, int ypix, int selected, static void canvas_howputnew(t_canvas *x, int *connectp, int *xpixp, int *ypixp, int *indexp, int *totalp) { - int xpix, ypix, indx = 0, nobj = 0, x1, x2, y1, y2; + int xpix, ypix, indx = 0, nobj = 0, n2, x1, x2, y1, y2; int connectme = (x->gl_editor->e_selection && !x->gl_editor->e_selection->sel_next); if (connectme) { - t_gobj *g; + t_gobj *g, *selected = x->gl_editor->e_selection->sel_what; for (g = x->gl_list, nobj = 0; g; g = g->g_next, nobj++) - if (g == x->gl_editor->e_selection->sel_what) + if (g == selected) { gobj_getrect(g, x, &x1, &y1, &x2, &y2); indx = nobj; *xpixp = x1; *ypixp = y2 + 5; } + glist_noselect(x); + /* search back for 'selected' and if it isn't on the list, + plan just to connect from the last item on the list. */ + for (g = x->gl_list, n2 = 0; g; g = g->g_next, n2++) + { + if (g == selected) + { + indx = n2; + break; + } + else if (!g->g_next) + indx = nobj-1; + } + } + else + { + glist_getnextxy(x, xpixp, ypixp); + glist_noselect(x); } - else glist_getnextxy(x, xpixp, ypixp); - glist_noselect(x); *connectp = connectme; *indexp = indx; *totalp = nobj; -- cgit v1.2.1