From 2deb119ee0ed2f73444717d4a1f5fadd7a9f90a6 Mon Sep 17 00:00:00 2001 From: Patric Mueller Date: Wed, 24 Aug 2022 21:03:36 +0200 Subject: [PATCH] curses: implement a dialog for the windowborders option --- doc/fixes3-7-0.txt | 1 + include/optlist.h | 2 +- src/options.c | 45 +++++++++++++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 77c0a5399..b084e5a45 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1823,6 +1823,7 @@ curses: 'windowborders' can be set to 3 or 4 to suppress perm_invent borders curses: if panictrace is triggered, reset the terminal before giving backtrace curses: if a message is marked urgent, override message suppression initiated by user having typed ESC at previous More>> prompt +curses: implement a dialog for the windowborders option Qt: the "paper doll" inventory subset can be controlled via the "Qt Settings" dialog box ("Preferences..." on OSX) Qt: draw a border around each tile in the paper doll inventory; when BUC is diff --git a/include/optlist.h b/include/optlist.h index dcad974e4..f98bd3ca2 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -642,7 +642,7 @@ static int optfn_##a(int, int, boolean, char *, char *); NHOPTB(whatis_moveskip, Advanced, 0, opt_in, set_in_game, Off, Yes, No, No, NoAlias, &iflags.getloc_moveskip) NHOPTC(windowborders, Advanced, 9, opt_in, set_in_game, - Yes, Yes, No, No, NoAlias, "0 (off), 1 (on), 2 (auto)") + Yes, Yes, No, Yes, NoAlias, "0 (off), 1 (on), 2 (auto)") #ifdef WINCHAIN NHOPTC(windowchain, Advanced, WINTYPELEN, opt_in, set_in_sysconf, No, Yes, No, No, NoAlias, "window processor to use") diff --git a/src/options.c b/src/options.c index 27772d8c9..2e54454d6 100644 --- a/src/options.c +++ b/src/options.c @@ -332,6 +332,7 @@ static int handler_msgtype(void); #ifndef NO_VERBOSE_GRANULARITY static int handler_verbose(int optidx); #endif +static int handler_windowborders(void); static boolean is_wc_option(const char *); static boolean wc_supported(const char *); @@ -4069,11 +4070,8 @@ optfn_windowborders( } return retval; } - if (req == get_cnf_val) { - if (!opts) - return optn_err; - Sprintf(opts, "%i", iflags.wc2_windowborders); - return optn_ok; + if (req == do_handler) { + return handler_windowborders(); } if (req == get_val) { if (!opts) @@ -5728,6 +5726,41 @@ RESTORE_WARNING_FORMAT_NONLITERAL #endif +static int +handler_windowborders(void) +{ + winid tmpwin; + anything any; + int i; + const char *mode_name; + menu_item *mode_pick = (menu_item *) 0; + int clr = 0; + static const char *windowborders_text[] = { + "Off, never show borders", + "On, always show borders", + "Auto, on if display is at least (24+2)x(80+2)", + "On, except forced off for perm_invent", + "Auto, except forced off for perm_invent" + }; + + tmpwin = create_nhwindow(NHW_MENU); + start_menu(tmpwin, MENU_BEHAVE_STANDARD); + any = cg.zeroany; + for (i = 0; i < SIZE(windowborders_text); i++) { + mode_name = windowborders_text[i]; + any.a_int = i + 1; + add_menu(tmpwin, &nul_glyphinfo, &any, 'a' + i, + 0, ATR_NONE, clr, mode_name, MENU_ITEMFLAGS_NONE); + } + end_menu(tmpwin, "Select window borders mode:"); + if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { + iflags.wc2_windowborders = mode_pick->item.a_int - 1; + free((genericptr_t) mode_pick); + } + destroy_nhwindow(tmpwin); + return optn_ok; +} + /* ********************************** * @@ -6657,7 +6690,7 @@ parsebindings(char *bindings) if (!parsebindings(bind)) ret = FALSE; } - + /* parse a single binding: first split around : */ if (! (bind = index(bindings, ':'))) return FALSE; /* it's not a binding */