Documented the dot-movement keys. - 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 f8183e171e2e3023251bf5346193b2abbee889bc
 (DIR) parent 0ab74c4a46c212b505bc792cdc3bb8e240768299
 (HTM) Author: Rob King <jking@deadpixi.com>
       Date:   Tue,  4 Aug 2015 22:25:41 -0500
       
       Documented the dot-movement keys.
       
       Ensured that dot is collapsed before keyboard-initiated movement
       begins.
       
       Diffstat:
         doc/sam.1                           |       1 +
         doc/sam.1.pdf                       |       0 
         samterm/main.c                      |     134 ++++++++++++++++---------------
       
       3 files changed, 71 insertions(+), 64 deletions(-)
       ---
 (DIR) diff --git a/doc/sam.1 b/doc/sam.1
       @@ -726,6 +726,7 @@ Backspace deletes the previous character, while Control-W deletes the previous w
        Escape selects
        .Pq "sets dot to"
        everything typed since the last mouse hit.
       +Control-S, Control-D, Control-E, and Control-X collapse the selection and the move it one character to the left or right (Control-S and Control-D) or one line up or down (Control-E and Control-X).
        .Pp
        Button 1 changes the selection.
        Pointing to a non-current window with button 1 makes it current; within the current window, button 1 selects text, thus setting dot.
 (DIR) diff --git a/doc/sam.1.pdf b/doc/sam.1.pdf
       Binary files differ.
 (DIR) diff --git a/samterm/main.c b/samterm/main.c
       @@ -460,13 +460,15 @@ type(Flayer *l, int res)        /* what a bloody mess this is */
                Rune *p = buf;
                int c, backspacing, moving;
                long a;
       -        int scrollkey, upkey;
       +        int scrollkey, upkey, movekey;
        
                scrollkey = 0;
                upkey = 0;
                if(res == RKeyboard) {
       -                scrollkey = qpeekc()==SCROLLKEY;        /* ICK */
       -                upkey = qpeekc() == UPKEY;
       +        int pc = qpeekc();
       +                scrollkey = pc==SCROLLKEY;        /* ICK */
       +                upkey = pc == UPKEY;
       +        movekey = (pc == 0x13 || pc == 0x04 || pc == 0x05 || pc == 0x18);
                }
        
                if(lock || t->lock){
       @@ -474,7 +476,7 @@ type(Flayer *l, int res)        /* what a bloody mess this is */
                        return;
                }
                a = l->p0;
       -        if(a!=l->p1 && !scrollkey && !upkey){
       +        if(a!=l->p1 && !scrollkey && !upkey && !movekey){
                        flushtyping(1);
                        cut(t, t->front, 1, 1);
                        return; /* it may now be locked */
       @@ -528,73 +530,77 @@ type(Flayer *l, int res)        /* what a bloody mess this is */
                } else if (moving){
                        switch(c){
                        case 0x13: /* ctrl-s */
       -            flushtyping(0);
       -            if (a > 0)
       -                    a--;
       -            flsetselect(l, a, a);
       -            center(l, a);
       -                break;
       +                            flsetselect(l, a, a);
       +                            flushtyping(0);
       +                            if (a > 0)
       +                                    a--;
       +                            flsetselect(l, a, a);
       +                            center(l, a);
       +                        break;
        
       -            case 0x04: /* ctrl-d */
       -                flushtyping(0);
       -                if (a < t->rasp.nrunes)
       -                        a++;
       -                flsetselect(l, a, a);
       -                center(l, a);
       -                break;
       +                    case 0x04: /* ctrl-d */
       +                            flsetselect(l, a, a);
       +                        flushtyping(0);
       +                        if (a < t->rasp.nrunes)
       +                                a++;
       +                        flsetselect(l, a, a);
       +                        center(l, a);
       +                        break;
            
       -            case 0x05: /* ctrl-e */
       -                flushtyping(1);
       -                if (a > 0){
       -                    long n0, n1, count = 0;
       -                    while (a > 0 && raspc(&t->rasp, a - 1) != '\n'){
       -                        a--;
       -                        count++;
       -                    }
       -                    if (a > 0){
       -                        n1 = a;
       -                        a--;
       -                        while (a > 0 && raspc(&t->rasp, a - 1) != '\n')
       -                            a--;
       +                    case 0x05: /* ctrl-e */
       +                            flsetselect(l, a, a);
       +                        flushtyping(1);
       +                        if (a > 0){
       +                                    long n0, n1, count = 0;
       +                                    while (a > 0 && raspc(&t->rasp, a - 1) != '\n'){
       +                                        a--;
       +                                        count++;
       +                                    }
       +                                    if (a > 0){
       +                                        n1 = a;
       +                                        a--;
       +                                        while (a > 0 && raspc(&t->rasp, a - 1) != '\n')
       +                                                    a--;
            
       -                        n0 = a;
       -                        a = (n0 + count > n1) ? n1 - 1 : n0 + count;
       -                        flsetselect(l, a, a);
       -                        center(l, a);
       -                    }
       -            }
       -            break;
       -
       -            case 0x18: /* ctrl-x */
       -                flushtyping(1);
       -                if (a < t->rasp.nrunes){
       -                        long n0, n1, n2, p0, count = 0;
       +                                        n0 = a;
       +                                        a = (n0 + count > n1) ? n1 - 1 : n0 + count;
       +                                        flsetselect(l, a, a);
       +                                        center(l, a);
       +                                    }
       +                            }
       +                            break;
       +
       +                            case 0x18: /* ctrl-x */
       +                                    flsetselect(l, a, a);
       +                                flushtyping(1);
       +                                if (a < t->rasp.nrunes){
       +                                        long n0, n1, n2, p0, count = 0;
                
       -                        p0 = a;
       -                        while (a > 0 && raspc(&t->rasp, a - 1) != '\n'){
       -                            a--;
       -                            count++;
       -                        }
       -                        n0 = a;
       +                                        p0 = a;
       +                                        while (a > 0 && raspc(&t->rasp, a - 1) != '\n'){
       +                                                    a--;
       +                                                    count++;
       +                                        }
       +                                        n0 = a;
                
       -                        a = p0;
       -                        while (a < t->rasp.nrunes && raspc(&t->rasp, a) != '\n')
       -                            a++;
       -                        n1 = ++a;
       +                                        a = p0;
       +                                        while (a < t->rasp.nrunes && raspc(&t->rasp, a) != '\n')
       +                                                    a++;
       +                                        n1 = ++a;
                
       -                        a++;
       -                        while (a < t->rasp.nrunes && raspc(&t->rasp, a) != '\n')
       -                            a++;
       -                        n2 = a;
       +                                        a++;
       +                                        while (a < t->rasp.nrunes && raspc(&t->rasp, a) != '\n')
       +                                                    a++;
       +                                        n2 = a;
                
       -                        if (n2 < t->rasp.nrunes && n1 != n2){
       -                            a = (n1 + count > n2) ? n2 : n1 + count;
       -                            flsetselect(l, a, a);
       -                            center(l, a);
       -                        }
       -                }
       -            break;
       -                }
       +                                        if (n2 < t->rasp.nrunes && n1 != n2){
       +                                                    a = (n1 + count > n2) ? n2 : n1 + count;
       +                                                    flsetselect(l, a, a);
       +                                                    center(l, a);
       +                                        }
       +                                }
       +                           break;
       +                   }
                }else if(backspacing && !lock){
                        if(l->f.p0>0 && a>0){
                                switch(c){