dvtm

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

commit 10e4db210f33661a429a7ce6d0f1f721ffc244f1
parent 5870e0bdc31952267519a8e09be59fb94fa39d82
Author: Frank LENORMAND <lenormf@gmail.com>
Date:   Sat,  1 Oct 2016 22:19:33 +0300

Allow window tagging through the commands FIFO

Introduce a `tag` command that allows assigning a tag to a visible
window through the commands FIFO.

This commit also fixes the `bitoftag` function which compared pointers
instead of the actual characters of the strings containing the tags.

Diffstat:
config.def.h | 3++-
dvtm.c | 18+++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -189,7 +189,8 @@ static Button buttons[] = { static Cmd commands[] = { { "create", { create, { NULL } } }, - { "focus", { focusid, { NULL } } }, + { "focus", { focusid, { NULL } } }, + { "tag", { tagid, { NULL } } }, }; /* gets executed when dvtm is started */ diff --git a/dvtm.c b/dvtm.c @@ -196,6 +196,7 @@ static void incnmaster(const char *args[]); static void setmfact(const char *args[]); static void startup(const char *args[]); static void tag(const char *args[]); +static void tagid(const char *args[]); static void togglebar(const char *args[]); static void togglebarpos(const char *args[]); static void toggleminimize(const char *args[]); @@ -769,7 +770,7 @@ keybinding(KeyCombo keys, unsigned int keycount) { static unsigned int bitoftag(const char *tag) { unsigned int i; - for (i = 0; (i < LENGTH(tags)) && (tags[i] != tag); i++); + for (i = 0; (i < LENGTH(tags)) && (*tags[i] != *tag); i++); return (i < LENGTH(tags)) ? (1 << i) : ~0; } @@ -798,6 +799,21 @@ tag(const char *args[]) { } static void +tagid(const char *args[]) { + if (!args[0] || !args[1] || !atoi(args[1])) + return; + + const int win_id = atoi(args[0]); + for (Client *c = nextvisible(clients); c; c = nextvisible(c->next)) { + if (c->id == win_id) { + c->tags = bitoftag(args[1]) & TAGMASK; + tagschanged(); + return; + } + } +} + +static void toggletag(const char *args[]) { if (!sel) return;