aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-11 10:04:34 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-11 10:04:34 +0200
commite324e6975367c235ed5413f76fdc3d5189cd00a2 (patch)
tree3d421c8189ebcc66263c6c7c21f4af022091bde3 /vis.c
parentaa3948409ade9064d90f3e60af5201da83b097d7 (diff)
downloadvis-e324e6975367c235ed5413f76fdc3d5189cd00a2.tar.gz
vis-e324e6975367c235ed5413f76fdc3d5189cd00a2.tar.xz
Add :qall command
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vis.c b/vis.c
index b99e1dc..8439856 100644
--- a/vis.c
+++ b/vis.c
@@ -380,6 +380,8 @@ static bool cmd_gotoline(const char *argv[]);
static bool cmd_open(const char *argv[]);
/* close the current window, if argv[0] contains a '!' discard modifications */
static bool cmd_quit(const char *argv[]);
+/* close all windows, exit editor, if argv[0] contains a '!' discard modifications */
+static bool cmd_qall(const char *argv[]);
/* for each argument try to insert the file content at current cursor postion */
static bool cmd_read(const char *argv[]);
static bool cmd_substitute(const char *argv[]);
@@ -862,12 +864,24 @@ static bool cmd_quit(const char *argv[]) {
}
if (!force && text_modified(vis->win->text))
return false;
- editor_window_close(vis);
+ editor_window_close(vis->win);
if (!vis->windows)
running = false;
return true;
}
+static bool cmd_qall(const char *argv[]) {
+ bool force = strchr(argv[0], '!') != NULL;
+ for (EditorWin *next, *win = vis->windows; win; win = next) {
+ next = win->next;
+ if (!text_modified(vis->win->text) || force)
+ editor_window_close(win);
+ }
+ if (!vis->windows)
+ running = false;
+ return vis->windows == NULL;
+}
+
static bool cmd_read(const char *argv[]) {
size_t pos = window_cursor_get(vis->win->win);
for (const char **file = &argv[1]; *file; file++) {