tvi: ^d and ^u - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit c54948868fdd6994a66acff21cb980fef4356465
 (DIR) parent 6a4f7acda55fd2175a268b20b308ee70ae2fa38b
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Wed, 17 Jun 2015 19:40:04 +0430
       
       vi: ^d and ^u
       
       Tested by Christian Neukirchen <chneukirchen@gmail.com>.
       
       Diffstat:
         M vi.c                                |      25 +++++++++++++++++++++++++
       
       1 file changed, 25 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/vi.c b/vi.c
       t@@ -22,6 +22,7 @@ static int vi_ybuf;                /* current yank buffer */
        static char *vi_kmap;                /* current insertion keymap */
        static int vi_pcol;                /* the column requested by | command */
        static int vi_printed;                /* ex_print() calls since the last command */
       +static int vi_scroll;                /* scroll amount for ^f and ^d*/
        
        static void vi_wait(void)
        {
       t@@ -1066,6 +1067,30 @@ static void vi(void)
                                                break;
                                        redraw = 1;
                                        break;
       +                        case TK_CTL('u'):
       +                                if (xrow == 0)
       +                                        break;
       +                                if (vi_arg1)
       +                                        vi_scroll = vi_arg1;
       +                                n = vi_scroll ? vi_scroll : xrows / 2;
       +                                xrow = MAX(0, xrow - n);
       +                                if (xtop > 0)
       +                                        xtop = MAX(0, xtop - n);
       +                                redraw = 1;
       +                                xoff = lbuf_indents(xb, xrow);
       +                                break;
       +                        case TK_CTL('d'):
       +                                if (xrow == lbuf_len(xb) - 1)
       +                                        break;
       +                                if (vi_arg1)
       +                                        vi_scroll = vi_arg1;
       +                                n = vi_scroll ? vi_scroll : xrows / 2;
       +                                xrow = MIN(MAX(0, lbuf_len(xb) - 1), xrow + n);
       +                                if (xtop < lbuf_len(xb) - xrows)
       +                                        xtop = MIN(lbuf_len(xb) - xrows, xtop + n);
       +                                redraw = 1;
       +                                xoff = lbuf_indents(xb, xrow);
       +                                break;
                                case TK_CTL('z'):
                                        term_pos(xrows, 0);
                                        term_suspend();