tvi: specify direction context with zL, zl, zr, and zR - neatvi - [fork] simple… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit aa607d3ef71740de17207fa9bc4fcd6a8d2eb556 | |
parent 62031568d8a420347c9be9b77bc75f80856e7281 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Wed, 6 May 2015 10:56:30 +0430 | |
vi: specify direction context with zL, zl, zr, and zR | |
Diffstat: | |
M ren.c | 6 ++++++ | |
M vi.c | 5 +++++ | |
M vi.h | 1 + | |
3 files changed, 12 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/ren.c b/ren.c | |
t@@ -40,6 +40,12 @@ static void bidi_reverse(int *ord, int beg, int end) | |
int ren_dir(char *s) | |
{ | |
+ if (xdir == 'R') | |
+ return -1; | |
+ if (xdir == 'l') | |
+ return *s && uc_dir(s) < 0 ? -1 : +1; | |
+ if (xdir == 'r') | |
+ return *s && uc_dir(s) > 0 ? +1 : -1; | |
return +1; | |
} | |
diff --git a/vi.c b/vi.c | |
t@@ -16,6 +16,7 @@ char xpath[PATHLEN]; /* current file */ | |
struct lbuf *xb; /* current buffer */ | |
int xrow, xcol, xtop; /* current row, column, and top row */ | |
int xled = 1; /* use the line editor */ | |
+int xdir = 'L'; /* current direction context */ | |
int xquit; | |
static void vi_draw(void) | |
t@@ -593,6 +594,10 @@ static void vi(void) | |
vc_put(c, pre1); | |
redraw = 1; | |
break; | |
+ case 'z': | |
+ xdir = vi_read(); | |
+ redraw = 1; | |
+ break; | |
default: | |
continue; | |
} | |
diff --git a/vi.h b/vi.h | |
t@@ -111,3 +111,4 @@ extern int xtop; | |
extern int xled; | |
extern char xpath[]; | |
extern int xquit; | |
+extern int xdir; |