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/9term/wind.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/cmd/9term/wind.c') diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c index 4cc9c207..aa7c8288 100644 --- a/src/cmd/9term/wind.c +++ b/src/cmd/9term/wind.c @@ -36,7 +36,7 @@ static Image *lightholdcol; static Image *paleholdcol; Window* -wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl, int scrolling) +wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl) { Window *w; Rectangle r; @@ -77,7 +77,6 @@ wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl, int scrolling) w->topped = ++topped; w->id = ++id; w->notefd = -1; - w->scrolling = scrolling; w->dir = estrdup(startdir); w->label = estrdup(""); r = insetrect(w->i->r, Selborder); @@ -192,7 +191,7 @@ winctl(void *arg) { Rune *rp, *bp, *up, *kbdr; uint qh; - int nr, nb, c, wid, i, npart, initial, lastb; + int nr, nb, c, wid, i, npart, initial, lastb, scrolling; char *s, *t, part[UTFmax]; Window *w; Mousestate *mp, m; @@ -248,10 +247,7 @@ winctl(void *arg) alts[WMouseread].op = CHANSND; else alts[WMouseread].op = CHANNOP; - if(!w->scrolling && !w->mouseopen && w->qh>w->org+w->f.nchars) - alts[WCwrite].op = CHANNOP; - else - alts[WCwrite].op = CHANSND; + alts[WCwrite].op = CHANSND; if(w->deleted || !w->wctlready) alts[WWread].op = CHANNOP; else @@ -369,8 +365,9 @@ winctl(void *arg) w->qh = qh; } nr = up - rp; + scrolling = w->org <= w->qh && w->qh <= w->org + w->f.nchars; w->qh = winsert(w, rp, nr, w->qh)+nr; - if(w->scrolling || w->mouseopen) + if(scrolling) wshow(w, w->qh); wsetselect(w, w->q0, w->q1); wscrdraw(w); -- cgit v1.2.3