[BACK]Return to options-table.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Annotation of src/usr.bin/tmux/options-table.c, Revision 1.63

1.63    ! nicm        1: /* $OpenBSD: options-table.c,v 1.62 2015/08/28 12:31:55 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,
                     88:          .default_str = NULL
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.2       nicm      255:          .type = OPTIONS_TABLE_FLAG,
                    256:          .default_num = 0
                    257:        },
                    258:
                    259:        { .name = "mouse-utf8",
1.1       nicm      260:          .type = OPTIONS_TABLE_FLAG,
                    261:          .default_num = 0
                    262:        },
                    263:
                    264:        { .name = "prefix",
1.19      nicm      265:          .type = OPTIONS_TABLE_KEY,
                    266:          .default_num = '\002',
                    267:        },
                    268:
                    269:        { .name = "prefix2",
                    270:          .type = OPTIONS_TABLE_KEY,
                    271:          .default_num = KEYC_NONE,
1.29      nicm      272:        },
                    273:
                    274:        { .name = "renumber-windows",
                    275:          .type = OPTIONS_TABLE_FLAG,
                    276:          .default_num = 0
1.1       nicm      277:        },
                    278:
                    279:        { .name = "repeat-time",
                    280:          .type = OPTIONS_TABLE_NUMBER,
                    281:          .minimum = 0,
                    282:          .maximum = SHRT_MAX,
                    283:          .default_num = 500
                    284:        },
                    285:
                    286:        { .name = "set-remain-on-exit",
                    287:          .type = OPTIONS_TABLE_FLAG,
                    288:          .default_num = 0
                    289:        },
                    290:
                    291:        { .name = "set-titles",
                    292:          .type = OPTIONS_TABLE_FLAG,
                    293:          .default_num = 0
                    294:        },
                    295:
                    296:        { .name = "set-titles-string",
                    297:          .type = OPTIONS_TABLE_STRING,
1.60      nicm      298:          .default_str = "#S:#I:#W - \"#T\" #{session_alerts}"
1.1       nicm      299:        },
                    300:
                    301:        { .name = "status",
                    302:          .type = OPTIONS_TABLE_FLAG,
                    303:          .default_num = 1
                    304:        },
                    305:
                    306:        { .name = "status-attr",
                    307:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      308:          .default_num = 0,
                    309:          .style = "status-style"
1.1       nicm      310:        },
                    311:
                    312:        { .name = "status-bg",
                    313:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      314:          .default_num = 2,
                    315:          .style = "status-style"
1.1       nicm      316:        },
                    317:
                    318:        { .name = "status-fg",
                    319:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      320:          .default_num = 0,
                    321:          .style = "status-style"
1.1       nicm      322:        },
                    323:
                    324:        { .name = "status-interval",
                    325:          .type = OPTIONS_TABLE_NUMBER,
                    326:          .minimum = 0,
                    327:          .maximum = INT_MAX,
                    328:          .default_num = 15
                    329:        },
                    330:
                    331:        { .name = "status-justify",
                    332:          .type = OPTIONS_TABLE_CHOICE,
                    333:          .choices = options_table_status_justify_list,
                    334:          .default_num = 0
                    335:        },
                    336:
                    337:        { .name = "status-keys",
                    338:          .type = OPTIONS_TABLE_CHOICE,
                    339:          .choices = options_table_status_keys_list,
                    340:          .default_num = MODEKEY_EMACS
                    341:        },
                    342:
                    343:        { .name = "status-left",
                    344:          .type = OPTIONS_TABLE_STRING,
1.51      nicm      345:          .default_str = "[#S] "
1.1       nicm      346:        },
                    347:
                    348:        { .name = "status-left-attr",
                    349:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      350:          .default_num = 0,
                    351:          .style = "status-left-style"
1.1       nicm      352:        },
                    353:
                    354:        { .name = "status-left-bg",
                    355:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      356:          .default_num = 8,
                    357:          .style = "status-left-style"
1.1       nicm      358:        },
                    359:
                    360:        { .name = "status-left-fg",
                    361:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      362:          .default_num = 8,
                    363:          .style = "status-left-style"
1.1       nicm      364:        },
                    365:
                    366:        { .name = "status-left-length",
                    367:          .type = OPTIONS_TABLE_NUMBER,
                    368:          .minimum = 0,
                    369:          .maximum = SHRT_MAX,
                    370:          .default_num = 10
1.20      nicm      371:        },
                    372:
1.43      nicm      373:        { .name = "status-left-style",
                    374:          .type = OPTIONS_TABLE_STYLE,
                    375:          .default_str = "default"
                    376:        },
                    377:
1.20      nicm      378:        { .name = "status-position",
                    379:          .type = OPTIONS_TABLE_CHOICE,
                    380:          .choices = options_table_status_position_list,
                    381:          .default_num = 1
1.1       nicm      382:        },
                    383:
                    384:        { .name = "status-right",
                    385:          .type = OPTIONS_TABLE_STRING,
1.52      sthen     386:          .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
1.1       nicm      387:        },
                    388:
                    389:        { .name = "status-right-attr",
                    390:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      391:          .default_num = 0,
                    392:          .style = "status-right-style"
1.1       nicm      393:        },
                    394:
                    395:        { .name = "status-right-bg",
                    396:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      397:          .default_num = 8,
                    398:          .style = "status-right-style"
1.1       nicm      399:        },
                    400:
                    401:        { .name = "status-right-fg",
                    402:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      403:          .default_num = 8,
                    404:          .style = "status-right-style"
1.1       nicm      405:        },
                    406:
                    407:        { .name = "status-right-length",
                    408:          .type = OPTIONS_TABLE_NUMBER,
                    409:          .minimum = 0,
                    410:          .maximum = SHRT_MAX,
                    411:          .default_num = 40
                    412:        },
                    413:
1.43      nicm      414:        { .name = "status-right-style",
                    415:          .type = OPTIONS_TABLE_STYLE,
                    416:          .default_str = "default"
                    417:        },
                    418:
                    419:        { .name = "status-style",
                    420:          .type = OPTIONS_TABLE_STYLE,
                    421:          .default_str = "bg=green,fg=black"
                    422:        },
                    423:
1.1       nicm      424:        { .name = "status-utf8",
                    425:          .type = OPTIONS_TABLE_FLAG,
                    426:          .default_num = 0 /* overridden in main() */
                    427:        },
                    428:
                    429:        { .name = "update-environment",
                    430:          .type = OPTIONS_TABLE_STRING,
                    431:          .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
1.9       nicm      432:                         "SSH_CONNECTION WINDOWID XAUTHORITY"
1.1       nicm      433:
                    434:        },
                    435:
                    436:        { .name = "visual-activity",
                    437:          .type = OPTIONS_TABLE_FLAG,
                    438:          .default_num = 0
                    439:        },
                    440:
                    441:        { .name = "visual-bell",
                    442:          .type = OPTIONS_TABLE_FLAG,
                    443:          .default_num = 0
                    444:        },
                    445:
                    446:        { .name = "visual-silence",
                    447:          .type = OPTIONS_TABLE_FLAG,
                    448:          .default_num = 0
                    449:        },
                    450:
