From a9fb53c81cec2008acc0ff3fc808ca5bd32f317e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 18 Sep 2014 14:34:33 +0200 Subject: Clean up window splitting API --- vis.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 93b32b9..48f89c7 100644 --- a/vis.c +++ b/vis.c @@ -793,9 +793,9 @@ static void winclose(const Arg *arg) { static void winsplit(const Arg *arg) { if (arg->b) - editor_window_vsplit(vis, NULL); + editor_window_vsplit(vis->win); else - editor_window_split(vis, NULL); + editor_window_split(vis->win); } static int argi2lines(const Arg *arg) { @@ -995,7 +995,9 @@ static bool cmd_gotoline(const char *argv[]) { static bool cmd_open(const char *argv[]) { for (const char **file = &argv[1]; *file; file++) { if (!editor_window_new(vis, *file)) { - editor_info_show(vis, "Can't open `%s'"); + errno = 0; + editor_info_show(vis, "Can't open `%s' %s", *file, + errno ? strerror(errno) : ""); return false; } } @@ -1090,18 +1092,28 @@ static bool cmd_substitute(const char *argv[]) { return true; } -static bool cmd_split(const char *argv[]) { - editor_window_split(vis, argv[1]); - for (const char **file = &argv[2]; *file; file++) - editor_window_split(vis, *file); +static bool openfiles(const char **files) { + for (; *files; files++) { + errno = 0; + if (!editor_window_new(vis, *files)) { + editor_info_show(vis, "Could not open `%s' %s", *files, + errno ? strerror(errno) : ""); + return false; + } + } return true; } +static bool cmd_split(const char *argv[]) { + if (!argv[1]) + return editor_window_split(vis->win); + return openfiles(&argv[1]); +} + static bool cmd_vsplit(const char *argv[]) { - editor_window_vsplit(vis, argv[1]); - for (const char **file = &argv[2]; *file; file++) - editor_window_vsplit(vis, *file); - return true; + if (!argv[1]) + return editor_window_vsplit(vis->win); + return openfiles(&argv[1]); } static bool cmd_wq(const char *argv[]) { -- cgit v1.2.3