dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit ca6a2237d28be98976bf55fbd95011c5d346ced0
parent 7e8027149aa462a48401da31d04c347fd4a970a6
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Thu,  5 Jan 2017 17:18:02 +0100

Add spatial navigation via MOD+{H,J,K,L}

Based on an initial patch by David Zmick.

Diffstat:
config.def.h | 6++++--
dvtm.1 | 10++++++++--
dvtm.c | 49+++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -82,8 +82,10 @@ static KeyBinding bindings[] = { { { MOD, 'C', }, { create, { NULL, NULL, "$CWD" } } }, { { MOD, 'x', 'x', }, { killclient, { NULL } } }, { { MOD, 'j', }, { focusnext, { NULL } } }, - { { MOD, 'J', }, { focusnextnm, { NULL } } }, - { { MOD, 'K', }, { focusprevnm, { NULL } } }, + { { MOD, 'J', }, { focusdown, { NULL } } }, + { { MOD, 'K', }, { focusup, { NULL } } }, + { { MOD, 'H', }, { focusleft, { NULL } } }, + { { MOD, 'L', }, { focusright, { NULL } } }, { { MOD, 'k', }, { focusprev, { NULL } } }, { { MOD, 'f', }, { setlayout, { "[]=" } } }, { { MOD, 'g', }, { setlayout, { "+++" } } }, diff --git a/dvtm.1 b/dvtm.1 @@ -116,10 +116,16 @@ Focus next window. Focus previous window. . .It Ic Mod-J -Focus next non minimized window. +Focus window below. . .It Ic Mod-K -Focus previous non minimized window. +Focus window above. +. +.It Ic Mod-H +Focus window to the left. +. +.It Ic Mod-L +Focus window to the right. . .It Ic Mod-[0..9] Focus the [0..9]-th window. diff --git a/dvtm.c b/dvtm.c @@ -187,6 +187,10 @@ static void focusnextnm(const char *args[]); static void focusprev(const char *args[]); static void focusprevnm(const char *args[]); static void focuslast(const char *args[]); +static void focusup(const char *args[]); +static void focusdown(const char *args[]); +static void focusleft(const char *args[]); +static void focusright(const char *args[]); static void killclient(const char *args[]); static void paste(const char *args[]); static void quit(const char *args[]); @@ -1236,6 +1240,51 @@ focuslast(const char *args[]) { } static void +focusup(const char *args[]) { + if (!sel) + return; + /* avoid vertical separator, hence +1 in x direction */ + Client *c = get_client_by_coord(sel->x + 1, sel->y - 1); + if (c) + focus(c); + else + focusprev(args); +} + +static void +focusdown(const char *args[]) { + if (!sel) + return; + Client *c = get_client_by_coord(sel->x, sel->y + sel->h); + if (c) + focus(c); + else + focusnext(args); +} + +static void +focusleft(const char *args[]) { + if (!sel) + return; + Client *c = get_client_by_coord(sel->x - 2, sel->y); + if (c) + focus(c); + else + focusprev(args); +} + +static void +focusright(const char *args[]) { + if (!sel) + return; + Client *c = get_client_by_coord(sel->x + sel->w + 1, sel->y); + if (c) + focus(c); + else + focusnext(args); +} + +static void killclient(const char *args[]) { if (!sel) return;