From 649b7c132d3a83cc7e67742d38d9e74c5cfae9ac Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 22 Sep 2009 13:56:02 +0000 Subject: Sync OpenBSD patchset 339: Move common code from show-options and show-window-options into a function. --- options-cmd.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'options-cmd.c') diff --git a/options-cmd.c b/options-cmd.c index e328fea2..aba4b3c5 100644 --- a/options-cmd.c +++ b/options-cmd.c @@ -1,4 +1,4 @@ -/* $Id: options-cmd.c,v 1.5 2009-08-09 16:48:34 tcunha Exp $ */ +/* $Id: options-cmd.c,v 1.6 2009-09-22 13:56:02 tcunha Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -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) -- cgit