diff options
author | nicm <nicm> | 2017-01-15 20:48:41 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-01-15 20:48:41 +0000 |
commit | 2b0bc9f1c5f546e822009c231a1bb0e1a2d6711a (patch) | |
tree | 72b8863580fcb241669d1ad299ea68cfca53e23e /tmux.c | |
parent | 404214b0ac99ca5e8b7599995e339857f893cb11 (diff) | |
download | rtmux-2b0bc9f1c5f546e822009c231a1bb0e1a2d6711a.tar.gz rtmux-2b0bc9f1c5f546e822009c231a1bb0e1a2d6711a.tar.bz2 rtmux-2b0bc9f1c5f546e822009c231a1bb0e1a2d6711a.zip |
Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more
closely to the options table rather than having an unnecessary
split. Also add support for array options (will be used later). Only
(intentional) user visible change is that show-options output is now
passed through vis(3) with VIS_DQ so quotes are escaped.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -188,9 +188,11 @@ find_home(void) int main(int argc, char **argv) { - char *path, *label, **var, tmp[PATH_MAX], *shellcmd = NULL; - const char *s; - int opt, flags, keys; + char *path, *label, tmp[PATH_MAX]; + char *shellcmd = NULL, **var; + const char *s, *shell; + int opt, flags, keys; + const struct options_table_entry *oe; if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) { if (setlocale(LC_CTYPE, "") == NULL) @@ -291,15 +293,23 @@ main(int argc, char **argv) environ_set(global_environ, "PWD", "%s", tmp); global_options = options_create(NULL); - options_table_populate_tree(OPTIONS_TABLE_SERVER, global_options); - global_s_options = options_create(NULL); - options_table_populate_tree(OPTIONS_TABLE_SESSION, global_s_options); - options_set_string(global_s_options, "default-shell", 0, "%s", - getshell()); - global_w_options = options_create(NULL); - options_table_populate_tree(OPTIONS_TABLE_WINDOW, global_w_options); + for (oe = options_table; oe->name != NULL; oe++) { + if (oe->scope == OPTIONS_TABLE_SERVER) + options_default(global_options, oe); + if (oe->scope == OPTIONS_TABLE_SESSION) + options_default(global_s_options, oe); + if (oe->scope == OPTIONS_TABLE_WINDOW) + options_default(global_w_options, oe); + } + + /* + * The default shell comes from SHELL or from the user's passwd entry + * if available. + */ + shell = getshell(); + options_set_string(global_s_options, "default-shell", 0, "%s", shell); /* Override keys to vi if VISUAL or EDITOR are set. */ if ((s = getenv("VISUAL")) != NULL || (s = getenv("EDITOR")) != NULL) { |