Annotation of src/usr.bin/tmux/options-table.c, Revision 1.79
1.79 ! nicm 1: /* $OpenBSD: options-table.c,v 1.78 2017/01/12 15:36:35 nicm Exp $ */
1.1 nicm 2:
3: /*
1.71 nicm 4: * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
1.1 nicm 5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15: * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #include <sys/types.h>
20:
21: #include <string.h>
22: #include <paths.h>
23:
24: #include "tmux.h"
25:
26: /*
27: * This file has a tables with all the server, session and window
28: * options. These tables are the master copy of the options with their real
29: * (user-visible) types, range limits and default values. At start these are
30: * copied into the runtime global options trees (which only has number and
1.49 nicm 31: * string types). These tables are then used to look up the real type when the
32: * user sets an option or its value needs to be shown.
1.1 nicm 33: */
34:
35: /* Choice option type lists. */
1.74 nicm 36: static const char *options_table_mode_keys_list[] = {
1.1 nicm 37: "emacs", "vi", NULL
38: };
1.74 nicm 39: static const char *options_table_clock_mode_style_list[] = {
1.1 nicm 40: "12", "24", NULL
41: };
1.74 nicm 42: static const char *options_table_status_keys_list[] = {
1.1 nicm 43: "emacs", "vi", NULL
44: };
1.74 nicm 45: static const char *options_table_status_justify_list[] = {
1.1 nicm 46: "left", "centre", "right", NULL
47: };
1.74 nicm 48: static const char *options_table_status_position_list[] = {
1.20 nicm 49: "top", "bottom", NULL
50: };
1.74 nicm 51: static const char *options_table_bell_action_list[] = {
1.59 nicm 52: "none", "any", "current", "other", NULL
1.1 nicm 53: };
1.74 nicm 54: static const char *options_table_pane_status_list[] = {
1.72 nicm 55: "off", "top", "bottom", NULL
56: };
1.1 nicm 57:
58: /* Server options. */
1.67 nicm 59: const struct options_table_entry options_table[] = {
1.1 nicm 60: { .name = "buffer-limit",
61: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 62: .scope = OPTIONS_TABLE_SERVER,
1.1 nicm 63: .minimum = 1,
64: .maximum = INT_MAX,
1.4 nicm 65: .default_num = 20
1.1 nicm 66: },
67:
1.56 nicm 68: { .name = "default-terminal",
69: .type = OPTIONS_TABLE_STRING,
1.67 nicm 70: .scope = OPTIONS_TABLE_SERVER,
1.56 nicm 71: .default_str = "screen"
72: },
73:
1.1 nicm 74: { .name = "escape-time",
75: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 76: .scope = OPTIONS_TABLE_SERVER,
1.1 nicm 77: .minimum = 0,
78: .maximum = INT_MAX,
79: .default_num = 500
80: },
81:
82: { .name = "exit-unattached",
1.38 nicm 83: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 84: .scope = OPTIONS_TABLE_SERVER,
1.38 nicm 85: .default_num = 0
86: },
87:
88: { .name = "focus-events",
1.1 nicm 89: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 90: .scope = OPTIONS_TABLE_SERVER,
1.1 nicm 91: .default_num = 0
1.61 nicm 92: },
93:
94: { .name = "history-file",
95: .type = OPTIONS_TABLE_STRING,
1.67 nicm 96: .scope = OPTIONS_TABLE_SERVER,
1.65 nicm 97: .default_str = ""
1.1 nicm 98: },
99:
1.46 nicm 100: { .name = "message-limit",
101: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 102: .scope = OPTIONS_TABLE_SERVER,
1.46 nicm 103: .minimum = 0,
104: .maximum = INT_MAX,
105: .default_num = 100
1.1 nicm 106: },
107:
1.8 nicm 108: { .name = "set-clipboard",
109: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 110: .scope = OPTIONS_TABLE_SERVER,
1.8 nicm 111: .default_num = 1
112: },
113:
1.45 nicm 114: { .name = "terminal-overrides",
115: .type = OPTIONS_TABLE_STRING,
1.67 nicm 116: .scope = OPTIONS_TABLE_SERVER,
1.63 nicm 117: .default_str = "xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
1.45 nicm 118: ":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
119: ":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"
120: },
121:
1.31 nicm 122: { .name = "assume-paste-time",
123: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 124: .scope = OPTIONS_TABLE_SESSION,
1.31 nicm 125: .minimum = 0,
126: .maximum = INT_MAX,
127: .default_num = 1,
128: },
129:
1.1 nicm 130: { .name = "base-index",
131: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 132: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 133: .minimum = 0,
134: .maximum = INT_MAX,
135: .default_num = 0
136: },
137:
138: { .name = "bell-action",
139: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 140: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 141: .choices = options_table_bell_action_list,
142: .default_num = BELL_ANY
1.11 nicm 143: },
144:
145: { .name = "bell-on-alert",
146: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 147: .scope = OPTIONS_TABLE_SESSION,
1.11 nicm 148: .default_num = 0
1.1 nicm 149: },
150:
151: { .name = "default-command",
152: .type = OPTIONS_TABLE_STRING,
1.67 nicm 153: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 154: .default_str = ""
155: },
156:
157: { .name = "default-shell",
158: .type = OPTIONS_TABLE_STRING,
1.67 nicm 159: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 160: .default_str = _PATH_BSHELL
161: },
162:
163: { .name = "destroy-unattached",
164: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 165: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 166: .default_num = 0
167: },
168:
169: { .name = "detach-on-destroy",
170: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 171: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 172: .default_num = 1
173: },
174:
175: { .name = "display-panes-active-colour",
176: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 177: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 178: .default_num = 1
179: },
180:
181: { .name = "display-panes-colour",
182: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 183: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 184: .default_num = 4
185: },
186:
187: { .name = "display-panes-time",
188: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 189: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 190: .minimum = 1,
191: .maximum = INT_MAX,
192: .default_num = 1000
193: },
194:
195: { .name = "display-time",
196: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 197: .scope = OPTIONS_TABLE_SESSION,
1.68 tim 198: .minimum = 0,
1.1 nicm 199: .maximum = INT_MAX,
200: .default_num = 750
201: },
202:
203: { .name = "history-limit",
204: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 205: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 206: .minimum = 0,
1.3 nicm 207: .maximum = INT_MAX,
1.1 nicm 208: .default_num = 2000
1.70 nicm 209: },
210:
211: { .name = "key-table",
212: .type = OPTIONS_TABLE_STRING,
213: .scope = OPTIONS_TABLE_SESSION,
214: .default_str = "root"
1.1 nicm 215: },
216:
217: { .name = "lock-after-time",
218: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 219: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 220: .minimum = 0,
221: .maximum = INT_MAX,
222: .default_num = 0
223: },
224:
225: { .name = "lock-command",
226: .type = OPTIONS_TABLE_STRING,
1.67 nicm 227: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 228: .default_str = "lock -np"
229: },
230:
231: { .name = "message-attr",
232: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 233: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 234: .default_num = 0,
235: .style = "message-style"
1.1 nicm 236: },
237:
238: { .name = "message-bg",
1.15 nicm 239: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 240: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 241: .default_num = 3,
242: .style = "message-style"
1.15 nicm 243: },
244:
245: { .name = "message-command-attr",
246: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 247: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 248: .default_num = 0,
249: .style = "message-command-style"
1.15 nicm 250: },
251:
252: { .name = "message-command-bg",
253: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 254: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 255: .default_num = 0,
256: .style = "message-command-style"
1.15 nicm 257: },
258:
259: { .name = "message-command-fg",
1.1 nicm 260: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 261: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 262: .default_num = 3,
263: .style = "message-command-style"
264: },
265:
266: { .name = "message-command-style",
267: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 268: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 269: .default_str = "bg=black,fg=yellow"
1.1 nicm 270: },
271:
272: { .name = "message-fg",
273: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 274: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 275: .default_num = 0,
276: .style = "message-style"
1.7 nicm 277: },
278:
1.43 nicm 279: { .name = "message-style",
280: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 281: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 282: .default_str = "bg=yellow,fg=black"
283: },
284:
1.55 nicm 285: { .name = "mouse",
1.1 nicm 286: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 287: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 288: .default_num = 0
289: },
290:
291: { .name = "prefix",
1.19 nicm 292: .type = OPTIONS_TABLE_KEY,
1.67 nicm 293: .scope = OPTIONS_TABLE_SESSION,
1.19 nicm 294: .default_num = '\002',
295: },
296:
297: { .name = "prefix2",
298: .type = OPTIONS_TABLE_KEY,
1.67 nicm 299: .scope = OPTIONS_TABLE_SESSION,
1.19 nicm 300: .default_num = KEYC_NONE,
1.29 nicm 301: },
302:
303: { .name = "renumber-windows",
304: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 305: .scope = OPTIONS_TABLE_SESSION,
1.29 nicm 306: .default_num = 0
1.1 nicm 307: },
308:
309: { .name = "repeat-time",
310: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 311: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 312: .minimum = 0,
313: .maximum = SHRT_MAX,
314: .default_num = 500
315: },
316:
317: { .name = "set-titles",
318: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 319: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 320: .default_num = 0
321: },
322:
323: { .name = "set-titles-string",
324: .type = OPTIONS_TABLE_STRING,
1.67 nicm 325: .scope = OPTIONS_TABLE_SESSION,
1.60 nicm 326: .default_str = "#S:#I:#W - \"#T\" #{session_alerts}"
1.1 nicm 327: },
328:
329: { .name = "status",
330: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 331: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 332: .default_num = 1
333: },
334:
335: { .name = "status-attr",
336: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 337: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 338: .default_num = 0,
339: .style = "status-style"
1.1 nicm 340: },
341:
342: { .name = "status-bg",
343: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 344: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 345: .default_num = 2,
346: .style = "status-style"
1.1 nicm 347: },
348:
349: { .name = "status-fg",
350: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 351: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 352: .default_num = 0,
353: .style = "status-style"
1.1 nicm 354: },
355:
356: { .name = "status-interval",
357: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 358: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 359: .minimum = 0,
360: .maximum = INT_MAX,
361: .default_num = 15
362: },
363:
364: { .name = "status-justify",
365: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 366: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 367: .choices = options_table_status_justify_list,
368: .default_num = 0
369: },
370:
371: { .name = "status-keys",
372: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 373: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 374: .choices = options_table_status_keys_list,
375: .default_num = MODEKEY_EMACS
376: },
377:
378: { .name = "status-left",
379: .type = OPTIONS_TABLE_STRING,
1.67 nicm 380: .scope = OPTIONS_TABLE_SESSION,
1.51 nicm 381: .default_str = "[#S] "
1.1 nicm 382: },
383:
384: { .name = "status-left-attr",
385: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 386: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 387: .default_num = 0,
388: .style = "status-left-style"
1.1 nicm 389: },
390:
391: { .name = "status-left-bg",
392: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 393: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 394: .default_num = 8,
395: .style = "status-left-style"
1.1 nicm 396: },
397:
398: { .name = "status-left-fg",
399: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 400: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 401: .default_num = 8,
402: .style = "status-left-style"
1.1 nicm 403: },
404:
405: { .name = "status-left-length",
406: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 407: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 408: .minimum = 0,
409: .maximum = SHRT_MAX,
410: .default_num = 10
1.20 nicm 411: },
412:
1.43 nicm 413: { .name = "status-left-style",
414: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 415: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 416: .default_str = "default"
417: },
418:
1.20 nicm 419: { .name = "status-position",
420: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 421: .scope = OPTIONS_TABLE_SESSION,
1.20 nicm 422: .choices = options_table_status_position_list,
423: .default_num = 1
1.1 nicm 424: },
425:
426: { .name = "status-right",
427: .type = OPTIONS_TABLE_STRING,
1.67 nicm 428: .scope = OPTIONS_TABLE_SESSION,
1.52 sthen 429: .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
1.1 nicm 430: },
431:
432: { .name = "status-right-attr",
433: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 434: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 435: .default_num = 0,
436: .style = "status-right-style"
1.1 nicm 437: },
438:
439: { .name = "status-right-bg",
440: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 441: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 442: .default_num = 8,
443: .style = "status-right-style"
1.1 nicm 444: },
445:
446: { .name = "status-right-fg",
447: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 448: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 449: .default_num = 8,
450: .style = "status-right-style"
1.1 nicm 451: },
452:
453: { .name = "status-right-length",
454: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 455: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 456: .minimum = 0,
457: .maximum = SHRT_MAX,
458: .default_num = 40
459: },
460:
1.43 nicm 461: { .name = "status-right-style",
462: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 463: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 464: .default_str = "default"
465: },
466:
467: { .name = "status-style",
468: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 469: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 470: .default_str = "bg=green,fg=black"
471: },
472:
1.1 nicm 473: { .name = "update-environment",
474: .type = OPTIONS_TABLE_STRING,
1.67 nicm 475: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 476: .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
1.9 nicm 477: "SSH_CONNECTION WINDOWID XAUTHORITY"
1.1 nicm 478:
479: },
480:
481: { .name = "visual-activity",
482: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 483: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 484: .default_num = 0
485: },
486:
487: { .name = "visual-bell",
488: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 489: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 490: .default_num = 0
491: },
492:
493: { .name = "visual-silence",
494: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 495: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 496: .default_num = 0
497: },
498:
1.16 nicm 499: { .name = "word-separators",
500: .type = OPTIONS_TABLE_STRING,
1.67 nicm 501: .scope = OPTIONS_TABLE_SESSION,
1.16 nicm 502: .default_str = " -_@"
503: },
504:
1.1 nicm 505: { .name = "aggressive-resize",
506: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 507: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 508: .default_num = 0
1.17 nicm 509: },
510:
511: { .name = "allow-rename",
512: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 513: .scope = OPTIONS_TABLE_WINDOW,
1.17 nicm 514: .default_num = 1
1.1 nicm 515: },
516:
517: { .name = "alternate-screen",
518: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 519: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 520: .default_num = 1
521: },
522:
523: { .name = "automatic-rename",
524: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 525: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 526: .default_num = 1
1.41 nicm 527: },
528:
529: { .name = "automatic-rename-format",
530: .type = OPTIONS_TABLE_STRING,
1.67 nicm 531: .scope = OPTIONS_TABLE_WINDOW,
1.50 nicm 532: .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}"
533: "#{?pane_dead,[dead],}"
1.1 nicm 534: },
535:
536: { .name = "clock-mode-colour",
537: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 538: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 539: .default_num = 4
540: },
541:
542: { .name = "clock-mode-style",
543: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 544: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 545: .choices = options_table_clock_mode_style_list,
546: .default_num = 1
547: },
548:
549: { .name = "force-height",
550: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 551: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 552: .minimum = 0,
553: .maximum = INT_MAX,
554: .default_num = 0
555: },
556:
557: { .name = "force-width",
558: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 559: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 560: .minimum = 0,
561: .maximum = INT_MAX,
562: .default_num = 0
563: },
564:
565: { .name = "main-pane-height",
566: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 567: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 568: .minimum = 1,
569: .maximum = INT_MAX,
570: .default_num = 24
571: },
572:
573: { .name = "main-pane-width",
574: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 575: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 576: .minimum = 1,
577: .maximum = INT_MAX,
578: .default_num = 80
579: },
580:
581: { .name = "mode-attr",
582: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 583: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 584: .default_num = 0,
585: .style = "mode-style"
1.1 nicm 586: },
587:
588: { .name = "mode-bg",
589: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 590: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 591: .default_num = 3,
592: .style = "mode-style"
1.1 nicm 593: },
594:
595: { .name = "mode-fg",
596: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 597: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 598: .default_num = 0,
599: .style = "mode-style"
1.1 nicm 600: },
601:
602: { .name = "mode-keys",
603: .type = OPTIONS_TABLE_CHOICE,
1.67 nicm 604: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 605: .choices = options_table_mode_keys_list,
606: .default_num = MODEKEY_EMACS
607: },
608:
1.43 nicm 609: { .name = "mode-style",
610: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 611: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 612: .default_str = "bg=yellow,fg=black"
613: },
614:
1.1 nicm 615: { .name = "monitor-activity",
616: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 617: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 618: .default_num = 0
619: },
620:
621: { .name = "monitor-silence",
622: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 623: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 624: .minimum = 0,
625: .maximum = INT_MAX,
626: .default_num = 0
627: },
628:
629: { .name = "other-pane-height",
630: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 631: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 632: .minimum = 0,
633: .maximum = INT_MAX,
634: .default_num = 0
635: },
636:
637: { .name = "other-pane-width",
638: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 639: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 640: .minimum = 0,
641: .maximum = INT_MAX,
1.13 nicm 642: .default_num = 0
643: },
644:
1.53 nicm 645: { .name = "pane-active-border-bg",
646: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 647: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 648: .default_num = 8,
649: .style = "pane-active-border-style"
650: },
651:
652: { .name = "pane-active-border-fg",
653: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 654: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 655: .default_num = 2,
656: .style = "pane-active-border-style"
657: },
658:
659: { .name = "pane-active-border-style",
660: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 661: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 662: .default_str = "fg=green"
663: },
664:
1.13 nicm 665: { .name = "pane-base-index",
666: .type = OPTIONS_TABLE_NUMBER,
1.67 nicm 667: .scope = OPTIONS_TABLE_WINDOW,
1.13 nicm 668: .minimum = 0,
669: .maximum = USHRT_MAX,
1.22 nicm 670: .default_num = 0
1.53 nicm 671: },
672:
673: { .name = "pane-border-bg",
674: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 675: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 676: .default_num = 8,
677: .style = "pane-border-style"
678: },
679:
680: { .name = "pane-border-fg",
681: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 682: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 683: .default_num = 8,
684: .style = "pane-border-style"
1.72 nicm 685: },
686:
687: { .name = "pane-border-format",
688: .type = OPTIONS_TABLE_STRING,
689: .scope = OPTIONS_TABLE_WINDOW,
1.73 nicm 690: .default_str = "#{?pane_active,#[reverse],}#{pane_index}#[default] "
691: "\"#{pane_title}\""
1.72 nicm 692: },
693:
694: { .name = "pane-border-status",
695: .type = OPTIONS_TABLE_CHOICE,
696: .scope = OPTIONS_TABLE_WINDOW,
697: .choices = options_table_pane_status_list,
698: .default_num = 0
1.53 nicm 699: },
700:
701: { .name = "pane-border-style",
702: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 703: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 704: .default_str = "default"
1.22 nicm 705: },
706:
1.1 nicm 707: { .name = "remain-on-exit",
708: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 709: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 710: .default_num = 0
711: },
712:
713: { .name = "synchronize-panes",
714: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 715: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 716: .default_num = 0
1.54 nicm 717: },
718:
719: { .name = "window-active-style",
720: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 721: .scope = OPTIONS_TABLE_WINDOW,
1.54 nicm 722: .default_str = "default"
723: },
724:
725: { .name = "window-style",
726: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 727: .scope = OPTIONS_TABLE_WINDOW,
1.54 nicm 728: .default_str = "default"
1.1 nicm 729: },
730:
1.21 nicm 731: { .name = "window-status-activity-attr",
1.1 nicm 732: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 733: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 734: .default_num = GRID_ATTR_REVERSE,
735: .style = "window-status-activity-style"
1.1 nicm 736: },
737:
1.21 nicm 738: { .name = "window-status-activity-bg",
1.1 nicm 739: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 740: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 741: .default_num = 8,
742: .style = "window-status-activity-style"
1.1 nicm 743: },
744:
1.21 nicm 745: { .name = "window-status-activity-fg",
1.18 nicm 746: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 747: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 748: .default_num = 8,
749: .style = "window-status-activity-style"
750: },
751:
752: { .name = "window-status-activity-style",
753: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 754: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 755: .default_str = "reverse"
756: },
757:
758: { .name = "window-status-attr",
759: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 760: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 761: .default_num = 0,
762: .style = "window-status-style"
1.18 nicm 763: },
764:
1.21 nicm 765: { .name = "window-status-bell-attr",
1.18 nicm 766: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 767: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 768: .default_num = GRID_ATTR_REVERSE,
769: .style = "window-status-bell-style"
1.18 nicm 770: },
771:
1.21 nicm 772: { .name = "window-status-bell-bg",
1.18 nicm 773: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 774: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 775: .default_num = 8,
776: .style = "window-status-bell-style"
1.18 nicm 777: },
778:
1.21 nicm 779: { .name = "window-status-bell-fg",
1.18 nicm 780: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 781: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 782: .default_num = 8,
783: .style = "window-status-bell-style"
784: },
785:
786: { .name = "window-status-bell-style",
787: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 788: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 789: .default_str = "reverse"
790: },
791:
792: { .name = "window-status-bg",
793: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 794: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 795: .default_num = 8,
796: .style = "window-status-style"
1.1 nicm 797: },
798:
799: { .name = "window-status-current-attr",
800: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 801: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 802: .default_num = 0,
803: .style = "window-status-current-style"
1.1 nicm 804: },
805:
806: { .name = "window-status-current-bg",
807: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 808: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 809: .default_num = 8,
810: .style = "window-status-current-style"
1.1 nicm 811: },
812:
813: { .name = "window-status-current-fg",
814: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 815: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 816: .default_num = 8,
817: .style = "window-status-current-style"
1.1 nicm 818: },
819:
820: { .name = "window-status-current-format",
821: .type = OPTIONS_TABLE_STRING,
1.67 nicm 822: .scope = OPTIONS_TABLE_WINDOW,
1.57 nicm 823: .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.30 nicm 824: },
825:
1.43 nicm 826: { .name = "window-status-current-style",
827: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 828: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 829: .default_str = "default"
830: },
831:
832: { .name = "window-status-fg",
833: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 834: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 835: .default_num = 8,
836: .style = "window-status-style"
837: },
838:
839: { .name = "window-status-format",
840: .type = OPTIONS_TABLE_STRING,
1.67 nicm 841: .scope = OPTIONS_TABLE_WINDOW,
1.57 nicm 842: .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.43 nicm 843: },
844:
1.30 nicm 845: { .name = "window-status-last-attr",
846: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 nicm 847: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 848: .default_num = 0,
849: .style = "window-status-last-style"
1.30 nicm 850: },
851:
852: { .name = "window-status-last-bg",
853: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 854: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 855: .default_num = 8,
856: .style = "window-status-last-style"
1.30 nicm 857: },
858:
859: { .name = "window-status-last-fg",
860: .type = OPTIONS_TABLE_COLOUR,
1.67 nicm 861: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 862: .default_num = 8,
863: .style = "window-status-last-style"
1.1 nicm 864: },
865:
1.43 nicm 866: { .name = "window-status-last-style",
867: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 868: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 869: .default_str = "default"
1.1 nicm 870: },
871:
1.43 nicm 872: { .name = "window-status-separator",
1.1 nicm 873: .type = OPTIONS_TABLE_STRING,
1.67 nicm 874: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 875: .default_str = " "
1.28 nicm 876: },
877:
1.43 nicm 878: { .name = "window-status-style",
879: .type = OPTIONS_TABLE_STYLE,
1.67 nicm 880: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 881: .default_str = "default"
1.24 nicm 882: },
883:
884: { .name = "wrap-search",
885: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 886: .scope = OPTIONS_TABLE_WINDOW,
1.24 nicm 887: .default_num = 1
1.1 nicm 888: },
889:
890: { .name = "xterm-keys",
891: .type = OPTIONS_TABLE_FLAG,
1.67 nicm 892: .scope = OPTIONS_TABLE_WINDOW,
1.76 nicm 893: .default_num = 1
1.1 nicm 894: },
895:
896: { .name = NULL }
897: };
898:
899: /* Populate an options tree from a table. */
900: void
1.67 nicm 901: options_table_populate_tree(enum options_table_scope scope, struct options *oo)
1.1 nicm 902: {
903: const struct options_table_entry *oe;
904:
1.67 nicm 905: for (oe = options_table; oe->name != NULL; oe++) {
1.69 nicm 906: if (oe->scope == OPTIONS_TABLE_NONE)
907: fatalx("no scope for %s", oe->name);
1.67 nicm 908: if (oe->scope != scope)
909: continue;
1.43 nicm 910: switch (oe->type) {
911: case OPTIONS_TABLE_STRING:
1.78 nicm 912: options_set_string(oo, oe->name, 0, "%s",
913: oe->default_str);
1.43 nicm 914: break;
915: case OPTIONS_TABLE_STYLE:
1.78 nicm 916: options_set_style(oo, oe->name, 0, oe->default_str);
1.43 nicm 917: break;
918: default:
1.1 nicm 919: options_set_number(oo, oe->name, oe->default_num);
1.43 nicm 920: break;
921: }
1.1 nicm 922: }
923: }
924:
925: /* Print an option using its type from the table. */
926: const char *
1.33 nicm 927: options_table_print_entry(const struct options_table_entry *oe,
928: struct options_entry *o, int no_quotes)
1.1 nicm 929: {
1.19 nicm 930: static char out[BUFSIZ];
931: const char *s;
1.1 nicm 932:
933: *out = '\0';
934: switch (oe->type) {
935: case OPTIONS_TABLE_STRING:
1.33 nicm 936: if (no_quotes)
937: xsnprintf(out, sizeof out, "%s", o->str);
938: else
939: xsnprintf(out, sizeof out, "\"%s\"", o->str);
1.1 nicm 940: break;
941: case OPTIONS_TABLE_NUMBER:
942: xsnprintf(out, sizeof out, "%lld", o->num);
943: break;
1.19 nicm 944: case OPTIONS_TABLE_KEY:
1.77 nicm 945: s = key_string_lookup_key(o->num);
946: xsnprintf(out, sizeof out, "%s", s);
1.1 nicm 947: break;
948: case OPTIONS_TABLE_COLOUR:
949: s = colour_tostring(o->num);
950: xsnprintf(out, sizeof out, "%s", s);
951: break;
952: case OPTIONS_TABLE_ATTRIBUTES:
953: s = attributes_tostring(o->num);
954: xsnprintf(out, sizeof out, "%s", s);
955: break;
956: case OPTIONS_TABLE_FLAG:
957: if (o->num)
958: strlcpy(out, "on", sizeof out);
959: else
960: strlcpy(out, "off", sizeof out);
961: break;
962: case OPTIONS_TABLE_CHOICE:
963: s = oe->choices[o->num];
1.43 nicm 964: xsnprintf(out, sizeof out, "%s", s);
965: break;
966: case OPTIONS_TABLE_STYLE:
967: s = style_tostring(&o->style);
1.1 nicm 968: xsnprintf(out, sizeof out, "%s", s);
969: break;
970: }
971: return (out);
1.22 nicm 972: }
973:
974: /* Find an option. */
975: int
1.67 nicm 976: options_table_find(const char *optstr, const struct options_table_entry **oe)
1.22 nicm 977: {
978: const struct options_table_entry *oe_loop;
979:
1.67 nicm 980: for (oe_loop = options_table; oe_loop->name != NULL; oe_loop++) {
981: if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
982: continue;
983:
984: /* If already found, ambiguous. */
985: if (*oe != NULL)
986: return (-1);
987: *oe = oe_loop;
988:
989: /* Bail now if an exact match. */
990: if (strcmp(oe_loop->name, optstr) == 0)
991: break;
1.22 nicm 992: }
993: return (0);
1.1 nicm 994: }