From 87e22336396cfb8350b0395c8c91060e029478d3 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Sat, 7 Dec 2013 20:18:43 -0500 Subject: [PATCH] added ability for comments to be navigated by rows (using up/down), as opposed to home/end which takes you to the beginning/end, or ctrl+left/right which takes you to the next space --- pd/src/g_rtext.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pd/src/g_rtext.c b/pd/src/g_rtext.c index 65657a9aa..0968ad975 100644 --- a/pd/src/g_rtext.c +++ b/pd/src/g_rtext.c @@ -671,8 +671,26 @@ be printable in whatever 8-bit character set we find ourselves. */ u8_dec(x->x_buf, &x->x_selstart); } } - /* this should be improved... life's too short */ - else if (!strcmp(keysym->s_name, "Up") || !strcmp(keysym->s_name, "Home")) + else if (!strcmp(keysym->s_name, "Up")) + { + if (x->x_selstart) + u8_dec(x->x_buf, &x->x_selstart); + while (x->x_selstart > 0 && (x->x_buf[x->x_selstart] != '\n' && x->x_buf[x->x_selstart] != '\v')) + u8_dec(x->x_buf, &x->x_selstart); + x->x_selend = x->x_selstart; + last_sel = 0; + } + else if (!strcmp(keysym->s_name, "Down")) + { + while (x->x_selend < x->x_bufsize && + (x->x_buf[x->x_selend] != '\n' && x->x_buf[x->x_selend] != '\v')) + u8_inc(x->x_buf, &x->x_selend); + if (x->x_selend < x->x_bufsize) + u8_inc(x->x_buf, &x->x_selend); + x->x_selstart = x->x_selend; + last_sel = 0; + } + else if (!strcmp(keysym->s_name, "Home")) { if (x->x_selstart) u8_dec(x->x_buf, &x->x_selstart); @@ -681,7 +699,7 @@ be printable in whatever 8-bit character set we find ourselves. */ x->x_selend = x->x_selstart; last_sel = 0; } - else if (!strcmp(keysym->s_name, "Down") || !strcmp(keysym->s_name, "End")) + else if (!strcmp(keysym->s_name, "End")) { while (x->x_selend < x->x_bufsize && x->x_buf[x->x_selend] != '\n') -- GitLab