1.16      nicm      451:        { .name = "word-separators",
                    452:          .type = OPTIONS_TABLE_STRING,
                    453:          .default_str = " -_@"
                    454:        },
                    455:
1.1       nicm      456:        { .name = NULL }
                    457: };
                    458:
                    459: /* Window options. */
                    460: const struct options_table_entry window_options_table[] = {
                    461:        { .name = "aggressive-resize",
                    462:          .type = OPTIONS_TABLE_FLAG,
                    463:          .default_num = 0
1.17      nicm      464:        },
                    465:
                    466:        { .name = "allow-rename",
                    467:          .type = OPTIONS_TABLE_FLAG,
                    468:          .default_num = 1
1.1       nicm      469:        },
                    470:
                    471:        { .name = "alternate-screen",
                    472:          .type = OPTIONS_TABLE_FLAG,
                    473:          .default_num = 1
                    474:        },
                    475:
                    476:        { .name = "automatic-rename",
                    477:          .type = OPTIONS_TABLE_FLAG,
                    478:          .default_num = 1
1.41      nicm      479:        },
                    480:
                    481:        { .name = "automatic-rename-format",
                    482:          .type = OPTIONS_TABLE_STRING,
1.50      nicm      483:          .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}"
                    484:                         "#{?pane_dead,[dead],}"
1.1       nicm      485:        },
                    486:
                    487:        { .name = "clock-mode-colour",
                    488:          .type = OPTIONS_TABLE_COLOUR,
                    489:          .default_num = 4
                    490:        },
                    491:
                    492:        { .name = "clock-mode-style",
                    493:          .type = OPTIONS_TABLE_CHOICE,
                    494:          .choices = options_table_clock_mode_style_list,
                    495:          .default_num = 1
                    496:        },
                    497:
                    498:        { .name = "force-height",
                    499:          .type = OPTIONS_TABLE_NUMBER,
                    500:          .minimum = 0,
                    501:          .maximum = INT_MAX,
                    502:          .default_num = 0
                    503:        },
                    504:
                    505:        { .name = "force-width",
                    506:          .type = OPTIONS_TABLE_NUMBER,
                    507:          .minimum = 0,
                    508:          .maximum = INT_MAX,
                    509:          .default_num = 0
                    510:        },
                    511:
                    512:        { .name = "main-pane-height",
                    513:          .type = OPTIONS_TABLE_NUMBER,
                    514:          .minimum = 1,
                    515:          .maximum = INT_MAX,
                    516:          .default_num = 24
                    517:        },
                    518:
                    519:        { .name = "main-pane-width",
                    520:          .type = OPTIONS_TABLE_NUMBER,
                    521:          .minimum = 1,
                    522:          .maximum = INT_MAX,
                    523:          .default_num = 80
                    524:        },
                    525:
                    526:        { .name = "mode-attr",
                    527:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      528:          .default_num = 0,
                    529:          .style = "mode-style"
1.1       nicm      530:        },
                    531:
                    532:        { .name = "mode-bg",
                    533:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      534:          .default_num = 3,
                    535:          .style = "mode-style"
1.1       nicm      536:        },
                    537:
                    538:        { .name = "mode-fg",
                    539:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      540:          .default_num = 0,
                    541:          .style = "mode-style"
1.1       nicm      542:        },
                    543:
                    544:        { .name = "mode-keys",
                    545:          .type = OPTIONS_TABLE_CHOICE,
                    546:          .choices = options_table_mode_keys_list,
                    547:          .default_num = MODEKEY_EMACS
                    548:        },
                    549:
