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