diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-27 15:59:08 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-27 16:05:47 +0200 |
| commit | d66ee8dcf013dc4308ad96e07649c2f4f972852c (patch) | |
| tree | b858d175130c640d8802ab0cc052c2e652d7da88 /vis.c | |
| parent | 11044c55e96183816a44a0bdd9a03716b6388c44 (diff) | |
| download | vis-d66ee8dcf013dc4308ad96e07649c2f4f972852c.tar.gz vis-d66ee8dcf013dc4308ad96e07649c2f4f972852c.tar.xz | |
Implement :bdelete
Diffstat (limited to 'vis.c')
| -rw-r--r-- | vis.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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) { |