1.43      nicm      550:        { .name = "mode-style",
                    551:          .type = OPTIONS_TABLE_STYLE,
                    552:          .default_str = "bg=yellow,fg=black"
                    553:        },
                    554:
1.1       nicm      555:        { .name = "monitor-activity",
                    556:          .type = OPTIONS_TABLE_FLAG,
                    557:          .default_num = 0
                    558:        },
                    559:
                    560:        { .name = "monitor-silence",
                    561:          .type = OPTIONS_TABLE_NUMBER,
                    562:          .minimum = 0,
                    563:          .maximum = INT_MAX,
                    564:          .default_num = 0
                    565:        },
                    566:
                    567:        { .name = "other-pane-height",
                    568:          .type = OPTIONS_TABLE_NUMBER,
                    569:          .minimum = 0,
                    570:          .maximum = INT_MAX,
                    571:          .default_num = 0
                    572:        },
                    573:
                    574:        { .name = "other-pane-width",
                    575:          .type = OPTIONS_TABLE_NUMBER,
                    576:          .minimum = 0,
                    577:          .maximum = INT_MAX,
1.13      nicm      578:          .default_num = 0
                    579:        },
                    580:
1.53      nicm      581:        { .name = "pane-active-border-bg",
                    582:          .type = OPTIONS_TABLE_COLOUR,
                    583:          .default_num = 8,
                    584:          .style = "pane-active-border-style"
                    585:        },
                    586:
                    587:        { .name = "pane-active-border-fg",
                    588:          .type = OPTIONS_TABLE_COLOUR,
                    589:          .default_num = 2,
                    590:          .style = "pane-active-border-style"
                    591:        },
                    592:
                    593:        { .name = "pane-active-border-style",
                    594:          .type = OPTIONS_TABLE_STYLE,
                    595:          .default_str = "fg=green"
                    596:        },
                    597:
