From d66ee8dcf013dc4308ad96e07649c2f4f972852c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 27 Sep 2014 15:59:08 +0200 Subject: Implement :bdelete --- vis.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 3dee122..6627ef9 100644 --- a/vis.c +++ b/vis.c @@ -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) { -- cgit v1.2.3