tex: td option for text direction - 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 667b29ccc16bd6e63382acb7cb1a9a254d4b96d9
 (DIR) parent b4ee1db9e7a83a8d8105af24c4c18f130a09fe67
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Wed, 20 May 2015 09:31:45 +0430
       
       ex: td option for text direction
       
       Diffstat:
         M dir.c                               |       6 +++---
         M ex.c                                |       3 ++-
         M vi.c                                |       4 +++-
       
       3 files changed, 8 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/dir.c b/dir.c
       t@@ -68,14 +68,14 @@ int dir_context(char *s)
        {
                int found;
                int dir;
       -        if (xdir == 'L')
       +        if (xdir > +1)
                        return +1;
       -        if (xdir == 'R')
       +        if (xdir < -1)
                        return -1;
                found = rset_find(dir_rsctx, s ? s : "", 0, NULL, 0);
                if (!conf_dircontext(found, NULL, &dir))
                        return dir;
       -        return xdir == 'r' ? -1 : +1;
       +        return xdir < 0 ? -1 : +1;
        }
        
        /* reorder the characters in s */
 (DIR) diff --git a/ex.c b/ex.c
       t@@ -19,7 +19,7 @@ struct lbuf *xb;                /* current buffer */
        int xrow, xcol, xtop;                /* current row, column, and top row */
        int xrow_alt;                        /* alternate row, column, and top row */
        int xled = 1;                        /* use the line editor */
       -int xdir = 'L';                        /* current direction context */
       +int xdir = +1;                        /* current direction context */
        
        /* read ex command location */
        static char *ex_loc(char *s, char *loc)
       t@@ -446,6 +446,7 @@ static struct option {
        } options[] = {
                {"ai", "autoindent", &xai},
                {"ic", "ignorecase", &xic},
       +        {"td", "textdirection", &xdir},
        };
        
        static char *cutword(char *s, char *d)
 (DIR) diff --git a/vi.c b/vi.c
       t@@ -1136,9 +1136,11 @@ static void vi(void)
                                                break;
                                        case 'l':
                                        case 'r':
       +                                        xdir = z == 'r' ? -1 : +1;
       +                                        break;
                                        case 'L':
                                        case 'R':
       -                                        xdir = z;
       +                                        xdir = z == 'R' ? -2 : +2;
                                                break;
                                        }
                                        redraw = 1;