tex: wq command - neatvi - [fork] simple vi-type editor with UTF-8 support | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 76467fcd1b5e8fc4fbc9ac1eae7d933272a8c09c | |
parent 4b67186ed7bb5e6e255f78c351151bf72e51919d | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Thu, 14 May 2015 11:23:22 +0430 | |
ex: wq command | |
Diffstat: | |
M ex.c | 16 ++++++++++------ | |
1 file changed, 10 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/ex.c b/ex.c | |
t@@ -181,6 +181,11 @@ static int ex_region(char *loc, int *beg, int *end) | |
return 0; | |
} | |
+static void ec_quit(char *ec) | |
+{ | |
+ xquit = 1; | |
+} | |
+ | |
static void ec_edit(char *ec) | |
{ | |
char arg[EXLEN]; | |
t@@ -215,10 +220,11 @@ static void ec_read(char *ec) | |
static void ec_write(char *ec) | |
{ | |
- char arg[EXLEN], loc[EXLEN]; | |
+ char cmd[EXLEN], arg[EXLEN], loc[EXLEN]; | |
char *path; | |
int beg, end; | |
int fd; | |
+ ex_cmd(ec, cmd); | |
ex_arg(ec, arg); | |
ex_loc(ec, loc); | |
path = arg[0] ? arg : xpath; | |
t@@ -233,6 +239,8 @@ static void ec_write(char *ec) | |
lbuf_wr(xb, fd, beg, end); | |
close(fd); | |
} | |
+ if (!strcmp("wq", cmd)) | |
+ ec_quit("wq"); | |
} | |
static void ec_insert(char *ec) | |
t@@ -423,11 +431,6 @@ static void ec_substitute(char *ec) | |
free(rep); | |
} | |
-static void ec_quit(char *ec) | |
-{ | |
- xquit = 1; | |
-} | |
- | |
static struct excmd { | |
char *abbr; | |
char *name; | |
t@@ -445,6 +448,7 @@ static struct excmd { | |
{"q", "quit", ec_quit}, | |
{"r", "read", ec_read}, | |
{"w", "write", ec_write}, | |
+ {"wq", "wq", ec_write}, | |
{"u", "undo", ec_undo}, | |
{"r", "redo", ec_redo}, | |
{"s", "substitute", ec_substitute}, |