Simplified the scrolldownline function. - sam - An updated version of the sam text editor.
 (HTM) git clone git://vernunftzentrum.de/sam.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 9e3cf08d5206503fa620136bd8b89528f5ca882c
 (DIR) parent 1b35b31c5c3faf98c9a1d239874b41454dd3859e
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Thu,  1 Sep 2016 17:15:03 -0500
       
       Simplified the scrolldownline function.
       
       Diffstat:
         doc/sam.1                           |       6 ++++++
         samterm/main.c                      |      12 +++++++-----
       
       2 files changed, 13 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/doc/sam.1 b/doc/sam.1
       @@ -1029,6 +1029,12 @@ Stores output of shell commands executed by
        .Xr ed 1
        .Sh BUGS
        .Pp
       +When using a mouse chord that targets a layer that isn't the front layer
       +.Pq "e.g. when scrolling using the mouse wheel on a background layer" ","
       +scrolling may jump unexpectedly if the layer was first moved to a lower part of the file
       +.Pq "e.g. by searching"
       +and then scrolled while still in the background.
       +.Pp
        The only human language in which colors may be specified is English.
        .Pp
        The only human language in which output is generated is English.
 (DIR) diff --git a/samterm/main.c b/samterm/main.c
       @@ -539,13 +539,15 @@ cmdscrollupline(Flayer *l, long a, Text *t)
        static long
        cmdscrolldownline(Flayer *l, long a, Text *t)
        {
       -    long tot = scrtotal(l);
       -    long p0 = l->origin + frcharofpt(&l->f, Pt(l->f.r.min.x, l->f.r.min.y + l->f.fheight));
       -    long p1 = l->origin + frcharofpt(&l->f, Pt(l->f.r.min.x, l->f.r.max.y - l->f.fheight / 2));
       +    long e = t->rasp.nrunes;
        
       -    if (p0 < tot && p1 < tot)
       -        horigin(t->tag, p0, l);
       +    if (l->origin + l->f.nchars < e){
       +        long x = l->origin;
       +        while (x + l->f.nchars < e && raspc(&t->rasp, x) != '\n')
       +            x++;
        
       +        horigin(t->tag, x + 1, l);
       +    }
            return a;
        }