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