[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.46

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