From 2201497fdee0af3f14c6a8df85279f89a4b9c835 Mon Sep 17 00:00:00 2001 From: Petter Rodhelind Date: Sat, 18 Mar 2017 01:55:14 +0100 Subject: Make Key-Up and Key-Down work with lines instead of scrolling --- src/cmd/acme/text.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 7634d921..21810860 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -681,10 +681,19 @@ texttype(Text *t, Rune r) textshow(t, t->q1+1, t->q1+1, TRUE); return; case Kdown: - if(t->what == Tag) - goto Tagdown; - n = t->fr.maxlines/3; - goto case_Down; + typecommit(t); + nnb = 0; + if(t->q0>0 && textreadc(t, t->q0-1)!='\n') + nnb = textbswidth(t, 0x15); + q0 = t->q0; + while(q0file->b.nc && textreadc(t, q0)!='\n') + q0++; + if (q0+1 != t->file->b.nc) + q0++; + while(q0file->b.nc && textreadc(t, q0)!='\n' && nnb--) + q0++; + textshow(t, q0, q0, TRUE); + return; case Kscrollonedown: if(t->what == Tag) goto Tagdown; @@ -699,10 +708,25 @@ texttype(Text *t, Rune r) textsetorigin(t, q0, TRUE); return; case Kup: - if(t->what == Tag) - goto Tagup; - n = t->fr.maxlines/3; - goto case_Up; + typecommit(t); + q0 = t->q0; + nnb = 0; + n = 0; + if(q0>0 && textreadc(t, q0-1)!='\n') + nnb = textbswidth(t, 0x15); + q0 -= nnb; + if (q0>0) + q0--; + while (q0>0 && textreadc(t, q0-1)!='\n') + if (q0 == 0) + break; + else { + q0--; + n++; + } + q0 += (nnb > n) ? n : nnb; + textshow(t, q0, q0, TRUE); + return; case Kscrolloneup: if(t->what == Tag) goto Tagup; @@ -758,6 +782,7 @@ texttype(Text *t, Rune r) undo(t, nil, nil, TRUE, 0, nil, 0); return; + Tagdown: /* expand tag to show all text */ if(!t->w->tagexpand){ -- cgit v1.2.3