From 667b29ccc16bd6e63382acb7cb1a9a254d4b96d9 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Wed, 20 May 2015 09:31:45 +0430 Subject: [PATCH] ex: td option for text direction --- dir.c | 6 +++--- ex.c | 3 ++- vi.c | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dir.c b/dir.c index 1e21068..3f43bc3 100644 --- a/dir.c +++ b/dir.c @@ -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 */ diff --git a/ex.c b/ex.c index fc651e6..7cb5296 100644 --- a/ex.c +++ b/ex.c @@ -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) @@ -446,6 +446,7 @@ static struct option { } options[] = { {"ai", "autoindent", &xai}, {"ic", "ignorecase", &xic}, + {"td", "textdirection", &xdir}, }; static char *cutword(char *s, char *d) diff --git a/vi.c b/vi.c index 81df330..968bc80 100644 --- a/vi.c +++ b/vi.c @@ -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; -- 2.11.4.GIT