aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-22 13:25:02 +0200
committerPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-22 13:25:02 +0200
commit1365290d24a712f9f3022fc442211133cccb54ef (patch)
treef0a2283fcce2acb561a1605be26fcf005e4dc759 /src/cmd/acme
parent1ce2713f90fa4b510a49fdbc7c8285d179ffe5a4 (diff)
downloadplan9port-1365290d24a712f9f3022fc442211133cccb54ef.tar.gz
plan9port-1365290d24a712f9f3022fc442211133cccb54ef.tar.bz2
plan9port-1365290d24a712f9f3022fc442211133cccb54ef.zip
acme: Move one line up/down using ^P and ^N.
Diffstat (limited to 'src/cmd/acme')
-rw-r--r--src/cmd/acme/text.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 4c4e1be1..e47c97d2 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -695,19 +695,10 @@ texttype(Text *t, Rune r)
textshow(t, t->q1+1, t->q1+1, TRUE);
return;
case Kdown:
- typecommit(t);
- q0 = t->q0;
- nnb = 0;
- if(q0>0 && textreadc(t, q0-1)!='\n')
- nnb = textbswidth(t, 0x15);
- 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;
+ if(t->what == Tag)
+ goto Tagdown;
+ n = t->fr.maxlines/3;
+ goto case_Down;
case Kscrollonedown:
if(t->what == Tag)
goto Tagdown;
@@ -722,25 +713,10 @@ texttype(Text *t, Rune r)
textsetorigin(t, q0, TRUE);
return;
case Kup:
- 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;
+ if(t->what == Tag)
+ goto Tagup;
+ n = t->fr.maxlines/3;
+ goto case_Up;
case Kscrolloneup:
if(t->what == Tag)
goto Tagup;
@@ -808,6 +784,40 @@ texttype(Text *t, Rune r)
q0++;
textshow(t, q0, q0, TRUE);
return;
+ case 0x0E: /* ^N: move one line down */
+ typecommit(t);
+ q0 = t->q0;
+ nnb = 0;
+ if(q0>0 && textreadc(t, q0-1)!='\n')
+ nnb = textbswidth(t, 0x15);
+ 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 0x10: /* ^P: move one line 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 Kcmd+'c': /* %C: copy */
typecommit(t);
cut(t, t, nil, TRUE, FALSE, nil, 0);