MCPcopy Create free account
hub / github.com/NetHack/NetHack / optfn_windowcolors

Function optfn_windowcolors

src/options.c:4893–4940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4891int wcolors_opt[WC_COUNT];
4892
4893staticfn int
4894optfn_windowcolors(
4895 int optidx, int req,
4896 boolean negated UNUSED,
4897 char *opts, char *op)
4898{
4899 int wccount;
4900
4901 if (req == do_init) {
4902 for (wccount = 0; wccount < WC_COUNT; ++wccount) {
4903 wcolors_opt[wccount] = 0;
4904 }
4905 return optn_ok;
4906 }
4907 if (req == do_set) {
4908 /* WINCAP
4909 * setting window colors
4910 * syntax: windowcolors=menu foregrnd/backgrnd text foregrnd/backgrnd
4911 */
4912 if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
4913 if (!wc_set_window_colors(op)) {
4914 config_error_add("Could not set %s '%s'", allopt[optidx].name,
4915 op);
4916 return optn_err;
4917 }
4918 }
4919 return optn_ok;
4920 }
4921 if (req == get_val || req == get_cnf_val) {
4922 const char *fg, *bg;
4923
4924 /* TODO: wide 'get_val' may need to be wrapped in the menu display */
4925 opts[0] = '\0';
4926 for (wccount = 0; wccount < WC_COUNT; ++wccount) {
4927 fg = iflags.wcolors[wccount].fg;
4928 bg = iflags.wcolors[wccount].bg;
4929 if (fg && (!*fg || !strcmp(fg, defbrief)))
4930 fg = 0;
4931 if (bg && (!*bg || !strcmp(bg, defbrief)))
4932 bg = 0;
4933 Sprintf(eos(opts), "%s%s %s/%s", !wccount ? "" : " ",
4934 (fg || bg) ? wcnames[wccount] : wcshortnames[wccount],
4935 fg ? fg : defbrief, bg ? bg : defbrief);
4936 }
4937 return optn_ok;
4938 }
4939 return optn_ok;
4940}
4941
4942staticfn int
4943optfn_windowtype(

Callers

nothing calls this directly

Calls 4

string_for_optFunction · 0.85
wc_set_window_colorsFunction · 0.85
config_error_addFunction · 0.85
eosFunction · 0.85

Tested by

no test coverage detected