12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- /* $OpenBSD$ */
- /*
- * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
- * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
- #include <sys/types.h>
- #include <string.h>
- #include "tmux.h"
- /*
- * This file has a tables with all the server, session and window
- * options. These tables are the master copy of the options with their real
- * (user-visible) types, range limits and default values. At start these are
- * copied into the runtime global options trees (which only has number and
- * string types). These tables are then used to look up the real type when the
- * user sets an option or its value needs to be shown.
- */
- /* Choice option type lists. */
- const char *options_table_mode_keys_list[] = {
- "emacs", "vi", NULL
- };
- const char *options_table_clock_mode_style_list[] = {
- "12", "24", NULL
- };
- const char *options_table_status_keys_list[] = {
- "emacs", "vi", NULL
- };
- const char *options_table_status_justify_list[] = {
- "left", "centre", "right", NULL
- };
- const char *options_table_status_position_list[] = {
- "top", "bottom", NULL
- };
- const char *options_table_bell_action_list[] = {
- "none", "any", "current", "other", NULL
- };
- /* Server options. */
- const struct options_table_entry options_table[] = {
- { .name = "buffer-limit",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SERVER,
- .minimum = 1,
- .maximum = INT_MAX,
- .default_num = 20
- },
- { .name = "default-terminal",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- #ifdef TMATE
- .default_str = "screen-256color"
- #else
- .default_str = "screen"
- #endif
- },
- { .name = "escape-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SERVER,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 500
- },
- { .name = "exit-unattached",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SERVER,
- .default_num = 0
- },
- { .name = "focus-events",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SERVER,
- .default_num = 0
- },
- { .name = "history-file",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = ""
- },
- { .name = "message-limit",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SERVER,
- .minimum = 0,
- .maximum = INT_MAX,
- #ifdef TMATE
- .default_num = 500
- #else
- .default_num = 100
- #endif
- },
- { .name = "quiet",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SERVER,
- .default_num = 0
- },
- { .name = "set-clipboard",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SERVER,
- .default_num = 1
- },
- { .name = "terminal-overrides",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = "xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
- ":Cs=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
- ":Ss=\\E[%p1%d q:Se=\\E[2 q,screen*:XT"
- },
- { .name = "assume-paste-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 1,
- },
- { .name = "base-index",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "bell-action",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_SESSION,
- .choices = options_table_bell_action_list,
- .default_num = BELL_ANY
- },
- { .name = "bell-on-alert",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "default-command",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = ""
- },
- { .name = "default-shell",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = _PATH_BSHELL
- },
- { .name = "destroy-unattached",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "detach-on-destroy",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 1
- },
- { .name = "display-panes-active-colour",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 1
- },
- { .name = "display-panes-colour",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 4
- },
- { .name = "display-panes-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 1,
- .maximum = INT_MAX,
- .default_num = 1000
- },
- { .name = "display-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 750
- },
- { .name = "history-limit",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 2000
- },
- { .name = "key-table",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "root"
- },
- { .name = "lock-after-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "lock-command",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "lock -np"
- },
- { .name = "message-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "message-style"
- },
- { .name = "message-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 3,
- .style = "message-style"
- },
- { .name = "message-command-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "message-command-style"
- },
- { .name = "message-command-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "message-command-style"
- },
- { .name = "message-command-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 3,
- .style = "message-command-style"
- },
- { .name = "message-command-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "bg=black,fg=yellow"
- },
- { .name = "message-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "message-style"
- },
- { .name = "message-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "bg=yellow,fg=black"
- },
- { .name = "mouse",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "prefix",
- .type = OPTIONS_TABLE_KEY,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = '\002',
- },
- { .name = "prefix2",
- .type = OPTIONS_TABLE_KEY,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = KEYC_NONE,
- },
- { .name = "renumber-windows",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "repeat-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = SHRT_MAX,
- .default_num = 500
- },
- { .name = "set-remain-on-exit",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "set-titles",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "set-titles-string",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "#S:#I:#W - \"#T\" #{session_alerts}"
- },
- { .name = "status",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 1
- },
- { .name = "status-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "status-style"
- },
- { .name = "status-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 2,
- .style = "status-style"
- },
- { .name = "status-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "status-style"
- },
- { .name = "status-interval",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 15
- },
- { .name = "status-justify",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_SESSION,
- .choices = options_table_status_justify_list,
- .default_num = 0
- },
- { .name = "status-keys",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_SESSION,
- .choices = options_table_status_keys_list,
- .default_num = MODEKEY_EMACS
- },
- { .name = "status-left",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "[#S] "
- },
- { .name = "status-left-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "status-left-style"
- },
- { .name = "status-left-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 8,
- .style = "status-left-style"
- },
- { .name = "status-left-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 8,
- .style = "status-left-style"
- },
- { .name = "status-left-length",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = SHRT_MAX,
- .default_num = 10
- },
- { .name = "status-left-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "default"
- },
- { .name = "status-position",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_SESSION,
- .choices = options_table_status_position_list,
- .default_num = 1
- },
- { .name = "status-right",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
- },
- { .name = "status-right-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0,
- .style = "status-right-style"
- },
- { .name = "status-right-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 8,
- .style = "status-right-style"
- },
- { .name = "status-right-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 8,
- .style = "status-right-style"
- },
- { .name = "status-right-length",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 0,
- .maximum = SHRT_MAX,
- .default_num = 40
- },
- { .name = "status-right-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "default"
- },
- { .name = "status-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "bg=green,fg=black"
- },
- { .name = "update-environment",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = "DISPLAY SSH_ASKPASS SSH_AUTH_SOCK SSH_AGENT_PID "
- "SSH_CONNECTION WINDOWID XAUTHORITY"
- },
- { .name = "visual-activity",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "visual-bell",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "visual-silence",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_SESSION,
- .default_num = 0
- },
- { .name = "word-separators",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SESSION,
- .default_str = " -_@"
- },
- { .name = "aggressive-resize",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0
- },
- { .name = "allow-rename",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 1
- },
- { .name = "alternate-screen",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 1
- },
- { .name = "automatic-rename",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 1
- },
- { .name = "automatic-rename-format",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "#{?pane_in_mode,[tmux],#{pane_current_command}}"
- "#{?pane_dead,[dead],}"
- },
- { .name = "clock-mode-colour",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 4
- },
- { .name = "clock-mode-style",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_WINDOW,
- .choices = options_table_clock_mode_style_list,
- .default_num = 1
- },
- { .name = "force-height",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "force-width",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "main-pane-height",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 1,
- .maximum = INT_MAX,
- .default_num = 24
- },
- { .name = "main-pane-width",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 1,
- .maximum = INT_MAX,
- .default_num = 80
- },
- { .name = "mode-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0,
- .style = "mode-style"
- },
- { .name = "mode-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 3,
- .style = "mode-style"
- },
- { .name = "mode-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0,
- .style = "mode-style"
- },
- { .name = "mode-keys",
- .type = OPTIONS_TABLE_CHOICE,
- .scope = OPTIONS_TABLE_WINDOW,
- .choices = options_table_mode_keys_list,
- .default_num = MODEKEY_EMACS
- },
- { .name = "mode-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "bg=yellow,fg=black"
- },
- { .name = "monitor-activity",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0
- },
- { .name = "monitor-silence",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "other-pane-height",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "other-pane-width",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = INT_MAX,
- .default_num = 0
- },
- { .name = "pane-active-border-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "pane-active-border-style"
- },
- { .name = "pane-active-border-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 2,
- .style = "pane-active-border-style"
- },
- { .name = "pane-active-border-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "fg=green"
- },
- { .name = "pane-base-index",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_WINDOW,
- .minimum = 0,
- .maximum = USHRT_MAX,
- .default_num = 0
- },
- { .name = "pane-border-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "pane-border-style"
- },
- { .name = "pane-border-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "pane-border-style"
- },
- { .name = "pane-border-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "remain-on-exit",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0
- },
- { .name = "synchronize-panes",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0
- },
- { .name = "window-active-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "window-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "window-status-activity-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = GRID_ATTR_REVERSE,
- .style = "window-status-activity-style"
- },
- { .name = "window-status-activity-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-activity-style"
- },
- { .name = "window-status-activity-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-activity-style"
- },
- { .name = "window-status-activity-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "reverse"
- },
- { .name = "window-status-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0,
- .style = "window-status-style"
- },
- { .name = "window-status-bell-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = GRID_ATTR_REVERSE,
- .style = "window-status-bell-style"
- },
- { .name = "window-status-bell-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-bell-style"
- },
- { .name = "window-status-bell-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-bell-style"
- },
- { .name = "window-status-bell-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "reverse"
- },
- { .name = "window-status-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-style"
- },
- { .name = "window-status-current-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0,
- .style = "window-status-current-style"
- },
- { .name = "window-status-current-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-current-style"
- },
- { .name = "window-status-current-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-current-style"
- },
- { .name = "window-status-current-format",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
- },
- { .name = "window-status-current-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "window-status-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-style"
- },
- { .name = "window-status-format",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
- },
- { .name = "window-status-last-attr",
- .type = OPTIONS_TABLE_ATTRIBUTES,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0,
- .style = "window-status-last-style"
- },
- { .name = "window-status-last-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-last-style"
- },
- { .name = "window-status-last-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 8,
- .style = "window-status-last-style"
- },
- { .name = "window-status-last-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "window-status-separator",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = " "
- },
- { .name = "window-status-style",
- .type = OPTIONS_TABLE_STYLE,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_str = "default"
- },
- { .name = "wrap-search",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 1
- },
- { .name = "xterm-keys",
- .type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
- .default_num = 0
- },
- #ifdef TMATE
- { .name = "tmate-identity",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = ""
- },
- { .name = "tmate-server-host",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = "ssh.tmate.io"
- },
- { .name = "tmate-server-port",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SERVER,
- .minimum = 1,
- .maximum = 65535,
- .default_num = 22
- },
- { .name = "tmate-server-dsa-fingerprint",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = "obsolete"
- },
- { .name = "tmate-server-rsa-fingerprint",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = "af:2d:81:c1:fe:49:70:2d:7f:09:a9:d7:4b:32:e3:be"
- },
- { .name = "tmate-server-ecdsa-fingerprint",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = "c7:a1:51:36:d2:bb:35:4b:0a:1a:c0:43:97:74:ea:42"
- },
- { .name = "tmate-display-time",
- .type = OPTIONS_TABLE_NUMBER,
- .scope = OPTIONS_TABLE_SESSION,
- .minimum = 1,
- .maximum = INT_MAX,
- .default_num = 15000
- },
- { .name = "tmate-webhook-userdata",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = ""
- },
- { .name = "tmate-webhook-url",
- .type = OPTIONS_TABLE_STRING,
- .scope = OPTIONS_TABLE_SERVER,
- .default_str = ""
- },
- #endif
- { .name = NULL }
- };
- /* Populate an options tree from a table. */
- void
- options_table_populate_tree(enum options_table_scope scope, struct options *oo)
- {
- const struct options_table_entry *oe;
- for (oe = options_table; oe->name != NULL; oe++) {
- if (oe->scope == OPTIONS_TABLE_NONE)
- fatalx("no scope for %s", oe->name);
- if (oe->scope != scope)
- continue;
- switch (oe->type) {
- case OPTIONS_TABLE_STRING:
- options_set_string(oo, oe->name, "%s", oe->default_str);
- break;
- case OPTIONS_TABLE_STYLE:
- options_set_style(oo, oe->name, oe->default_str, 0);
- break;
- default:
- options_set_number(oo, oe->name, oe->default_num);
- break;
- }
- }
- }
- /* Print an option using its type from the table. */
- const char *
- options_table_print_entry(const struct options_table_entry *oe,
- struct options_entry *o, int no_quotes)
- {
- static char out[BUFSIZ];
- const char *s;
- *out = '\0';
- switch (oe->type) {
- case OPTIONS_TABLE_STRING:
- if (no_quotes)
- xsnprintf(out, sizeof out, "%s", o->str);
- else
- xsnprintf(out, sizeof out, "\"%s\"", o->str);
- break;
- case OPTIONS_TABLE_NUMBER:
- xsnprintf(out, sizeof out, "%lld", o->num);
- break;
- case OPTIONS_TABLE_KEY:
- xsnprintf(out, sizeof out, "%s",
- key_string_lookup_key(o->num));
- break;
- case OPTIONS_TABLE_COLOUR:
- s = colour_tostring(o->num);
- xsnprintf(out, sizeof out, "%s", s);
- break;
- case OPTIONS_TABLE_ATTRIBUTES:
- s = attributes_tostring(o->num);
- xsnprintf(out, sizeof out, "%s", s);
- break;
- case OPTIONS_TABLE_FLAG:
- if (o->num)
- strlcpy(out, "on", sizeof out);
- else
- strlcpy(out, "off", sizeof out);
- break;
- case OPTIONS_TABLE_CHOICE:
- s = oe->choices[o->num];
- xsnprintf(out, sizeof out, "%s", s);
- break;
- case OPTIONS_TABLE_STYLE:
- s = style_tostring(&o->style);
- xsnprintf(out, sizeof out, "%s", s);
- break;
- }
- return (out);
- }
- /* Find an option. */
- int
- options_table_find(const char *optstr, const struct options_table_entry **oe)
- {
- const struct options_table_entry *oe_loop;
- for (oe_loop = options_table; oe_loop->name != NULL; oe_loop++) {
- if (strncmp(oe_loop->name, optstr, strlen(optstr)) != 0)
- continue;
- /* If already found, ambiguous. */
- if (*oe != NULL)
- return (-1);
- *oe = oe_loop;
- /* Bail now if an exact match. */
- if (strcmp(oe_loop->name, optstr) == 0)
- break;
- }
- return (0);
- }
|