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