GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/tmux/options-table.c Lines: 0 44 0.0 %
Date: 2016-12-06 Branches: 0 30 0.0 %

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