dvtm

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

commit 3b23ffa9ce4c49e1a468e53465d00ae452341e96
parent de7f95e1a10e18a5d4f4078821a9c499c1c1b4c5
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri,  6 Feb 2015 18:48:06 +0100

Add MOD+S to toggle position of status bar

Diffstat:
config.def.h | 1+
dvtm.1 | 3+++
dvtm.c | 41+++++++++++++++++++++++++++++++++++------
3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -92,6 +92,7 @@ static KeyBinding bindings[] = { { { MOD, 'l', }, { setmfact, { "+0.05" } } }, { { MOD, '.', }, { toggleminimize, { NULL } } }, { { MOD, 's', }, { togglebar, { NULL } } }, + { { MOD, 'S', }, { togglebarpos, { NULL } } }, { { MOD, 'M', }, { togglemouse, { NULL } } }, { { MOD, '\n', }, { zoom , { NULL } } }, { { MOD, '1', }, { focusn, { "1" } } }, diff --git a/dvtm.1 b/dvtm.1 @@ -144,6 +144,9 @@ Change to grid layout. .B Mod\-s Show/hide the status bar. .TP +.B Mod\-S +Toggle position of the status bar between top and bottom. +.TP .B Mod\-r .TQ .B Mod\-^L diff --git a/dvtm.c b/dvtm.c @@ -137,7 +137,7 @@ enum { ALIGN_LEFT, ALIGN_RIGHT }; typedef struct { int fd; - int pos; + int pos, lastpos; bool autohide; unsigned short int h; unsigned short int y; @@ -194,6 +194,7 @@ static void setmfact(const char *args[]); static void startup(const char *args[]); static void tag(const char *args[]); static void togglebar(const char *args[]); +static void togglebarpos(const char *args[]); static void toggleminimize(const char *args[]); static void togglemouse(const char *args[]); static void togglerunall(const char *args[]); @@ -231,7 +232,7 @@ static unsigned int seltags; static unsigned int tagset[2] = { 1, 1 }; static bool mouse_events_enabled = ENABLE_MOUSE; static Layout *layout = layouts; -static StatusBar bar = { .fd = -1, .pos = BAR_POS, .autohide = BAR_AUTOHIDE, .h = 1 }; +static StatusBar bar = { .fd = -1, .lastpos = BAR_POS, .pos = BAR_POS, .autohide = BAR_AUTOHIDE, .h = 1 }; static CmdFifo cmdfifo = { .fd = -1 }; static const char *shell; static Register copyreg; @@ -297,6 +298,20 @@ updatebarpos(void) { } static void +hidebar(void) { + if (bar.pos != BAR_OFF) { + bar.lastpos = bar.pos; + bar.pos = BAR_OFF; + } +} + +static void +showbar(void) { + if (bar.pos == BAR_OFF) + bar.pos = bar.lastpos; +} + +static void drawbar(void) { int sx, sy, x, y, width; unsigned int occupied = 0, urgent = 0; @@ -455,9 +470,9 @@ arrange(void) { attrset(NORMAL_ATTR); if (bar.fd == -1 && bar.autohide) { if ((!clients || !clients->next) && n == 1) - bar.pos = BAR_OFF; + hidebar(); else - bar.pos = BAR_POS; + showbar(); updatebarpos(); } if (m && !isarrange(fullscreen)) @@ -1264,15 +1279,29 @@ startup(const char *args[]) { static void togglebar(const char *args[]) { if (bar.pos == BAR_OFF) - bar.pos = (BAR_POS == BAR_OFF) ? BAR_TOP : BAR_POS; + showbar(); else - bar.pos = BAR_OFF; + hidebar(); bar.autohide = false; updatebarpos(); redraw(NULL); } static void +togglebarpos(const char *args[]) { + switch (bar.pos == BAR_OFF ? bar.lastpos : bar.pos) { + case BAR_TOP: + bar.pos = BAR_BOTTOM; + break; + case BAR_BOTTOM: + bar.pos = BAR_TOP; + break; + } + updatebarpos(); + redraw(NULL); +} + +static void toggleminimize(const char *args[]) { Client *c, *m, *t; unsigned int n;