dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

dvtm.h (10444B)


      1 /* valid curses attributes are listed below they can be ORed
      2  *
      3  * A_NORMAL        Normal display (no highlight)
      4  * A_STANDOUT      Best highlighting mode of the terminal.
      5  * A_UNDERLINE     Underlining
      6  * A_REVERSE       Reverse video
      7  * A_BLINK         Blinking
      8  * A_DIM           Half bright
      9  * A_BOLD          Extra bright or bold
     10  * A_PROTECT       Protected mode
     11  * A_INVIS         Invisible or blank mode
     12  */
     13 
     14 enum {
     15 	DEFAULT,
     16 	BLUE,
     17 };
     18 
     19 static Color colors[] = {
     20 	[DEFAULT] = { .fg = -1,         .bg = -1, .fg256 = -1, .bg256 = -1, },
     21 	[BLUE]    = { .fg = COLOR_BLUE, .bg = -1, .fg256 = 24, .bg256 = -1, },
     22 };
     23 
     24 #define COLOR(c)        COLOR_PAIR(colors[c].pair)
     25 /* curses attributes for the currently focused window */
     26 #define SELECTED_ATTR   (COLOR(BLUE) | A_NORMAL)
     27 /* curses attributes for normal (not selected) windows */
     28 #define NORMAL_ATTR     (COLOR(DEFAULT) | A_NORMAL)
     29 /* curses attributes for a window with pending urgent flag */
     30 #define URGENT_ATTR     NORMAL_ATTR
     31 /* curses attributes for the status bar */
     32 #define BAR_ATTR        (COLOR(BLUE) | A_NORMAL)
     33 /* characters for beginning and end of status bar message */
     34 #define BAR_BEGIN       '['
     35 #define BAR_END         ']'
     36 /* status bar (command line option -s) position */
     37 #define BAR_POS         BAR_TOP /* BAR_BOTTOM, BAR_OFF */
     38 /* whether status bar should be hidden if only one client exists */
     39 #define BAR_AUTOHIDE    true
     40 /* master width factor [0.1 .. 0.9] */
     41 #define MFACT 0.5
     42 /* number of clients in master area */
     43 #define NMASTER 1
     44 /* scroll back buffer size in lines */
     45 #define SCROLL_HISTORY 500
     46 /* printf format string for the tag in the status bar */
     47 #define TAG_SYMBOL   "[%s]"
     48 /* curses attributes for the currently selected tags */
     49 #define TAG_SEL      (COLOR(BLUE) | A_BOLD)
     50 /* curses attributes for not selected tags which contain no windows */
     51 #define TAG_NORMAL   (COLOR(DEFAULT) | A_NORMAL)
     52 /* curses attributes for not selected tags which contain windows */
     53 #define TAG_OCCUPIED (COLOR(BLUE) | A_NORMAL)
     54 /* curses attributes for not selected tags which with urgent windows */
     55 #define TAG_URGENT (COLOR(BLUE) | A_NORMAL | A_BLINK)
     56 
     57 const char tags[][8] = { "1", "2", "3", "4", "5", "6", "8", "9" };
     58 
     59 #include "tile.c"
     60 #include "grid.c"
     61 #include "bstack.c"
     62 #include "fullscreen.c"
     63 
     64 /* by default the first layout entry is used */
     65 static Layout layouts[] = {
     66 	{ "[]=", tile },
     67 	{ "+++", grid },
     68 	{ "TTT", bstack },
     69 	{ "[ ]", fullscreen },
     70 };
     71 
     72 #define MOD  CTRL(' ')
     73 #define TAGKEYS(KEY,SKEY,TAG) \
     74 	{ { MOD,      KEY,     }, { view,           { tags[TAG] }               } }, \
     75 	{ { MOD, 't', KEY,     }, { tag,            { tags[TAG] }               } }, \
     76 	{ { MOD,      SKEY,    }, { toggleview,     { tags[TAG] }               } }, \
     77 	{ { MOD, 'T', KEY,     }, { toggletag,      { tags[TAG] }               } },
     78 
     79 /* you can specifiy at most 3 arguments */
     80 static KeyBinding bindings[] = {
     81 	{ { MOD, 'c',          }, { create,         { NULL }                    } },
     82 	{ { MOD, 'C',          }, { create,         { NULL, NULL, "$CWD" }      } },
     83 	{ { MOD, 'x', 'x',     }, { killclient,     { NULL }                    } },
     84 	{ { MOD, 'j',          }, { focusnext,      { NULL }                    } },
     85 	{ { MOD, 'J',          }, { focusdown,      { NULL }                    } },
     86 	{ { MOD, 'K',          }, { focusup,        { NULL }                    } },
     87 	{ { MOD, 'H',          }, { focusleft,      { NULL }                    } },
     88 	{ { MOD, 'L',          }, { focusright,     { NULL }                    } },
     89 	{ { MOD, 'k',          }, { focusprev,      { NULL }                    } },
     90 	{ { MOD, 'f',          }, { setlayout,      { "[]=" }                   } },
     91 	{ { MOD, 'g',          }, { setlayout,      { "+++" }                   } },
     92 	{ { MOD, 'b',          }, { setlayout,      { "TTT" }                   } },
     93 	{ { MOD, 'm',          }, { setlayout,      { "[ ]" }                   } },
     94 	{ { MOD, ' ',          }, { setlayout,      { NULL }                    } },
     95 	{ { MOD, 'i',          }, { incnmaster,     { "+1" }                    } },
     96 	{ { MOD, 'd',          }, { incnmaster,     { "-1" }                    } },
     97 	{ { MOD, 'h',          }, { setmfact,       { "-0.05" }                 } },
     98 	{ { MOD, 'l',          }, { setmfact,       { "+0.05" }                 } },
     99 	{ { MOD, '.',          }, { toggleminimize, { NULL }                    } },
    100 	{ { MOD, 's',          }, { togglebar,      { NULL }                    } },
    101 	{ { MOD, 'S',          }, { togglebarpos,   { NULL }                    } },
    102 	{ { MOD, 'M',          }, { togglemouse,    { NULL }                    } },
    103 	{ { MOD, '\n',         }, { zoom ,          { NULL }                    } },
    104 	{ { MOD, '\r',         }, { zoom ,          { NULL }                    } },
    105 	/* { { MOD, '1',          }, { focusn,         { "1" }                     } }, */
    106 	/* { { MOD, '2',          }, { focusn,         { "2" }                     } }, */
    107 	/* { { MOD, '3',          }, { focusn,         { "3" }                     } }, */
    108 	/* { { MOD, '4',          }, { focusn,         { "4" }                     } }, */
    109 	/* { { MOD, '5',          }, { focusn,         { "5" }                     } }, */
    110 	/* { { MOD, '6',          }, { focusn,         { "6" }                     } }, */
    111 	/* { { MOD, '7',          }, { focusn,         { "7" }                     } }, */
    112 	/* { { MOD, '8',          }, { focusn,         { "8" }                     } }, */
    113 	/* { { MOD, '9',          }, { focusn,         { "9" }                     } }, */
    114 	{ { MOD, '\t',         }, { focuslast,      { NULL }                    } },
    115 	{ { MOD, 'q', 'q',     }, { quit,           { NULL }                    } },
    116 	{ { MOD, 'a',          }, { togglerunall,   { NULL }                    } },
    117 	{ { MOD, CTRL('L'),    }, { redraw,         { NULL }                    } },
    118 	{ { MOD, 'r',          }, { redraw,         { NULL }                    } },
    119 	{ { MOD, 'e',          }, { copymode,       { "dvtm-editor" }           } },
    120 	{ { MOD, 'E',          }, { copymode,       { "dvtm-pager" }            } },
    121 	{ { MOD, '/',          }, { copymode,       { "dvtm-pager", "/" }       } },
    122 	{ { MOD, 'p',          }, { paste,          { NULL }                    } },
    123 	{ { MOD, KEY_PPAGE,    }, { scrollback,     { "-1" }                    } },
    124 	{ { MOD, KEY_NPAGE,    }, { scrollback,     { "1"  }                    } },
    125 	{ { MOD, '?',          }, { create,         { "man dvtm", "dvtm help" } } },
    126 	{ { MOD, MOD,          }, { send,           { (const char []){MOD, 0} } } },
    127 	{ { KEY_SPREVIOUS,     }, { scrollback,     { "-1" }                    } },
    128 	{ { KEY_SNEXT,         }, { scrollback,     { "1"  }                    } },
    129 	{ { MOD, '0',          }, { view,           { NULL }                    } },
    130 	{ { MOD, KEY_F(1),     }, { view,           { tags[0] }                 } },
    131 	{ { MOD, KEY_F(2),     }, { view,           { tags[1] }                 } },
    132 	{ { MOD, KEY_F(3),     }, { view,           { tags[2] }                 } },
    133 	{ { MOD, KEY_F(4),     }, { view,           { tags[3] }                 } },
    134 	{ { MOD, KEY_F(5),     }, { view,           { tags[4] }                 } },
    135 	{ { MOD, 'v', '0'      }, { view,           { NULL }                    } },
    136 	{ { MOD, 'v', '\t',    }, { viewprevtag,    { NULL }                    } },
    137 	{ { MOD, 't', '0'      }, { tag,            { NULL }                    } },
    138 	TAGKEYS( '1', '!',                         0)
    139 	TAGKEYS( '2', '@',                         1)
    140 	TAGKEYS( '3', '#',                         2)
    141 	TAGKEYS( '4', '$',                         3)
    142 	TAGKEYS( '5', '%',                         4)
    143 	TAGKEYS( '6', '^',                         0)
    144 	TAGKEYS( '7', '&',                         1)
    145 	TAGKEYS( '8', '*',                         2)
    146 	TAGKEYS( '9', '(',                         3)
    147 };
    148 
    149 static const ColorRule colorrules[] = {
    150 	{ "", A_NORMAL, &colors[DEFAULT] }, /* default */
    151 };
    152 
    153 /* possible values for the mouse buttons are listed below:
    154  *
    155  * BUTTON1_PRESSED          mouse button 1 down
    156  * BUTTON1_RELEASED         mouse button 1 up
    157  * BUTTON1_CLICKED          mouse button 1 clicked
    158  * BUTTON1_DOUBLE_CLICKED   mouse button 1 double clicked
    159  * BUTTON1_TRIPLE_CLICKED   mouse button 1 triple clicked
    160  * BUTTON2_PRESSED          mouse button 2 down
    161  * BUTTON2_RELEASED         mouse button 2 up
    162  * BUTTON2_CLICKED          mouse button 2 clicked
    163  * BUTTON2_DOUBLE_CLICKED   mouse button 2 double clicked
    164  * BUTTON2_TRIPLE_CLICKED   mouse button 2 triple clicked
    165  * BUTTON3_PRESSED          mouse button 3 down
    166  * BUTTON3_RELEASED         mouse button 3 up
    167  * BUTTON3_CLICKED          mouse button 3 clicked
    168  * BUTTON3_DOUBLE_CLICKED   mouse button 3 double clicked
    169  * BUTTON3_TRIPLE_CLICKED   mouse button 3 triple clicked
    170  * BUTTON4_PRESSED          mouse button 4 down
    171  * BUTTON4_RELEASED         mouse button 4 up
    172  * BUTTON4_CLICKED          mouse button 4 clicked
    173  * BUTTON4_DOUBLE_CLICKED   mouse button 4 double clicked
    174  * BUTTON4_TRIPLE_CLICKED   mouse button 4 triple clicked
    175  * BUTTON_SHIFT             shift was down during button state change
    176  * BUTTON_CTRL              control was down during button state change
    177  * BUTTON_ALT               alt was down during button state change
    178  * ALL_MOUSE_EVENTS         report all button state changes
    179  * REPORT_MOUSE_POSITION    report mouse movement
    180  */
    181 
    182 #ifdef NCURSES_MOUSE_VERSION
    183 # define CONFIG_MOUSE /* compile in mouse support if we build against ncurses */
    184 #endif
    185 
    186 #define ENABLE_MOUSE true /* whether to enable mouse events by default */
    187 
    188 #ifdef CONFIG_MOUSE
    189 static Button buttons[] = {
    190 	{ BUTTON1_CLICKED,        { mouse_focus,      { NULL  } } },
    191 	{ BUTTON1_DOUBLE_CLICKED, { mouse_fullscreen, { "[ ]" } } },
    192 	{ BUTTON2_CLICKED,        { mouse_zoom,       { NULL  } } },
    193 	{ BUTTON3_CLICKED,        { mouse_minimize,   { NULL  } } },
    194 };
    195 #endif /* CONFIG_MOUSE */
    196 
    197 static Cmd commands[] = {
    198 	/* create [cmd]: create a new window, run `cmd` in the shell if specified */
    199 	{ "create", { create,	{ NULL } } },
    200 	/* focus <win_id>: focus the window whose `DVTM_WINDOW_ID` is `win_id` */
    201 	{ "focus",  { focusid,	{ NULL } } },
    202 	/* tag <win_id> <tag> [tag ...]: add +tag, remove -tag or set tag of the window with the given identifier */
    203 	{ "tag",    { tagid,	{ NULL } } },
    204 };
    205 
    206 /* gets executed when dvtm is started */
    207 static Action actions[] = {
    208 	{ create, { NULL } },
    209 };
    210 
    211 static char const * const keytable[] = {
    212 	/* add your custom key escape sequences */
    213 };