tex: restore the first visible line when switching buffers - 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 6934b8bc85446824a8c2ad3fd5d699832f5c7aeb
 (DIR) parent 76a36a5a78f420961f660f1f10067587fd39463e
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Fri, 15 Apr 2016 14:36:18 +0430
       
       ex: restore the first visible line when switching buffers
       
       Diffstat:
         M ex.c                                |       6 +++++-
       
       1 file changed, 5 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/ex.c b/ex.c
       t@@ -29,7 +29,7 @@ static struct buf {
                char ft[32];
                char *path;
                struct lbuf *lb;
       -        int row, off;
       +        int row, off, top;
                long mtime;                /* modification time */
        } bufs[8];
        
       t@@ -70,6 +70,7 @@ static int bufs_open(char *path)
                bufs[i].lb = lbuf_make();
                bufs[i].row = 0;
                bufs[i].off = 0;
       +        bufs[i].top = 0;
                bufs[i].mtime = -1;
                strcpy(bufs[i].ft, syn_filetype(path));
                return i;
       t@@ -92,6 +93,7 @@ static void bufs_switch(int idx)
                bufs_swap(0, idx);
                xrow = bufs[0].row;
                xoff = bufs[0].off;
       +        xtop = bufs[0].top;
        }
        
        char *ex_path(void)
       t@@ -371,6 +373,7 @@ static int ec_edit(char *ec)
                        return 1;
                bufs[0].row = xrow;
                bufs[0].off = xoff;
       +        bufs[0].top = xtop;
                if (arg[0] && bufs_find(path) >= 0) {
                        bufs_switch(bufs_find(path));
                        return 0;
       t@@ -392,6 +395,7 @@ static int ec_edit(char *ec)
                bufs[0].mtime = mtime(ex_path());
                xrow = MAX(0, MIN(xrow, lbuf_len(xb) - 1));
                xoff = 0;
       +        xtop = MAX(0, MIN(xtop, lbuf_len(xb) - 1));
                return 0;
        }