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