dvtm

Fork of dvtm, a minimal terminal multiplexer
git clone git://git.laack.co/dvtm.git
Log | Files | Refs | README | LICENSE

config.h (11305B)


      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 = 68, .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    false
     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[][10] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
     58 
     59 #include "tile.c"
     60 #include "grid.c"
     61 //#include "horizontal.c"
     62 #include "bstack.c"
     63 #include "fullscreen.c"
     64 
     65 /* by default the first layout entry is used */
     66 static Layout layouts[] = {
     67 	{ "[]=", tile },
     68 	//{ "|||", horizontal },
     69 	{ "+++", grid },
     70 	{ "TTT", bstack },
     71 	{ "[ ]", fullscreen },
     72 };
     73 
     74 #define MOD  CTRL('s')
     75 #define TAGKEYS(KEY,TAG) \
     76 	{ { MOD, 'v', KEY,     }, { view,           { tags[TAG] }               } }, \
     77 	{ { MOD, 't', KEY,     }, { tag,            { tags[TAG] }               } }, \
     78 	{ { MOD, 'V', KEY,     }, { toggleview,     { tags[TAG] }               } }, \
     79 	{ { MOD, 'T', KEY,     }, { toggletag,      { tags[TAG] }               } },
     80 
     81 /* you can specifiy at most 3 arguments */
     82 static KeyBinding bindings[] = {
     83 	{ { MOD, '\r',          }, { create,         { NULL }                    } },
     84 	//{ { MOD, '\n',          }, { create,         { NULL, NULL, "$CWD" }      } },
     85 	{ { MOD, 'x', 	       }, { killclient,     { NULL }                    } },
     86 	{ { MOD, KEY_DOWN,          }, { focusnext,      { NULL }                    } },
     87 	//{ { MOD, 'n',          }, { focusnext,      { NULL }                    } },
     88 	//{ { MOD, 'J',          }, { focusdown,      { NULL }                    } },
     89 	//{ { MOD, 'K',          }, { focusup,        { NULL }                    } },
     90 	//{ { MOD, 'H',          }, { focusleft,      { NULL }                    } },
     91 	//{ { MOD, 'L',          }, { focusright,     { NULL }                    } },
     92 	{ { MOD, KEY_UP,          }, { focusprev,      { NULL }                    } },
     93 	//{ { MOD, 'p',          }, { focusprev,      { NULL }                    } },
     94 	{ { MOD, 'v',          }, { setlayout,      { "[]=" }                   } },
     95 	//{ { MOD, 'h',          }, { setlayout,      { "|||" }                   } },
     96 	{ { MOD, 'g',          }, { setlayout,      { "+++" }                   } },
     97 	{ { MOD, 'b',          }, { setlayout,      { "TTT" }                   } },
     98 	{ { MOD, 'm',          }, { setlayout,      { "[ ]" }                   } },
     99 	{ { MOD, ' ',          }, { setlayout,      { NULL }                    } },
    100 	{ { MOD, 'i',          }, { incnmaster,     { "+1" }                    } },
    101 	{ { MOD, 'd',          }, { incnmaster,     { "-1" }                    } },
    102 	{ { MOD, KEY_LEFT,          }, { setmfact,       { "-0.05" }                 } },
    103 	{ { MOD, KEY_RIGHT,          }, { setmfact,       { "+0.05" }                 } },
    104 	{ { MOD, '.',          }, { toggleminimize, { NULL }                    } },
    105 	{ { MOD, 's',          }, { togglebar,      { NULL }                    } },
    106 	{ { MOD, 'S',          }, { togglebarpos,   { NULL }                    } },
    107 	{ { MOD, 'M',          }, { togglemouse,    { NULL }                    } },
    108 	//{ { MOD, Shift, '\r',         }, { zoom ,          { NULL }                    } },
    109 	{ { MOD, 'T',         }, { zoom ,          { NULL }                    } },
    110 	{ { MOD, '\r',          }, { zoom,         { NULL }                    } },
    111 	{ { MOD, '1',          }, { view,         { "1" }                     } },
    112 	{ { MOD, '2',          }, { view,         { "2" }                     } },
    113 	{ { MOD, '3',          }, { view,         { "3" }                     } },
    114 	{ { MOD, '4',          }, { view,         { "4" }                     } },
    115 	{ { MOD, '5',          }, { view,         { "5" }                     } },
    116 	{ { MOD, '6',          }, { view,         { "6" }                     } },
    117 	{ { MOD, '7',          }, { view,         { "7" }                     } },
    118 	{ { MOD, '8',          }, { view,         { "8" }                     } },
    119 	{ { MOD, '9',          }, { view,         { "9" }                     } },
    120 	{ { MOD, '0',          }, { view,         { "10" }                     } },
    121 	{ { MOD, '\t',         }, { focuslast,      { NULL }                    } },
    122 	{ { MOD, 'Q',     }, { quit,           { NULL }                    } },
    123 	{ { MOD, 'a',          }, { togglerunall,   { NULL }                    } },
    124 	{ { MOD, CTRL('L'),    }, { redraw,         { NULL }                    } },
    125 	{ { MOD, 'r',          }, { redraw,         { NULL }                    } },
    126 	{ { MOD, 'e',          }, { copymode,       { "dvtm-editor" }           } },
    127 	{ { MOD, 'E',          }, { copymode,       { "dvtm-pager" }            } },
    128 	{ { MOD, '/',          }, { copymode,       { "dvtm-pager", "/" }       } },
    129 	//{ { MOD, 'p',          }, { paste,          { NULL }                    } },
    130 	{ { MOD, KEY_PPAGE,    }, { scrollback,     { "-1" }                    } },
    131 	{ { MOD, KEY_NPAGE,    }, { scrollback,     { "1"  }                    } },
    132 	{ { MOD, '?',          }, { create,         { "man dvtm", "dvtm help" } } },
    133 	{ { MOD, MOD,          }, { send,           { (const char []){MOD, 0} } } },
    134 	{ { KEY_SPREVIOUS,     }, { scrollback,     { "-1" }                    } },
    135 	{ { KEY_SNEXT,         }, { scrollback,     { "1"  }                    } },
    136 	//{ { MOD, '0',          }, { view,           { NULL }                    } },
    137 	{ { MOD, KEY_F(1),     }, { view,           { tags[0] }                 } },
    138 	{ { MOD, KEY_F(2),     }, { view,           { tags[1] }                 } },
    139 	{ { MOD, KEY_F(3),     }, { view,           { tags[2] }                 } },
    140 	{ { MOD, KEY_F(4),     }, { view,           { tags[3] }                 } },
    141 	{ { MOD, KEY_F(5),     }, { view,           { tags[4] }                 } },
    142 	{ { MOD, KEY_F(6),     }, { view,           { tags[5] }                 } },
    143 	{ { MOD, KEY_F(7),     }, { view,           { tags[6] }                 } },
    144 	{ { MOD, KEY_F(8),     }, { view,           { tags[7] }                 } },
    145 	{ { MOD, KEY_F(9),     }, { view,           { tags[8] }                 } },
    146 	{ { MOD, KEY_F(10),     }, { view,          { tags[9] }                 } },
    147 	//{ { MOD, 'v', '0'      }, { view,           { NULL }                    } },
    148 	//{ { MOD, 'v', '\t',    }, { viewprevtag,    { NULL }                    } },
    149 	//{ { MOD, 't', '0'      }, { tag,            { NULL }                    } },
    150 	TAGKEYS( '1',                              0)
    151 	TAGKEYS( '2',                              1)
    152 	TAGKEYS( '3',                              2)
    153 	TAGKEYS( '4',                              3)
    154 	TAGKEYS( '5',                              4)
    155 	TAGKEYS( '6',                              5)
    156 	TAGKEYS( '7',                              6)
    157 	TAGKEYS( '8',                              7)
    158 	TAGKEYS( '9',                              8)
    159 	TAGKEYS( '10',                             9)
    160 };
    161 
    162 static const ColorRule colorrules[] = {
    163 	{ "", A_NORMAL, &colors[DEFAULT] }, /* default */
    164 };
    165 
    166 /* possible values for the mouse buttons are listed below:
    167  *
    168  * BUTTON1_PRESSED          mouse button 1 down
    169  * BUTTON1_RELEASED         mouse button 1 up
    170  * BUTTON1_CLICKED          mouse button 1 clicked
    171  * BUTTON1_DOUBLE_CLICKED   mouse button 1 double clicked
    172  * BUTTON1_TRIPLE_CLICKED   mouse button 1 triple clicked
    173  * BUTTON2_PRESSED          mouse button 2 down
    174  * BUTTON2_RELEASED         mouse button 2 up
    175  * BUTTON2_CLICKED          mouse button 2 clicked
    176  * BUTTON2_DOUBLE_CLICKED   mouse button 2 double clicked
    177  * BUTTON2_TRIPLE_CLICKED   mouse button 2 triple clicked
    178  * BUTTON3_PRESSED          mouse button 3 down
    179  * BUTTON3_RELEASED         mouse button 3 up
    180  * BUTTON3_CLICKED          mouse button 3 clicked
    181  * BUTTON3_DOUBLE_CLICKED   mouse button 3 double clicked
    182  * BUTTON3_TRIPLE_CLICKED   mouse button 3 triple clicked
    183  * BUTTON4_PRESSED          mouse button 4 down
    184  * BUTTON4_RELEASED         mouse button 4 up
    185  * BUTTON4_CLICKED          mouse button 4 clicked
    186  * BUTTON4_DOUBLE_CLICKED   mouse button 4 double clicked
    187  * BUTTON4_TRIPLE_CLICKED   mouse button 4 triple clicked
    188  * BUTTON_SHIFT             shift was down during button state change
    189  * BUTTON_CTRL              control was down during button state change
    190  * BUTTON_ALT               alt was down during button state change
    191  * ALL_MOUSE_EVENTS         report all button state changes
    192  * REPORT_MOUSE_POSITION    report mouse movement
    193  */
    194 
    195 #ifdef NCURSES_MOUSE_VERSION
    196 # define CONFIG_MOUSE /* compile in mouse support if we build against ncurses */
    197 #endif
    198 
    199 #define ENABLE_MOUSE true /* whether to enable mouse events by default */
    200 
    201 #ifdef CONFIG_MOUSE
    202 static Button buttons[] = {
    203 	{ BUTTON1_CLICKED,        { mouse_focus,      { NULL  } } },
    204 	{ BUTTON1_DOUBLE_CLICKED, { mouse_fullscreen, { "[ ]" } } },
    205 	{ BUTTON2_CLICKED,        { mouse_zoom,       { NULL  } } },
    206 	{ BUTTON3_CLICKED,        { mouse_minimize,   { NULL  } } },
    207 };
    208 #endif /* CONFIG_MOUSE */
    209 
    210 static Cmd commands[] = {
    211 	/* create [cmd]: create a new window, run `cmd` in the shell if specified */
    212 	{ "create", { create,	{ NULL } } },
    213 	/* focus <win_id>: focus the window whose `DVTM_WINDOW_ID` is `win_id` */
    214 	{ "focus",  { focusid,	{ NULL } } },
    215 	/* tag <win_id> <tag> [tag ...]: add +tag, remove -tag or set tag of the window with the given identifier */
    216 	{ "tag",    { tagid,	{ NULL } } },
    217 };
    218 
    219 /* gets executed when dvtm is started */
    220 static Action actions[] = {
    221 	{ create, { NULL } },
    222 };
    223 
    224 static char const * const keytable[] = {
    225 	/* add your custom key escape sequences */
    226 };