diff options
| -rw-r--r-- | README | 1 | ||||
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 21 |
3 files changed, 23 insertions, 0 deletions
@@ -420,6 +420,7 @@ and their current support in vis. At the ':'-command prompt only the following commands are recognized: :nnn go to line nnn + :bdelete close all windows which display the same file as the current one :edit replace current file with a new one or reload it from disk :open open a new window :qall close all windows, exit editor diff --git a/config.def.h b/config.def.h index bed3c80..655442d 100644 --- a/config.def.h +++ b/config.def.h @@ -48,6 +48,7 @@ enum { /* command recognized at the ':'-prompt. tested top to bottom, first match wins. */ static Command cmds[] = { { "^[0-9]+$", cmd_gotoline, false }, + { "^bd(elete)?!?$", cmd_bdelete, false }, { "^e(dit)?!?$", cmd_edit, false }, { "^new$", cmd_new, false }, { "^o(pen)?$", cmd_open, false }, @@ -457,6 +457,8 @@ static bool cmd_open(const char *argv[]); static bool cmd_edit(const char *argv[]); /* close the current window, if argv[0] contains a '!' discard modifications */ static bool cmd_quit(const char *argv[]); +/* close all windows which show current file. if argv[0] contains a '!' discard modifications */ +static bool cmd_bdelete(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 */ @@ -1221,6 +1223,25 @@ static bool cmd_quit(const char *argv[]) { return true; } +static bool cmd_bdelete(const char *argv[]) { + bool force = strchr(argv[0], '!') != NULL; + Text *txt = vis->win->text; + if (text_modified(txt) && !force) { + editor_info_show(vis, "No write since last change " + "(add ! to override)"); + return false; + } + for (EditorWin *next, *win = vis->windows; win; win = next) { + next = win->next; + if (win->text == txt) + editor_window_close(win); + } + + if (!vis->windows) + quit(NULL); + return true; +} + static bool cmd_qall(const char *argv[]) { bool force = strchr(argv[0], '!') != NULL; for (EditorWin *next, *win = vis->windows; win; win = next) { |
