diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-09-21 14:46:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-09-21 14:46:47 +0000 |
commit | e3c3d746f7e78e5327627bed665a98e72d874774 (patch) | |
tree | 7c7990b3fa1efe4445fe45a52229ed6a9309fda1 /options-cmd.c | |
parent | b769aa59d35e9feed05610e63ee3bda1bdc5a66e (diff) | |
download | rtmux-e3c3d746f7e78e5327627bed665a98e72d874774.tar.gz rtmux-e3c3d746f7e78e5327627bed665a98e72d874774.tar.bz2 rtmux-e3c3d746f7e78e5327627bed665a98e72d874774.zip |
Move common code from show-options and show-window-options into a function.
Diffstat (limited to 'options-cmd.c')
-rw-r--r-- | options-cmd.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/options-cmd.c b/options-cmd.c index 4cdd75d0..0e41a62c 100644 --- a/options-cmd.c +++ b/options-cmd.c @@ -23,6 +23,46 @@ #include "tmux.h" +const char * +set_option_print(const struct set_option_entry *entry, struct options_entry *o) +{ + static char out[BUFSIZ]; + const char *s; + + *out = '\0'; + switch (entry->type) { + case SET_OPTION_STRING: + xsnprintf(out, sizeof out, "\"%s\"", o->str); + break; + case SET_OPTION_NUMBER: + xsnprintf(out, sizeof out, "%lld", o->num); + break; + case SET_OPTION_KEY: + s = key_string_lookup_key(o->num); + xsnprintf(out, sizeof out, "%s", s); + break; + case SET_OPTION_COLOUR: + s = colour_tostring(o->num); + xsnprintf(out, sizeof out, "%s", s); + break; + case SET_OPTION_ATTRIBUTES: + s = attributes_tostring(o->num); + xsnprintf(out, sizeof out, "%s", s); + break; + case SET_OPTION_FLAG: + if (o->num) + strlcpy(out, "on", sizeof out); + else + strlcpy(out, "off", sizeof out); + break; + case SET_OPTION_CHOICE: + s = entry->choices[o->num]; + xsnprintf(out, sizeof out, "%s", s); + break; + } + return (out); +} + void set_option_string(struct cmd_ctx *ctx, struct options *oo, const struct set_option_entry *entry, char *value, int append) |