diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-24 20:16:52 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-24 20:16:52 +0200 |
| commit | 34e9b2ebcc73160d6d176cf166ecd6345a70433d (patch) | |
| tree | 7bdd30ace25a4682c25bd439cc83748563cd6947 | |
| parent | c4be8388aa0ccc678c765be065ef5563c3ff7c12 (diff) | |
| download | vis-34e9b2ebcc73160d6d176cf166ecd6345a70433d.tar.gz vis-34e9b2ebcc73160d6d176cf166ecd6345a70433d.tar.xz | |
Implement window related keys (CTRL-W ...) in terms of ':'-commands
| -rw-r--r-- | config.def.h | 5 | ||||
| -rw-r--r-- | vis.c | 19 |
2 files changed, 8 insertions, 16 deletions
diff --git a/config.def.h b/config.def.h index faa7e06..f07369f 100644 --- a/config.def.h +++ b/config.def.h @@ -360,8 +360,9 @@ static KeyBinding vis_marks_set[] = { static KeyBinding vis_mode_normal[] = { { { CONTROL('w'), NONE('n') }, winnew, { .s = NULL } }, - { { CONTROL('w'), NONE('q') }, winclose, { .s = NULL } }, - { { CONTROL('w'), NONE('s') }, winsplit, { .b = false } }, + { { CONTROL('w'), NONE('c') }, cmd, { .s = "q" } }, + { { CONTROL('w'), NONE('s') }, cmd, { .s = "split" } }, + { { CONTROL('w'), NONE('v') }, cmd, { .s = "vsplit" } }, { { CONTROL('w'), NONE('j') }, call, { .f = editor_window_next } }, { { CONTROL('w'), NONE('k') }, call, { .f = editor_window_prev } }, { { CONTROL('B') }, wscroll, { .i = -PAGE } }, @@ -364,10 +364,8 @@ static void openline(const Arg *arg); static void joinline(const Arg *arg); /* create a new window with the filename arg->s */ static void winnew(const Arg *arg); -/* close currently focused window except if there are unsafed changes */ -static void winclose(const Arg *arg); -/* split current window horizontally (default) or vertically (if arg->b is set) */ -static void winsplit(const Arg *arg); +/* execute arg->s as if it was typed on command prompt */ +static void cmd(const Arg *arg); /* perform last action i.e. action_prev again */ static void repeat(const Arg *arg); /* replace character at cursor with one read form keyboard */ @@ -870,16 +868,9 @@ static void winnew(const Arg *arg) { editor_window_new(vis, arg->s); } -static void winclose(const Arg *arg) { - cmd_quit((const char*[]){ "q", NULL }); -} - -static void winsplit(const Arg *arg) { - editor_window_split(vis->win); - if (arg->b) - editor_windows_arrange_vertical(vis); - else - editor_windows_arrange_horizontal(vis); +static void cmd(const Arg *arg) { + /* casting to char* is only save if arg->s contains no arguments */ + exec_command((char*)arg->s); } static int argi2lines(const Arg *arg) { |