1.13      nicm      598:        { .name = "pane-base-index",
                    599:          .type = OPTIONS_TABLE_NUMBER,
                    600:          .minimum = 0,
                    601:          .maximum = USHRT_MAX,
1.22      nicm      602:          .default_num = 0
1.53      nicm      603:        },
                    604:
                    605:        { .name = "pane-border-bg",
                    606:          .type = OPTIONS_TABLE_COLOUR,
                    607:          .default_num = 8,
                    608:          .style = "pane-border-style"
                    609:        },
                    610:
                    611:        { .name = "pane-border-fg",
                    612:          .type = OPTIONS_TABLE_COLOUR,
                    613:          .default_num = 8,
                    614:          .style = "pane-border-style"
                    615:        },
                    616:
                    617:        { .name = "pane-border-style",
                    618:          .type = OPTIONS_TABLE_STYLE,
                    619:          .default_str = "default"
1.22      nicm      620:        },
                    621:
1.1       nicm      622:        { .name = "remain-on-exit",
                    623:          .type = OPTIONS_TABLE_FLAG,
                    624:          .default_num = 0
                    625:        },
                    626:
                    627:        { .name = "synchronize-panes",
                    628:          .type = OPTIONS_TABLE_FLAG,
                    629:          .default_num = 0
                    630:        },
                    631:
                    632:        { .name = "utf8",
                    633:          .type = OPTIONS_TABLE_FLAG,
                    634:          .default_num = 0 /* overridden in main() */
1.54      nicm      635:        },
                    636:
                    637:        { .name = "window-active-style",
                    638:          .type = OPTIONS_TABLE_STYLE,
                    639:          .default_str = "default"
                    640:        },
                    641:
                    642:        { .name = "window-style",
                    643:          .type = OPTIONS_TABLE_STYLE,
                    644:          .default_str = "default"
1.1       nicm      645:        },
                    646:
1.21      nicm      647:        { .name = "window-status-activity-attr",
1.1       nicm      648:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      649:          .default_num = GRID_ATTR_REVERSE,
                    650:          .style = "window-status-activity-style"
1.1       nicm      651:        },
                    652:
1.21      nicm      653:        { .name = "window-status-activity-bg",
1.1       nicm      654:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      655:          .default_num = 8,
                    656:          .style = "window-status-activity-style"
1.1       nicm      657:        },
                    658:
1.21      nicm      659:        { .name = "window-status-activity-fg",
1.18      nicm      660:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      661:          .default_num = 8,
                    662:          .style = "window-status-activity-style"
                    663:        },
                    664:
                    665:        { .name = "window-status-activity-style",
                    666:          .type = OPTIONS_TABLE_STYLE,
                    667:          .default_str = "reverse"
                    668:        },
                    669:
                    670:        { .name = "window-status-attr",
                    671:          .type = OPTIONS_TABLE_ATTRIBUTES,
                    672:          .default_num = 0,
                    673:          .style = "window-status-style"
1.18      nicm      674:        },
                    675:
1.21      nicm      676:        { .name = "window-status-bell-attr",
1.18      nicm      677:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      678:          .default_num = GRID_ATTR_REVERSE,
                    679:          .style = "window-status-bell-style"
1.18      nicm      680:        },
                    681:
1.21      nicm      682:        { .name = "window-status-bell-bg",
1.18      nicm      683:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      684:          .default_num = 8,
                    685:          .style = "window-status-bell-style"
1.18      nicm      686:        },
                    687:
