aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-18 14:34:33 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-18 17:37:37 +0200
commita9fb53c81cec2008acc0ff3fc808ca5bd32f317e (patch)
tree7f3692a8105bda4844ac232ebf248ec3268bd315 /vis.c
parent3eaa312c0babe1264d5f4408f82310cd1458dd02 (diff)
downloadvis-a9fb53c81cec2008acc0ff3fc808ca5bd32f317e.tar.gz
vis-a9fb53c81cec2008acc0ff3fc808ca5bd32f317e.tar.xz
Clean up window splitting API
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c34
1 files changed, 23 insertions, 11 deletions
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[]) {