aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/xfid.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/xfid.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/xfid.c')
-rw-r--r--src/cmd/acme/xfid.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c
index 18b06dd1..a1cc3848 100644
--- a/src/cmd/acme/xfid.c
+++ b/src/cmd/acme/xfid.c
@@ -395,6 +395,14 @@ xfidread(Xfid *x)
winunlock(w);
}
+static int
+shouldscroll(Text *t, uint q0, int qid)
+{
+ if(qid == Qcons)
+ return TRUE;
+ return t->org <= q0 && q0 <= t->org+t->fr.nchars;
+}
+
void
xfidwrite(Xfid *x)
{
@@ -510,7 +518,7 @@ xfidwrite(Xfid *x)
if(tq1 >= q0)
tq1 += nr;
textsetselect(t, tq0, tq1);
- if(t->org <= q0 && q0 <= t->org+t->fr.nchars)
+ if(shouldscroll(t, q0, qid))
textshow(t, q0+nr, q0+nr, 0);
textscrdraw(t);
winsettag(w);
@@ -568,7 +576,7 @@ xfidwrite(Xfid *x)
}
q0 = textbsinsert(t, q0, r, nr, TRUE, &nr);
textsetselect(t, t->q0, t->q1); /* insert could leave it somewhere else */
- if(qid!=QWwrsel && t->org <= q0 && q0 < t->org+t->fr.nchars)
+ if(qid!=QWwrsel && shouldscroll(t, q0, qid))
textshow(t, q0+nr, q0+nr, 1);
textscrdraw(t);
}