aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2017-03-18 01:55:14 +0100
committerPetter Rodhelind <petter.rodhelind@gmail.com>2017-03-18 01:55:14 +0100
commit2201497fdee0af3f14c6a8df85279f89a4b9c835 (patch)
tree947c02f522e3a9d9650a30777bf302a18ce15852 /src
parentcd099110f379d3a899b4dec03d3f955d68249fd8 (diff)
downloadplan9port-2201497fdee0af3f14c6a8df85279f89a4b9c835.tar.gz
plan9port-2201497fdee0af3f14c6a8df85279f89a4b9c835.tar.bz2
plan9port-2201497fdee0af3f14c6a8df85279f89a4b9c835.zip
Make Key-Up and Key-Down work with lines instead of scrolling
Diffstat (limited to 'src')
-rw-r--r--src/cmd/acme/text.c41
1 files changed, 33 insertions, 8 deletions
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(q0<t->file->b.nc && textreadc(t, q0)!='\n')
+ q0++;
+ if (q0+1 != t->file->b.nc)
+ q0++;
+ while(q0<t->file->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){