Annotation of src/usr.bin/tmux/options-table.c, Revision 1.67
1.67 ! nicm 1: /* $OpenBSD: options-table.c,v 1.66 2015/11/12 11:09:11 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.1 nicm 201: .minimum = 1,
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
212: },
213:
214: { .name = "lock-after-time",
215: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 216: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 217: .minimum = 0,
218: .maximum = INT_MAX,
219: .default_num = 0
220: },
221:
222: { .name = "lock-command",
223: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 224: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 225: .default_str = "lock -np"
226: },
227:
228: { .name = "message-attr",
229: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 230: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 231: .default_num = 0,
232: .style = "message-style"
1.1 nicm 233: },
234:
235: { .name = "message-bg",
1.15 nicm 236: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 237: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 238: .default_num = 3,
239: .style = "message-style"
1.15 nicm 240: },
241:
242: { .name = "message-command-attr",
243: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 244: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 245: .default_num = 0,
246: .style = "message-command-style"
1.15 nicm 247: },
248:
249: { .name = "message-command-bg",
250: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 251: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 252: .default_num = 0,
253: .style = "message-command-style"
1.15 nicm 254: },
255:
256: { .name = "message-command-fg",
1.1 nicm 257: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 258: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 259: .default_num = 3,
260: .style = "message-command-style"
261: },
262:
263: { .name = "message-command-style",
264: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 265: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 266: .default_str = "bg=black,fg=yellow"
1.1 nicm 267: },
268:
269: { .name = "message-fg",
270: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 271: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 272: .default_num = 0,
273: .style = "message-style"
1.7 nicm 274: },
275:
1.43 nicm 276: { .name = "message-style",
277: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 278: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 279: .default_str = "bg=yellow,fg=black"
280: },
281:
1.55 nicm 282: { .name = "mouse",
1.1 nicm 283: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 284: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 285: .default_num = 0
286: },
287:
288: { .name = "prefix",
1.19 nicm 289: .type = OPTIONS_TABLE_KEY,
1.67 ! nicm 290: .scope = OPTIONS_TABLE_SESSION,
1.19 nicm 291: .default_num = '\002',
292: },
293:
294: { .name = "prefix2",
295: .type = OPTIONS_TABLE_KEY,
1.67 ! nicm 296: .scope = OPTIONS_TABLE_SESSION,
1.19 nicm 297: .default_num = KEYC_NONE,
1.29 nicm 298: },
299:
300: { .name = "renumber-windows",
301: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 302: .scope = OPTIONS_TABLE_SESSION,
1.29 nicm 303: .default_num = 0
1.1 nicm 304: },
305:
306: { .name = "repeat-time",
307: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 308: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 309: .minimum = 0,
310: .maximum = SHRT_MAX,
311: .default_num = 500
312: },
313:
314: { .name = "set-remain-on-exit",
315: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 316: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 317: .default_num = 0
318: },
319:
320: { .name = "set-titles",
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-string",
327: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 328: .scope = OPTIONS_TABLE_SESSION,
1.60 nicm 329: .default_str = "#S:#I:#W - \"#T\" #{session_alerts}"
1.1 nicm 330: },
331:
332: { .name = "status",
333: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 334: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 335: .default_num = 1
336: },
337:
338: { .name = "status-attr",
339: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 340: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 341: .default_num = 0,
342: .style = "status-style"
1.1 nicm 343: },
344:
345: { .name = "status-bg",
346: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 347: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 348: .default_num = 2,
349: .style = "status-style"
1.1 nicm 350: },
351:
352: { .name = "status-fg",
353: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 354: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 355: .default_num = 0,
356: .style = "status-style"
1.1 nicm 357: },
358:
359: { .name = "status-interval",
360: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 361: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 362: .minimum = 0,
363: .maximum = INT_MAX,
364: .default_num = 15
365: },
366:
367: { .name = "status-justify",
368: .type = OPTIONS_TABLE_CHOICE,
1.67 ! nicm 369: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 370: .choices = options_table_status_justify_list,
371: .default_num = 0
372: },
373:
374: { .name = "status-keys",
375: .type = OPTIONS_TABLE_CHOICE,
1.67 ! nicm 376: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 377: .choices = options_table_status_keys_list,
378: .default_num = MODEKEY_EMACS
379: },
380:
381: { .name = "status-left",
382: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 383: .scope = OPTIONS_TABLE_SESSION,
1.51 nicm 384: .default_str = "[#S] "
1.1 nicm 385: },
386:
387: { .name = "status-left-attr",
388: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 389: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 390: .default_num = 0,
391: .style = "status-left-style"
1.1 nicm 392: },
393:
394: { .name = "status-left-bg",
395: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 396: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 397: .default_num = 8,
398: .style = "status-left-style"
1.1 nicm 399: },
400:
401: { .name = "status-left-fg",
402: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 403: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 404: .default_num = 8,
405: .style = "status-left-style"
1.1 nicm 406: },
407:
408: { .name = "status-left-length",
409: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 410: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 411: .minimum = 0,
412: .maximum = SHRT_MAX,
413: .default_num = 10
1.20 nicm 414: },
415:
1.43 nicm 416: { .name = "status-left-style",
417: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 418: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 419: .default_str = "default"
420: },
421:
1.20 nicm 422: { .name = "status-position",
423: .type = OPTIONS_TABLE_CHOICE,
1.67 ! nicm 424: .scope = OPTIONS_TABLE_SESSION,
1.20 nicm 425: .choices = options_table_status_position_list,
426: .default_num = 1
1.1 nicm 427: },
428:
429: { .name = "status-right",
430: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 431: .scope = OPTIONS_TABLE_SESSION,
1.52 sthen 432: .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
1.1 nicm 433: },
434:
435: { .name = "status-right-attr",
436: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 437: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 438: .default_num = 0,
439: .style = "status-right-style"
1.1 nicm 440: },
441:
442: { .name = "status-right-bg",
443: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 444: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 445: .default_num = 8,
446: .style = "status-right-style"
1.1 nicm 447: },
448:
449: { .name = "status-right-fg",
450: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 451: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 452: .default_num = 8,
453: .style = "status-right-style"
1.1 nicm 454: },
455:
456: { .name = "status-right-length",
457: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 458: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 459: .minimum = 0,
460: .maximum = SHRT_MAX,
461: .default_num = 40
462: },
463:
1.43 nicm 464: { .name = "status-right-style",
465: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 466: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 467: .default_str = "default"
468: },
469:
470: { .name = "status-style",
471: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 472: .scope = OPTIONS_TABLE_SESSION,
1.43 nicm 473: .default_str = "bg=green,fg=black"
474: },
475:
1.1 nicm 476: { .name = "update-environment",
477: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 478: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 479: .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
1.9 nicm 480: "SSH_CONNECTION WINDOWID XAUTHORITY"
1.1 nicm 481:
482: },
483:
484: { .name = "visual-activity",
485: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 486: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 487: .default_num = 0
488: },
489:
490: { .name = "visual-bell",
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-silence",
497: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 498: .scope = OPTIONS_TABLE_SESSION,
1.1 nicm 499: .default_num = 0
500: },
501:
1.16 nicm 502: { .name = "word-separators",
503: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 504: .scope = OPTIONS_TABLE_SESSION,
1.16 nicm 505: .default_str = " -_@"
506: },
507:
1.1 nicm 508: { .name = "aggressive-resize",
509: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 510: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 511: .default_num = 0
1.17 nicm 512: },
513:
514: { .name = "allow-rename",
515: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 516: .scope = OPTIONS_TABLE_WINDOW,
1.17 nicm 517: .default_num = 1
1.1 nicm 518: },
519:
520: { .name = "alternate-screen",
521: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 522: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 523: .default_num = 1
524: },
525:
526: { .name = "automatic-rename",
527: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 528: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 529: .default_num = 1
1.41 nicm 530: },
531:
532: { .name = "automatic-rename-format",
533: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 534: .scope = OPTIONS_TABLE_WINDOW,
1.50 nicm 535: .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}"
536: "#{?pane_dead,[dead],}"
1.1 nicm 537: },
538:
539: { .name = "clock-mode-colour",
540: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 541: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 542: .default_num = 4
543: },
544:
545: { .name = "clock-mode-style",
546: .type = OPTIONS_TABLE_CHOICE,
1.67 ! nicm 547: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 548: .choices = options_table_clock_mode_style_list,
549: .default_num = 1
550: },
551:
552: { .name = "force-height",
553: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 554: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 555: .minimum = 0,
556: .maximum = INT_MAX,
557: .default_num = 0
558: },
559:
560: { .name = "force-width",
561: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 562: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 563: .minimum = 0,
564: .maximum = INT_MAX,
565: .default_num = 0
566: },
567:
568: { .name = "main-pane-height",
569: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 570: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 571: .minimum = 1,
572: .maximum = INT_MAX,
573: .default_num = 24
574: },
575:
576: { .name = "main-pane-width",
577: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 578: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 579: .minimum = 1,
580: .maximum = INT_MAX,
581: .default_num = 80
582: },
583:
584: { .name = "mode-attr",
585: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 586: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 587: .default_num = 0,
588: .style = "mode-style"
1.1 nicm 589: },
590:
591: { .name = "mode-bg",
592: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 593: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 594: .default_num = 3,
595: .style = "mode-style"
1.1 nicm 596: },
597:
598: { .name = "mode-fg",
599: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 600: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 601: .default_num = 0,
602: .style = "mode-style"
1.1 nicm 603: },
604:
605: { .name = "mode-keys",
606: .type = OPTIONS_TABLE_CHOICE,
1.67 ! nicm 607: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 608: .choices = options_table_mode_keys_list,
609: .default_num = MODEKEY_EMACS
610: },
611:
1.43 nicm 612: { .name = "mode-style",
613: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 614: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 615: .default_str = "bg=yellow,fg=black"
616: },
617:
1.1 nicm 618: { .name = "monitor-activity",
619: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 620: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 621: .default_num = 0
622: },
623:
624: { .name = "monitor-silence",
625: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 626: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 627: .minimum = 0,
628: .maximum = INT_MAX,
629: .default_num = 0
630: },
631:
632: { .name = "other-pane-height",
633: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 634: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 635: .minimum = 0,
636: .maximum = INT_MAX,
637: .default_num = 0
638: },
639:
640: { .name = "other-pane-width",
641: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 642: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 643: .minimum = 0,
644: .maximum = INT_MAX,
1.13 nicm 645: .default_num = 0
646: },
647:
1.53 nicm 648: { .name = "pane-active-border-bg",
649: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 650: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 651: .default_num = 8,
652: .style = "pane-active-border-style"
653: },
654:
655: { .name = "pane-active-border-fg",
656: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 657: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 658: .default_num = 2,
659: .style = "pane-active-border-style"
660: },
661:
662: { .name = "pane-active-border-style",
663: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 664: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 665: .default_str = "fg=green"
666: },
667:
1.13 nicm 668: { .name = "pane-base-index",
669: .type = OPTIONS_TABLE_NUMBER,
1.67 ! nicm 670: .scope = OPTIONS_TABLE_WINDOW,
1.13 nicm 671: .minimum = 0,
672: .maximum = USHRT_MAX,
1.22 nicm 673: .default_num = 0
1.53 nicm 674: },
675:
676: { .name = "pane-border-bg",
677: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 678: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 679: .default_num = 8,
680: .style = "pane-border-style"
681: },
682:
683: { .name = "pane-border-fg",
684: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 685: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 686: .default_num = 8,
687: .style = "pane-border-style"
688: },
689:
690: { .name = "pane-border-style",
691: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 692: .scope = OPTIONS_TABLE_WINDOW,
1.53 nicm 693: .default_str = "default"
1.22 nicm 694: },
695:
1.1 nicm 696: { .name = "remain-on-exit",
697: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 698: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 699: .default_num = 0
700: },
701:
702: { .name = "synchronize-panes",
703: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 704: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 705: .default_num = 0
1.54 nicm 706: },
707:
708: { .name = "window-active-style",
709: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 710: .scope = OPTIONS_TABLE_WINDOW,
1.54 nicm 711: .default_str = "default"
712: },
713:
714: { .name = "window-style",
715: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 716: .scope = OPTIONS_TABLE_WINDOW,
1.54 nicm 717: .default_str = "default"
1.1 nicm 718: },
719:
1.21 nicm 720: { .name = "window-status-activity-attr",
1.1 nicm 721: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 722: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 723: .default_num = GRID_ATTR_REVERSE,
724: .style = "window-status-activity-style"
1.1 nicm 725: },
726:
1.21 nicm 727: { .name = "window-status-activity-bg",
1.1 nicm 728: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 729: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 730: .default_num = 8,
731: .style = "window-status-activity-style"
1.1 nicm 732: },
733:
1.21 nicm 734: { .name = "window-status-activity-fg",
1.18 nicm 735: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 736: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 737: .default_num = 8,
738: .style = "window-status-activity-style"
739: },
740:
741: { .name = "window-status-activity-style",
742: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 743: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 744: .default_str = "reverse"
745: },
746:
747: { .name = "window-status-attr",
748: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 749: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 750: .default_num = 0,
751: .style = "window-status-style"
1.18 nicm 752: },
753:
1.21 nicm 754: { .name = "window-status-bell-attr",
1.18 nicm 755: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 756: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 757: .default_num = GRID_ATTR_REVERSE,
758: .style = "window-status-bell-style"
1.18 nicm 759: },
760:
1.21 nicm 761: { .name = "window-status-bell-bg",
1.18 nicm 762: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 763: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 764: .default_num = 8,
765: .style = "window-status-bell-style"
1.18 nicm 766: },
767:
1.21 nicm 768: { .name = "window-status-bell-fg",
1.18 nicm 769: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 770: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 771: .default_num = 8,
772: .style = "window-status-bell-style"
773: },
774:
775: { .name = "window-status-bell-style",
776: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 777: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 778: .default_str = "reverse"
779: },
780:
781: { .name = "window-status-bg",
782: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 783: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 784: .default_num = 8,
785: .style = "window-status-style"
1.1 nicm 786: },
787:
788: { .name = "window-status-current-attr",
789: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 790: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 791: .default_num = 0,
792: .style = "window-status-current-style"
1.1 nicm 793: },
794:
795: { .name = "window-status-current-bg",
796: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 797: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 798: .default_num = 8,
799: .style = "window-status-current-style"
1.1 nicm 800: },
801:
802: { .name = "window-status-current-fg",
803: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 804: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 805: .default_num = 8,
806: .style = "window-status-current-style"
1.1 nicm 807: },
808:
809: { .name = "window-status-current-format",
810: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 811: .scope = OPTIONS_TABLE_WINDOW,
1.57 nicm 812: .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.30 nicm 813: },
814:
1.43 nicm 815: { .name = "window-status-current-style",
816: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 817: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 818: .default_str = "default"
819: },
820:
821: { .name = "window-status-fg",
822: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 823: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 824: .default_num = 8,
825: .style = "window-status-style"
826: },
827:
828: { .name = "window-status-format",
829: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 830: .scope = OPTIONS_TABLE_WINDOW,
1.57 nicm 831: .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.43 nicm 832: },
833:
1.30 nicm 834: { .name = "window-status-last-attr",
835: .type = OPTIONS_TABLE_ATTRIBUTES,
1.67 ! nicm 836: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 837: .default_num = 0,
838: .style = "window-status-last-style"
1.30 nicm 839: },
840:
841: { .name = "window-status-last-bg",
842: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 843: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 844: .default_num = 8,
845: .style = "window-status-last-style"
1.30 nicm 846: },
847:
848: { .name = "window-status-last-fg",
849: .type = OPTIONS_TABLE_COLOUR,
1.67 ! nicm 850: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 851: .default_num = 8,
852: .style = "window-status-last-style"
1.1 nicm 853: },
854:
1.43 nicm 855: { .name = "window-status-last-style",
856: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 857: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 858: .default_str = "default"
1.1 nicm 859: },
860:
1.43 nicm 861: { .name = "window-status-separator",
1.1 nicm 862: .type = OPTIONS_TABLE_STRING,
1.67 ! nicm 863: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 864: .default_str = " "
1.28 nicm 865: },
866:
1.43 nicm 867: { .name = "window-status-style",
868: .type = OPTIONS_TABLE_STYLE,
1.67 ! nicm 869: .scope = OPTIONS_TABLE_WINDOW,
1.43 nicm 870: .default_str = "default"
1.24 nicm 871: },
872:
873: { .name = "wrap-search",
874: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 875: .scope = OPTIONS_TABLE_WINDOW,
1.24 nicm 876: .default_num = 1
1.1 nicm 877: },
878:
879: { .name = "xterm-keys",
880: .type = OPTIONS_TABLE_FLAG,
1.67 ! nicm 881: .scope = OPTIONS_TABLE_WINDOW,
1.1 nicm 882: .default_num = 0
883: },
884:
885: { .name = NULL }
886: };
887:
888: /* Populate an options tree from a table. */
889: void
1.67 ! nicm 890: options_table_populate_tree(enum options_table_scope scope, struct options *oo)
1.1 nicm 891: {
892: const struct options_table_entry *oe;
893:
1.67 ! nicm 894: for (oe = options_table; oe->name != NULL; oe++) {
! 895: if (oe->scope != scope)
! 896: continue;
1.43 nicm 897: switch (oe->type) {
898: case OPTIONS_TABLE_STRING:
1.1 nicm 899: options_set_string(oo, oe->name, "%s", oe->default_str);
1.43 nicm 900: break;
901: case OPTIONS_TABLE_STYLE:
1.44 nicm 902: options_set_style(oo, oe->name, oe->default_str, 0);
1.43 nicm 903: break;
904: default:
1.1 nicm 905: options_set_number(oo, oe->name, oe->default_num);
1.43 nicm 906: break;
907: }
1.1 nicm 908: }
909: }
910:
911: /* Print an option using its type from the table. */
912: const char *
1.33 nicm 913: options_table_print_entry(const struct options_table_entry *oe,
914: struct options_entry *o, int no_quotes)
1.1 nicm 915: {
1.19 nicm 916: static char out[BUFSIZ];
917: const char *s;
1.1 nicm 918:
919: *out = '\0';
920: switch (oe->type) {
921: case OPTIONS_TABLE_STRING:
1.33 nicm 922: if (no_quotes)
923: xsnprintf(out, sizeof out, "%s", o->str);
924: else
925: xsnprintf(out, sizeof out, "\"%s\"", o->str);
1.1 nicm 926: break;
927: case OPTIONS_TABLE_NUMBER:
928: xsnprintf(out, sizeof out, "%lld", o->num);
929: break;
1.19 nicm 930: case OPTIONS_TABLE_KEY:
1.33 nicm 931: xsnprintf(out, sizeof out, "%s",
932: key_string_lookup_key(o->num));
1.1 nicm 933: break;
934: case OPTIONS_TABLE_COLOUR:
935: s = colour_tostring(o->num);
936: xsnprintf(out, sizeof out, "%s", s);
937: break;
938: case OPTIONS_TABLE_ATTRIBUTES:
939: s = attributes_tostring(o->num);
940: xsnprintf(out, sizeof out, "%s", s);
941: break;
942: case OPTIONS_TABLE_FLAG:
943: if (o->num)
944: strlcpy(out, "on", sizeof out);
945: else
946: strlcpy(out, "off", sizeof out);
947: break;
948: case OPTIONS_TABLE_CHOICE:
949: s = oe->choices[o->num];
1.43 nicm 950: xsnprintf(out, sizeof out, "%s", s);
951: break;
952: case OPTIONS_TABLE_STYLE:
953: s = style_tostring(&o->style);
1.1 nicm 954: xsnprintf(out, sizeof out, "%s", s);
955: break;
956: }
957: return (out);
1.22 nicm 958: }
959:
960: /* Find an option. */
961: int
1.67 ! nicm 962: options_table_find(const char *optstr, const struct options_table_entry **oe)
1.22 nicm 963: {
964: const struct options_table_entry *oe_loop;
965:
1.67 ! nicm 966: for (oe_loop = options_table; oe_loop->name != NULL; oe_loop++) {
! 967: if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
! 968: continue;
! 969:
! 970: /* If already found, ambiguous. */
! 971: if (*oe != NULL)
! 972: return (-1);
! 973: *oe = oe_loop;
! 974:
! 975: /* Bail now if an exact match. */
! 976: if (strcmp(oe_loop->name, optstr) == 0)
! 977: break;
1.22 nicm 978: }
979: return (0);
1.1 nicm 980: }