From aa4823e78092ac3c18201089b4c2eedb9cd6bfe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 27 Sep 2014 16:03:09 +0200 Subject: Factor out common user info message --- vis.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vis.c b/vis.c index 6627ef9..a700166 100644 --- a/vis.c +++ b/vis.c @@ -1194,12 +1194,15 @@ static bool is_window_closeable(EditorWin *win) { return false; } +static void info_unsaved_changes(void) { + editor_info_show(vis, "No write since last change (add ! to override)"); +} + static bool cmd_edit(const char *argv[]) { EditorWin *oldwin = vis->win; bool force = strchr(argv[0], '!') != NULL; if (!force && !is_window_closeable(oldwin)) { - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return false; } if (!argv[1]) @@ -1213,8 +1216,7 @@ static bool cmd_edit(const char *argv[]) { static bool cmd_quit(const char *argv[]) { bool force = strchr(argv[0], '!') != NULL; if (!force && !is_window_closeable(vis->win)) { - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return false; } editor_window_close(vis->win); @@ -1227,8 +1229,7 @@ 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)"); + info_unsaved_changes(); return false; } for (EditorWin *next, *win = vis->windows; win; win = next) { @@ -1236,7 +1237,6 @@ static bool cmd_bdelete(const char *argv[]) { if (win->text == txt) editor_window_close(win); } - if (!vis->windows) quit(NULL); return true; @@ -1252,8 +1252,7 @@ static bool cmd_qall(const char *argv[]) { if (!vis->windows) quit(NULL); else - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return vis->windows == NULL; } -- cgit v1.2.3