1.21      nicm      688:        { .name = "window-status-bell-fg",
1.18      nicm      689:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      690:          .default_num = 8,
                    691:          .style = "window-status-bell-style"
                    692:        },
                    693:
                    694:        { .name = "window-status-bell-style",
                    695:          .type = OPTIONS_TABLE_STYLE,
                    696:          .default_str = "reverse"
                    697:        },
                    698:
                    699:        { .name = "window-status-bg",
                    700:          .type = OPTIONS_TABLE_COLOUR,
                    701:          .default_num = 8,
                    702:          .style = "window-status-style"
1.1       nicm      703:        },
                    704:
                    705:        { .name = "window-status-current-attr",
                    706:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      707:          .default_num = 0,
                    708:          .style = "window-status-current-style"
1.1       nicm      709:        },
                    710:
                    711:        { .name = "window-status-current-bg",
                    712:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      713:          .default_num = 8,
                    714:          .style = "window-status-current-style"
1.1       nicm      715:        },
                    716:
                    717:        { .name = "window-status-current-fg",
                    718:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      719:          .default_num = 8,
                    720:          .style = "window-status-current-style"
1.1       nicm      721:        },
                    722:
                    723:        { .name = "window-status-current-format",
                    724:          .type = OPTIONS_TABLE_STRING,
1.57      nicm      725:          .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.30      nicm      726:        },
                    727:
1.43      nicm      728:        { .name = "window-status-current-style",
                    729:          .type = OPTIONS_TABLE_STYLE,
                    730:          .default_str = "default"
                    731:        },
                    732:
                    733:        { .name = "window-status-fg",
                    734:          .type = OPTIONS_TABLE_COLOUR,
                    735:          .default_num = 8,
                    736:          .style = "window-status-style"
                    737:        },
                    738:
                    739:        { .name = "window-status-format",
                    740:          .type = OPTIONS_TABLE_STRING,
1.57      nicm      741:          .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
1.43      nicm      742:        },
                    743:
1.30      nicm      744:        { .name = "window-status-last-attr",
                    745:          .type = OPTIONS_TABLE_ATTRIBUTES,
1.43      nicm      746:          .default_num = 0,
                    747:          .style = "window-status-last-style"
1.30      nicm      748:        },
                    749:
                    750:        { .name = "window-status-last-bg",
                    751:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      752:          .default_num = 8,
                    753:          .style = "window-status-last-style"
1.30      nicm      754:        },
                    755:
                    756:        { .name = "window-status-last-fg",
                    757:          .type = OPTIONS_TABLE_COLOUR,
1.43      nicm      758:          .default_num = 8,
                    759:          .style = "window-status-last-style"
1.1       nicm      760:        },
                    761:
1.43      nicm      762:        { .name = "window-status-last-style",
                    763:          .type = OPTIONS_TABLE_STYLE,
                    764:          .default_str = "default"
1.1       nicm      765:        },
                    766:
1.43      nicm      767:        { .name = "window-status-separator",
1.1       nicm      768:          .type = OPTIONS_TABLE_STRING,
1.43      nicm      769:          .default_str = " "
1.28      nicm      770:        },
                    771:
1.43      nicm      772:        { .name = "window-status-style",
                    773:          .type = OPTIONS_TABLE_STYLE,
                    774:          .default_str = "default"
1.24      nicm      775:        },
                    776:
                    777:        { .name = "wrap-search",
                    778:          .type = OPTIONS_TABLE_FLAG,
                    779:          .default_num = 1
1.1       nicm      780:        },
                    781:
                    782:        { .name = "xterm-keys",
                    783:          .type = OPTIONS_TABLE_FLAG,
                    784:          .default_num = 0
                    785:        },
                    786:
                    787:        { .name = NULL }
                    788: };
                    789:
                    790: /* Populate an options tree from a table. */
                    791: void
                    792: options_table_populate_tree(
                    793:     const struct options_table_entry *table, struct options *oo)
                    794: {
                    795:        const struct options_table_entry        *oe;
                    796:
                    797:        for (oe = table; oe->name != NULL; oe++) {
1.43      nicm      798:                switch (oe->type) {
                    799:                case OPTIONS_TABLE_STRING:
1.1       nicm      800:                        options_set_string(oo, oe->name, "%s", oe->default_str);
1.43      nicm      801:                        break;
                    802:                case OPTIONS_TABLE_STYLE:
1.44      nicm      803:                        options_set_style(oo, oe->name, oe->default_str, 0);
1.43      nicm      804:                        break;
                    805:                default:
1.1       nicm      806:                        options_set_number(oo, oe->name, oe->default_num);
1.43      nicm      807:                        break;
                    808:                }
1.1       nicm      809:        }
                    810: }
                    811:
                    812: /* Print an option using its type from the table. */
                    813: const char *
