Skip to content

Commit

Permalink
Implement tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Oct 29, 2014
1 parent f83552a commit 1e8fc97
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 89 deletions.
9 changes: 7 additions & 2 deletions bstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ static void bstack(void)
unsigned int i, n, nx, ny, nw, nh, mh, tw;
Client *c;

for (n = 0, c = clients; c && !c->minimized; c = c->next, n++);
for (n = 0, c = nextvisible(clients); c; c = nextvisible(c->next))
if (!c->minimized)
n++;

mh = n <= 1 ? wah : screen.mfact * wah;
tw = n <= 1 ? 0 : waw / (n - 1);
nx = wax;
ny = way;

for (i = 0, c = clients; c && !c->minimized; c = c->next, i++) {
for (i = 0, c = nextvisible(clients); c; c = nextvisible(c->next)) {
if (c->minimized)
continue;
if (i == 0) { /* master */
nh = mh;
nw = waw;
Expand All @@ -32,5 +36,6 @@ static void bstack(void)

if (i > 0)
nx += nw;
i++;
}
}
55 changes: 49 additions & 6 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ static Color colors[] = {
/* curses attributes for the status bar */
#define BAR_ATTR (COLOR(BLUE) | A_NORMAL)
/* status bar (command line option -s) position */
#define BAR_POS BAR_TOP /* BAR_BOTTOM, BAR_OFF */
#define BAR_POS BAR_TOP /* BAR_BOTTOM, BAR_OFF */
/* whether status bar should be hidden if only one client exists */
#define BAR_AUTOHIDE true
/* determines whether the statusbar text should be right or left aligned */
#define BAR_ALIGN ALIGN_RIGHT
/* separator between window title and window number */
Expand All @@ -42,6 +44,16 @@ static Color colors[] = {
#define MFACT 0.5
/* scroll back buffer size in lines */
#define SCROLL_HISTORY 500
/* printf format string for the tag in the status bar */
#define TAG_SYMBOL "[%s]"
/* curses attributes for the currently selected tags */
#define TAG_SEL (COLOR(BLUE) | A_BOLD)
/* curses attributes for not selected tags which contain no windows */
#define TAG_NORMAL (COLOR(DEFAULT) | A_NORMAL)
/* curses attributes for not selected tags which contain windows */
#define TAG_OCCUPIED (COLOR(BLUE) | A_NORMAL)

const char tags[][8] = { "1", "2", "3", "4", "5" };

#include "tile.c"
#include "grid.c"
Expand All @@ -56,7 +68,7 @@ static Layout layouts[] = {
{ "[ ]", fullscreen },
};

#define MOD CTRL('g')
#define MOD CTRL('g')

/* you can at most specifiy MAX_ARGS (3) number of arguments */
static KeyBinding bindings[] = {
Expand All @@ -67,7 +79,7 @@ static KeyBinding bindings[] = {
{ { MOD, 'u', }, { focusnextnm, { NULL } } },
{ { MOD, 'i', }, { focusprevnm, { NULL } } },
{ { MOD, 'k', }, { focusprev, { NULL } } },
{ { MOD, 't', }, { setlayout, { "[]=" } } },
{ { MOD, 'd', }, { setlayout, { "[]=" } } },
{ { MOD, 'g', }, { setlayout, { "+++" } } },
{ { MOD, 'b', }, { setlayout, { "TTT" } } },
{ { MOD, 'm', }, { setlayout, { "[ ]" } } },
Expand All @@ -90,18 +102,49 @@ static KeyBinding bindings[] = {
{ { MOD, '\t', }, { focuslast, { NULL } } },
{ { MOD, 'q', }, { quit, { NULL } } },
{ { MOD, 'a', }, { togglerunall, { NULL } } },
{ { MOD, CTRL('L'), }, { redraw, { NULL } } },
{ { MOD, 'r', }, { redraw, { NULL } } },
{ { MOD, 'B', }, { togglebell, { NULL } } },
{ { MOD, 'v', }, { copymode, { NULL } } },
{ { MOD, 'e', }, { copymode, { NULL } } },
{ { MOD, '/', }, { copymode, { "/" } } },
{ { MOD, '?', }, { copymode, { "?" } } },
{ { MOD, 'p', }, { paste, { NULL } } },
{ { MOD, KEY_PPAGE, }, { scrollback, { "-1" } } },
{ { MOD, KEY_NPAGE, }, { scrollback, { "1" } } },
{ { MOD, KEY_F(1), }, { create, { "man dvtm", "dvtm help" } } },
{ { MOD, '?', }, { create, { "man dvtm", "dvtm help" } } },
{ { MOD, MOD, }, { send, { (const char []){MOD, 0} } } },
{ { KEY_SPREVIOUS, }, { scrollback, { "-1" } } },
{ { KEY_SNEXT, }, { scrollback, { "1" } } },
{ { MOD, MOD, }, { send, { (const char []){MOD, 0} } } },
{ { KEY_SPREVIOUS, }, { scrollback, { "-1" } } },
{ { KEY_SNEXT, }, { scrollback, { "1" } } },
{ { MOD, '0', }, { view, { NULL } } },
{ { MOD, KEY_F(1), }, { view, { tags[0] } } },
{ { MOD, KEY_F(2), }, { view, { tags[1] } } },
{ { MOD, KEY_F(3), }, { view, { tags[2] } } },
{ { MOD, KEY_F(4), }, { view, { tags[3] } } },
{ { MOD, KEY_F(5), }, { view, { tags[4] } } },
{ { MOD, 'v', '1' }, { view, { tags[0] } } },
{ { MOD, 'v', '2' }, { view, { tags[1] } } },
{ { MOD, 'v', '3' }, { view, { tags[2] } } },
{ { MOD, 'v', '4' }, { view, { tags[3] } } },
{ { MOD, 'v', '5' }, { view, { tags[4] } } },
{ { MOD, 'v', '\t', }, { viewprevtag, { NULL } } },
{ { MOD, 't', '0' }, { tag, { NULL } } },
{ { MOD, 't', '1' }, { tag, { tags[0] } } },
{ { MOD, 't', '2' }, { tag, { tags[1] } } },
{ { MOD, 't', '3' }, { tag, { tags[2] } } },
{ { MOD, 't', '4' }, { tag, { tags[3] } } },
{ { MOD, 't', '5' }, { tag, { tags[4] } } },
{ { MOD, 'V', '1' }, { toggleview, { tags[0] } } },
{ { MOD, 'V', '2' }, { toggleview, { tags[1] } } },
{ { MOD, 'V', '3' }, { toggleview, { tags[2] } } },
{ { MOD, 'V', '4' }, { toggleview, { tags[3] } } },
{ { MOD, 'V', '5' }, { toggleview, { tags[4] } } },
{ { MOD, 'T', '1' }, { toggletag, { tags[0] } } },
{ { MOD, 'T', '2' }, { toggletag, { tags[1] } } },
{ { MOD, 'T', '3' }, { toggletag, { tags[2] } } },
{ { MOD, 'T', '4' }, { toggletag, { tags[3] } } },
{ { MOD, 'T', '5' }, { toggletag, { tags[4] } } },
};

static const ColorRule colorrules[] = {
Expand Down
31 changes: 25 additions & 6 deletions dvtm.1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Toggle between defined layouts (affects all windows).
.B Mod\-Enter
Zooms/cycles current window to/from master area.
.TP
.B Mod\-t
.B Mod\-d
Change to vertical stack tiling layout.
.TP
.B Mod\-b
Expand All @@ -145,6 +145,8 @@ Change to grid layout.
Show/hide the status bar.
.TP
.B Mod\-r
.TQ
.B Mod\-^L
Redraw whole screen.
.TP
.B Mod\-a
Expand All @@ -157,24 +159,41 @@ Toggle bell (off by default).
.B Mod\-M
Toggle dvtm mouse grabbing.
.TP
.B Mod\-v
.B Mod\-e
Enter copy mode (see section below for further information).
.TP
.B Mod\-/
Enter copy mode and start searching forward (assumes a vi-like editor).
.TP
.B Mod\-?
Enter copy mode and start searching backwards (assumes a vi-like editor).
.TP
.B Mod\-p
Paste last copied text from copy mode at current cursor position.
.TP
.B Mod\-F1
.B Mod\-?
Show this manual page.
.TP
.B Mod\-Mod
Send the Mod key.
.TP
.B Mod-F[1..n]
.TQ
.B Mod-v-[1..n]
View all windows with nth tag.
.TP
.B Mod-0
View all windows with any tag.
.TP
.B Mod-v-Tab
Toggles to the previously selected tags.
.TP
.B Mod-V-[1..n]
Add/remove all windows with nth tag to/from the view.
.TP
.B Mod-t-[1..n]
Apply nth tag to focused window.
.TP
.B Mod-T-[1..n]
Add/remove nth tag to/from focused window.
.TP
.B Mod\-q
Quit dvtm.
.SS Mouse commands
Expand Down
Loading

0 comments on commit 1e8fc97

Please sign in to comment.