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