version 1.49, 2019/06/20 07:41:29 |
version 1.50, 2019/06/20 11:59:59 |
|
|
|
|
if (oo->parent == NULL) |
if (oo->parent == NULL) |
fatalx("no parent options for %s", s); |
fatalx("no parent options for %s", s); |
o = options_get_only(oo->parent, s); |
o = options_get(oo->parent, s); |
if (o == NULL) |
if (o == NULL) |
fatalx("%s not in parent options", s); |
fatalx("%s not in parent options", s); |
return (o->tableentry); |
return (o->tableentry); |
|
|
free(oo); |
free(oo); |
} |
} |
|
|
|
void |
|
options_set_parent(struct options *oo, struct options *parent) |
|
{ |
|
oo->parent = parent; |
|
} |
|
|
struct options_entry * |
struct options_entry * |
options_first(struct options *oo) |
options_first(struct options *oo) |
{ |
{ |
|
|
} |
} |
|
|
char * |
char * |
options_match(const char *s, int *idx, int* ambiguous) |
options_match(const char *s, int *idx, int *ambiguous) |
{ |
{ |
const struct options_table_entry *oe, *found; |
const struct options_table_entry *oe, *found; |
char *name; |
char *name; |
|
|
return (o); |
return (o); |
} |
} |
|
|
enum options_table_scope |
int |
options_scope_from_name(struct args *args, int window, |
options_scope_from_name(struct args *args, int window, |
const char *name, struct cmd_find_state *fs, struct options **oo, |
const char *name, struct cmd_find_state *fs, struct options **oo, |
char **cause) |
char **cause) |
{ |
{ |
struct session *s = fs->s; |
struct session *s = fs->s; |
struct winlink *wl = fs->wl; |
struct winlink *wl = fs->wl; |
const char *target = args_get(args, 't'); |
struct window_pane *wp = fs->wp; |
enum options_table_scope scope; |
const char *target = args_get(args, 't'); |
|
const struct options_table_entry *oe; |
|
int scope; |
|
|
if (*name == '@') |
if (*name == '@') |
return (options_scope_from_flags(args, window, fs, oo, cause)); |
return (options_scope_from_flags(args, window, fs, oo, cause)); |
|
|
if (options_get_only(global_options, name) != NULL) |
for (oe = options_table; oe->name != NULL; oe++) { |
scope = OPTIONS_TABLE_SERVER; |
if (strcmp(oe->name, name) == 0) |
else if (options_get_only(global_s_options, name) != NULL) |
break; |
scope = OPTIONS_TABLE_SESSION; |
} |
else if (options_get_only(global_w_options, name) != NULL) |
if (oe->name == NULL) { |
scope = OPTIONS_TABLE_WINDOW; |
|
else { |
|
xasprintf(cause, "unknown option: %s", name); |
xasprintf(cause, "unknown option: %s", name); |
return (OPTIONS_TABLE_NONE); |
return (OPTIONS_TABLE_NONE); |
} |
} |
|
scope = oe->scope; |
|
|
if (scope == OPTIONS_TABLE_SERVER) |
switch (scope) { |
|
case OPTIONS_TABLE_SERVER: |
*oo = global_options; |
*oo = global_options; |
else if (scope == OPTIONS_TABLE_SESSION) { |
break; |
|
case OPTIONS_TABLE_SESSION: |
if (args_has(args, 'g')) |
if (args_has(args, 'g')) |
*oo = global_s_options; |
*oo = global_s_options; |
else if (s == NULL) { |
else if (s == NULL && target != NULL) |
if (target != NULL) |
xasprintf(cause, "no such session: %s", target); |
xasprintf(cause, "no such session: %s", target); |
else if (s == NULL) |
else |
xasprintf(cause, "no current session"); |
xasprintf(cause, "no current session"); |
else |
} else |
|
*oo = s->options; |
*oo = s->options; |
} else if (scope == OPTIONS_TABLE_WINDOW) { |
break; |
|
case OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE: |
|
if (args_has(args, 'p')) { |
|
if (wp == NULL && target != NULL) |
|
xasprintf(cause, "no such pane: %s", target); |
|
else if (wp == NULL) |
|
xasprintf(cause, "no current pane"); |
|
else |
|
*oo = wp->options; |
|
break; |
|
} |
|
scope = OPTIONS_TABLE_WINDOW; |
|
/* FALLTHROUGH */ |
|
case OPTIONS_TABLE_WINDOW: |
if (args_has(args, 'g')) |
if (args_has(args, 'g')) |
*oo = global_w_options; |
*oo = global_w_options; |
else if (wl == NULL) { |
else if (wl == NULL && target != NULL) |
if (target != NULL) |
xasprintf(cause, "no such window: %s", target); |
xasprintf(cause, "no such window: %s", target); |
else if (wl == NULL) |
else |
xasprintf(cause, "no current window"); |
xasprintf(cause, "no current window"); |
else |
} else |
|
*oo = wl->window->options; |
*oo = wl->window->options; |
|
break; |
} |
} |
return (scope); |
return (scope); |
} |
} |
|
|
enum options_table_scope |
int |
options_scope_from_flags(struct args *args, int window, |
options_scope_from_flags(struct args *args, int window, |
struct cmd_find_state *fs, struct options **oo, char **cause) |
struct cmd_find_state *fs, struct options **oo, char **cause) |
{ |
{ |
struct session *s = fs->s; |
struct session *s = fs->s; |
struct winlink *wl = fs->wl; |
struct winlink *wl = fs->wl; |
const char *target = args_get(args, 't'); |
struct window_pane *wp = fs->wp; |
|
const char *target = args_get(args, 't'); |
|
|
if (args_has(args, 's')) { |
if (args_has(args, 's')) { |
*oo = global_options; |
*oo = global_options; |
return (OPTIONS_TABLE_SERVER); |
return (OPTIONS_TABLE_SERVER); |
} |
} |
|
|
if (window || args_has(args, 'w')) { |
if (args_has(args, 'p')) { |
|
if (wp == NULL) { |
|
if (target != NULL) |
|
xasprintf(cause, "no such pane: %s", target); |
|
else |
|
xasprintf(cause, "no current pane"); |
|
return (OPTIONS_TABLE_NONE); |
|
} |
|
*oo = wp->options; |
|
return (OPTIONS_TABLE_PANE); |
|
} else if (window || args_has(args, 'w')) { |
if (args_has(args, 'g')) { |
if (args_has(args, 'g')) { |
*oo = global_w_options; |
*oo = global_w_options; |
return (OPTIONS_TABLE_WINDOW); |
return (OPTIONS_TABLE_WINDOW); |