aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/text.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2011-08-02 07:44:11 -0400
committerRuss Cox <rsc@swtch.com>2011-08-02 07:44:11 -0400
commit76864eb6cd2759efd687f392ada4f1facbf06250 (patch)
treed85cc2325a5ece172f0575ae20b58943a19f0480 /src/cmd/acme/text.c
parent67afaf385afa5a2bcc6b7640d7cec6cd5d17863e (diff)
downloadplan9port-76864eb6cd2759efd687f392ada4f1facbf06250.tar.gz
plan9port-76864eb6cd2759efd687f392ada4f1facbf06250.tar.bz2
plan9port-76864eb6cd2759efd687f392ada4f1facbf06250.zip
acme: scrolling fixes + new home/end
Home and End previously navigated between two different window locations: the top and the bottom of the text. Now they include a third waypoint: the location where typing last happened. Thus, in a win window, typing ls -l <home> scrolls to the beginning of the ls -l output. A second <home> continues to the top of the file. Makes Send scroll always, along with writes by external programs to +Errors. R=r CC=mccoyst http://codereview.appspot.com/4830051
Diffstat (limited to 'src/cmd/acme/text.c')
-rw-r--r--src/cmd/acme/text.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index 7ea4131c..ed0fc0c9 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -379,6 +379,8 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile)
}
}
+ if(q0 < t->iq1)
+ t->iq1 += n;
if(q0 < t->q1)
t->q1 += n;
if(q0 < t->q0)
@@ -472,6 +474,8 @@ textdelete(Text *t, uint q0, uint q1, int tofile)
}
}
}
+ if(t->iq1 < t->q0)
+ t->iq1 -= min(n, t->iq1-q0);
if(q0 < t->q0)
t->q0 -= min(n, t->q0-q0);
if(q0 < t->q1)
@@ -714,11 +718,19 @@ texttype(Text *t, Rune r)
return;
case Khome:
typecommit(t);
- textshow(t, 0, 0, FALSE);
+ if(t->org > t->iq1) {
+ q0 = textbacknl(t, t->iq1, 1);
+ textsetorigin(t, q0, TRUE);
+ } else
+ textshow(t, 0, 0, FALSE);
return;
case Kend:
typecommit(t);
- textshow(t, t->file->b.nc, t->file->b.nc, FALSE);
+ if(t->iq1 > t->org+t->fr.nchars) {
+ q0 = textbacknl(t, t->iq1, 1);
+ textsetorigin(t, q0, TRUE);
+ } else
+ textshow(t, t->file->b.nc, t->file->b.nc, FALSE);
return;
case 0x01: /* ^A: beginning of line */
typecommit(t);
@@ -771,6 +783,7 @@ texttype(Text *t, Rune r)
}
cut(t, t, nil, TRUE, TRUE, nil, 0);
textshow(t, t->q0, t->q0, 1);
+ t->iq1 = t->q0;
return;
case Kcmd+'v': /* %V: paste */
typecommit(t);
@@ -780,6 +793,7 @@ texttype(Text *t, Rune r)
}
paste(t, t, nil, TRUE, FALSE, nil, 0);
textshow(t, t->q0, t->q1, 1);
+ t->iq1 = t->q1;
return;
}
if(t->q1 > t->q0){
@@ -802,6 +816,7 @@ texttype(Text *t, Rune r)
textsetselect(t, t->eq0, t->q0);
if(t->ncache > 0)
typecommit(t);
+ t->iq1 = t->q0;
return;
case 0x08: /* ^H: erase character */
case 0x15: /* ^U: erase line */
@@ -844,6 +859,7 @@ texttype(Text *t, Rune r)
}
for(i=0; i<t->file->ntext; i++)
textfill(t->file->text[i]);
+ t->iq1 = t->q0;
return;
case '\n':
if(t->w->autoindent){
@@ -895,6 +911,7 @@ texttype(Text *t, Rune r)
textsetselect(t, t->q0+nr, t->q0+nr);
if(r=='\n' && t->w!=nil)
wincommit(t->w, t);
+ t->iq1 = t->q0;
}
void