diff options
author | Russ Cox <rsc@swtch.com> | 2011-08-02 07:55:20 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2011-08-02 07:55:20 -0400 |
commit | 65a5e5fe46b9ff928babbef063030c62fafc6b43 (patch) | |
tree | af45ab88785cec7b2507913b62afef7c7969a452 /src/cmd/9term | |
parent | 76864eb6cd2759efd687f392ada4f1facbf06250 (diff) | |
download | plan9port-65a5e5fe46b9ff928babbef063030c62fafc6b43.tar.gz plan9port-65a5e5fe46b9ff928babbef063030c62fafc6b43.tar.bz2 plan9port-65a5e5fe46b9ff928babbef063030c62fafc6b43.zip |
9term: home/end like acme
R=rsc
http://codereview.appspot.com/4830052
Diffstat (limited to 'src/cmd/9term')
-rw-r--r-- | src/cmd/9term/dat.h | 1 | ||||
-rw-r--r-- | src/cmd/9term/wind.c | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/cmd/9term/dat.h b/src/cmd/9term/dat.h index 052f3b82..32b75414 100644 --- a/src/cmd/9term/dat.h +++ b/src/cmd/9term/dat.h @@ -117,6 +117,7 @@ struct Window uint q0; uint q1; uint qh; + uint iq1; /* last input position */ int id; char name[32]; uint namecount; diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c index aa7c8288..a7050a2d 100644 --- a/src/cmd/9term/wind.c +++ b/src/cmd/9term/wind.c @@ -623,10 +623,18 @@ wkeyctl(Window *w, Rune r) } return; case Khome: - wshow(w, 0); + if(w->org > w->iq1) { + q0 = wbacknl(w, w->iq1, 1); + wsetorigin(w, q0, TRUE); + } else + wshow(w, 0); return; case Kend: - wshow(w, w->nr); + if(w->iq1 > w->org+w->f.nchars) { + q0 = wbacknl(w, w->iq1, 1); + wsetorigin(w, q0, TRUE); + } else + wshow(w, w->nr); return; case 0x01: /* ^A: beginning of line */ if(w->q0==0 || w->q0==w->qh || w->r[w->q0-1]=='\n') @@ -689,6 +697,7 @@ wkeyctl(Window *w, Rune r) w->qh = w->nr; wshow(w, w->qh); winterrupt(w); + w->iq1 = w->q0; return; case 0x06: /* ^F: file name completion */ case Kins: /* Insert: file name completion */ @@ -699,6 +708,7 @@ wkeyctl(Window *w, Rune r) q0 = w->q0; q0 = winsert(w, rp, nr, q0); wshow(w, q0+nr); + w->iq1 = w->q0; free(rp); return; case 0x08: /* ^H: erase character */ @@ -717,12 +727,14 @@ wkeyctl(Window *w, Rune r) wdelete(w, q0, q0+nb); wsetselect(w, q0, q0); } + w->iq1 = w->q0; return; } /* otherwise ordinary character; just insert */ q0 = w->q0; q0 = winsert(w, &r, 1, q0); wshow(w, q0+1); + w->iq1 = w->q0; } void @@ -921,6 +933,8 @@ wdelete(Window *w, uint q0, uint q1) return; runemove(w->r+q0, w->r+q1, w->nr-q1); w->nr -= n; + if(q0 < w->iq1) + w->iq1 -= min(n, w->iq1-q0); if(q0 < w->q0) w->q0 -= min(n, w->q0-q0); if(q0 < w->q1) @@ -1609,6 +1623,8 @@ winsert(Window *w, Rune *r, int n, uint q0) w->qh += n; if(q0 < w->org) w->org += n; + if(q0 < w->iq1) + w->iq1 += n; else if(q0 <= w->org+w->f.nchars) frinsert(&w->f, r, r+n, q0-w->org); return q0; |