From b5d21356735d3c3be0e3ab45146ba99394a660f9 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 22 Mar 2016 18:22:39 -0700 Subject: [PATCH] 'O' for regexp options Noticed when testing tty menucolor changes recently, using the 'O' command to interactively add a new entry would accept one and then quit, unlike remove which accepts multiple at a time and then goes back to the menu where you could choose 'remove' all over again. Adding is still done one entry at a time, but instead of finishing, it goes back to the menu where you can choose to add another. --- doc/fixes36.1 | 4 +++ src/options.c | 84 ++++++++++++++++++++++++--------------------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index c8e65af55..a2853713b 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -192,6 +192,10 @@ female gnome who gains level can grow up into male-only gnome lord; give an an alternate message instead of prohibiting the promotion kicked weapon which successfully hits monster vanishes from play unseen landmine explosion could result in "The statue crumbles." +when using the 'O' command for regexp options (autopickup exceptions, + menucolors, message types), provide opportunity to add more than one + at a time [after 'add', return to add/list/remove menu] + post-3.6.0: fix "object lost" panic during pickup caused by sortloot revamp post-3.6.0: more sortloot revisions diff --git a/src/options.c b/src/options.c index e96252911..af854e9c8 100644 --- a/src/options.c +++ b/src/options.c @@ -4288,23 +4288,23 @@ boolean setinitial, setfromfile; msgtypes_again: nmt = msgtype_count(); opt_idx = handle_add_list_remove("message type", nmt); - if (opt_idx == 3) { - ; /* done--fall through to function exit */ + if (opt_idx == 3) { /* done */ + return TRUE; } else if (opt_idx == 0) { /* add new */ getlin("What new message pattern?", mtbuf); - if (*mtbuf == '\033' || !*mtbuf) - goto msgtypes_again; - mttyp = query_msgtype(); - if (mttyp == -1) - goto msgtypes_again; - if (!msgtype_add(mttyp, mtbuf)) { + if (*mtbuf == '\033') + return TRUE; + if (*mtbuf + && (mttyp = query_msgtype()) != -1 + && !msgtype_add(mttyp, mtbuf)) { pline("Error adding the message type."); wait_synch(); - goto msgtypes_again; } - } else { /* list or remove */ + goto msgtypes_again; + } else { /* list (1) or remove (2) */ int pick_idx, pick_cnt; int mt_idx; + const char *mtype; menu_item *pick_list = (menu_item *) 0; struct plinemsg_type *tmp = plinemsg_types; @@ -4313,8 +4313,7 @@ boolean setinitial, setfromfile; any = zeroany; mt_idx = 0; while (tmp) { - const char *mtype = msgtype2name(tmp->msgtype); - + mtype = msgtype2name(tmp->msgtype); any.a_int = ++mt_idx; Sprintf(mtbuf, "%-5s \"%s\"", mtype, tmp->pattern); add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf, @@ -4344,26 +4343,24 @@ boolean setinitial, setfromfile; menucolors_again: nmc = count_menucolors(); opt_idx = handle_add_list_remove("menucolor", nmc); - if (opt_idx == 3) { - ; /* done--fall through to function exit */ + if (opt_idx == 3) { /* done */ + return TRUE; } else if (opt_idx == 0) { /* add new */ getlin("What new menucolor pattern?", mcbuf); - if (*mcbuf == '\033' || !*mcbuf) - goto menucolors_again; - mcclr = query_color(); - if (mcclr == -1) - goto menucolors_again; - mcattr = query_attr(NULL); - if (mcattr == -1) - goto menucolors_again; - if (!add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) { + if (*mcbuf == '\033') + return TRUE; + if (*mcbuf + && (mcclr = query_color()) != -1 + && (mcattr = query_attr((char *) 0)) != -1 + && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) { pline("Error adding the menu color."); wait_synch(); - goto menucolors_again; } - } else { /* list or remove */ + goto menucolors_again; + } else { /* list (1) or remove (2) */ int pick_idx, pick_cnt; int mc_idx; + const char *sattr, *sclr; menu_item *pick_list = (menu_item *) 0; struct menucoloring *tmp = menu_colorings; @@ -4372,10 +4369,9 @@ boolean setinitial, setfromfile; any = zeroany; mc_idx = 0; while (tmp) { - const char *sattr = attr2attrname(tmp->attr); - const char *sclr = clr2colorname(tmp->color); - - any.a_int = (++mc_idx); + sattr = attr2attrname(tmp->attr); + sclr = clr2colorname(tmp->color); + any.a_int = ++mc_idx; Sprintf(mcbuf, "\"%s\"=%s%s%s", tmp->origstr, sclr, (tmp->attr != ATR_NONE) ? " & " : "", (tmp->attr != ATR_NONE) ? sattr : ""); @@ -4407,26 +4403,24 @@ boolean setinitial, setfromfile; ape_again: totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]); opt_idx = handle_add_list_remove("autopickup exception", totalapes); - if (opt_idx == 3) { - ; /* done--fall through to function exit */ + if (opt_idx == 3) { /* done */ + return TRUE; } else if (opt_idx == 0) { /* add new */ getlin("What new autopickup exception pattern?", &apebuf[1]); mungspaces(&apebuf[1]); /* regularize whitespace */ - if (apebuf[1] == '\033') { - ; /* fall through to function exit */ - } else { - if (apebuf[1]) { - apebuf[0] = '\"'; - /* guarantee room for \" prefix and \"\0 suffix; - -2 is good enough for apebuf[] but -3 makes - sure the whole thing fits within normal BUFSZ */ - apebuf[sizeof apebuf - 3] = '\0'; - Strcat(apebuf, "\""); - add_autopickup_exception(apebuf); - } - goto ape_again; + if (apebuf[1] == '\033') + return TRUE; + if (apebuf[1]) { + apebuf[0] = '\"'; + /* guarantee room for \" prefix and \"\0 suffix; + -2 is good enough for apebuf[] but -3 makes + sure the whole thing fits within normal BUFSZ */ + apebuf[sizeof apebuf - 3] = '\0'; + Strcat(apebuf, "\""); + add_autopickup_exception(apebuf); } - } else { /* list or remove */ + goto ape_again; + } else { /* list (1) or remove (2) */ int pick_idx, pick_cnt; menu_item *pick_list = (menu_item *) 0; -- 2.40.0