1.33      nicm      814: options_table_print_entry(const struct options_table_entry *oe,
                    815:     struct options_entry *o, int no_quotes)
1.1       nicm      816: {
1.19      nicm      817:        static char      out[BUFSIZ];
                    818:        const char      *s;
1.1       nicm      819:
                    820:        *out = '\0';
                    821:        switch (oe->type) {
                    822:        case OPTIONS_TABLE_STRING:
1.33      nicm      823:                if (no_quotes)
                    824:                        xsnprintf(out, sizeof out, "%s", o->str);
                    825:                else
                    826:                        xsnprintf(out, sizeof out, "\"%s\"", o->str);
1.1       nicm      827:                break;
                    828:        case OPTIONS_TABLE_NUMBER:
                    829:                xsnprintf(out, sizeof out, "%lld", o->num);
                    830:                break;
1.19      nicm      831:        case OPTIONS_TABLE_KEY:
1.33      nicm      832:                xsnprintf(out, sizeof out, "%s",
                    833:                    key_string_lookup_key(o->num));
1.1       nicm      834:                break;
                    835:        case OPTIONS_TABLE_COLOUR:
                    836:                s = colour_tostring(o->num);
                    837:                xsnprintf(out, sizeof out, "%s", s);
                    838:                break;
                    839:        case OPTIONS_TABLE_ATTRIBUTES:
                    840:                s = attributes_tostring(o->num);
                    841:                xsnprintf(out, sizeof out, "%s", s);
                    842:                break;
                    843:        case OPTIONS_TABLE_FLAG:
                    844:                if (o->num)
                    845:                        strlcpy(out, "on", sizeof out);
                    846:                else
                    847:                        strlcpy(out, "off", sizeof out);
                    848:                break;
                    849:        case OPTIONS_TABLE_CHOICE:
                    850:                s = oe->choices[o->num];
1.43      nicm      851:                xsnprintf(out, sizeof out, "%s", s);
                    852:                break;
                    853:        case OPTIONS_TABLE_STYLE:
                    854:                s = style_tostring(&o->style);
1.1       nicm      855:                xsnprintf(out, sizeof out, "%s", s);
                    856:                break;
                    857:        }
                    858:        return (out);
1.22      nicm      859: }
                    860:
                    861: /* Find an option. */
                    862: int
                    863: options_table_find(
                    864:     const char *optstr, const struct options_table_entry **table,
                    865:     const struct options_table_entry **oe)
                    866: {
                    867:        static const struct options_table_entry *tables[] = {
                    868:                server_options_table,
                    869:                window_options_table,
                    870:                session_options_table
                    871:        };
                    872:        const struct options_table_entry        *oe_loop;
                    873:        u_int                                    i;
                    874:
                    875:        for (i = 0; i < nitems(tables); i++) {
                    876:                for (oe_loop = tables[i]; oe_loop->name != NULL; oe_loop++) {
                    877:                        if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
                    878:                                continue;
                    879:
                    880:                        /* If already found, ambiguous. */
                    881:                        if (*oe != NULL)
                    882:                                return (-1);
                    883:                        *oe = oe_loop;
                    884:                        *table = tables[i];
                    885:
                    886:                        /* Bail now if an exact match. */
                    887:                        if (strcmp((*oe)->name, optstr) == 0)
                    888:                                break;
                    889:                }
                    890:        }
                    891:        return (0);
1.1       nicm      892: }