~martanne/dvtm

ca6a2237d28be98976bf55fbd95011c5d346ced0 — Marc AndrĂ© Tanner 7 years ago 7e80271
Add spatial navigation via MOD+{H,J,K,L}

Based on an initial patch by David Zmick.
3 files changed, 61 insertions(+), 4 deletions(-)

M config.def.h
M dvtm.1
M dvtm.c
M config.def.h => config.def.h +4 -2
@@ 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,      { "+++" }                   } },

M dvtm.1 => dvtm.1 +8 -2
@@ 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.

M dvtm.c => dvtm.c +49 -0
@@ 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;