From ba31ab3044765270d40c9da934dfc11e5f8b63c5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Apr 2011 13:18:07 -0400 Subject: 9term, acme: autoscroll Ignore scroll/noscroll window setting. Instead, scroll when the write begins in or immediately after the displayed window content. In the new scrolling discipline, executing "Noscroll" is replaced by typing Page Up or using the mouse to scroll higher in the buffer, and executing "Scroll" is replaced by typing End or using the mouse to scroll to the bottom of the buffer. R=r, r2 http://codereview.appspot.com/4433060 --- src/cmd/acme/dat.h | 1 - src/cmd/acme/exec.c | 1 + src/cmd/acme/xfid.c | 14 +++----------- 3 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src/cmd/acme') diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h index b15395fd..300ba65f 100644 --- a/src/cmd/acme/dat.h +++ b/src/cmd/acme/dat.h @@ -243,7 +243,6 @@ struct Window Range limit; uchar nopen[QMAX]; uchar nomark; - uchar noscroll; Range wrselrange; int rdselfd; Column *col; diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index a71b5b48..ad4da001 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -960,6 +960,7 @@ sendx(Text *et, Text *t, Text *_0, int _1, int _2, Rune *_3, int _4) if(textreadc(t, t->file->b.nc-1) != '\n'){ textinsert(t, t->file->b.nc, Lnl, 1, TRUE); textsetselect(t, t->file->b.nc, t->file->b.nc); + textshow(t, t->q1, t->q1, 1); } } diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index db5d54b0..18b06dd1 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -510,8 +510,8 @@ xfidwrite(Xfid *x) if(tq1 >= q0) tq1 += nr; textsetselect(t, tq0, tq1); - if(!t->w->noscroll) - textshow(t, q0, q0+nr, 0); + if(t->org <= q0 && q0 <= t->org+t->fr.nchars) + textshow(t, q0+nr, q0+nr, 0); textscrdraw(t); winsettag(w); free(r); @@ -568,7 +568,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->w->noscroll) + if(qid!=QWwrsel && t->org <= q0 && q0 < t->org+t->fr.nchars) textshow(t, q0+nr, q0+nr, 1); textscrdraw(t); } @@ -768,18 +768,10 @@ out: w->filemenu = TRUE; m = 4; }else - if(strncmp(p, "noscroll", 8) == 0){ /* turn off automatic scrolling */ - w->noscroll = TRUE; - m = 8; - }else if(strncmp(p, "cleartag", 8) == 0){ /* wipe tag right of bar */ wincleartag(w); settag = TRUE; m = 8; - }else - if(strncmp(p, "scroll", 6) == 0){ /* turn on automatic scrolling (writes to body only) */ - w->noscroll = FALSE; - m = 6; }else{ err = Ebadctl; break; -- cgit v1.2.3