'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.
This commit is contained in:
PatR
2016-03-22 18:22:39 -07:00
parent e8e8c14b34
commit b5d2135673
2 changed files with 43 additions and 45 deletions
+4
View File
@@ -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 an alternate message instead of prohibiting the promotion
kicked weapon which successfully hits monster vanishes from play kicked weapon which successfully hits monster vanishes from play
unseen landmine explosion could result in "The <monst-type> statue crumbles." unseen landmine explosion could result in "The <monst-type> 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: fix "object lost" panic during pickup caused by sortloot revamp
post-3.6.0: more sortloot revisions post-3.6.0: more sortloot revisions
+39 -45
View File
@@ -4288,23 +4288,23 @@ boolean setinitial, setfromfile;
msgtypes_again: msgtypes_again:
nmt = msgtype_count(); nmt = msgtype_count();
opt_idx = handle_add_list_remove("message type", nmt); opt_idx = handle_add_list_remove("message type", nmt);
if (opt_idx == 3) { if (opt_idx == 3) { /* done */
; /* done--fall through to function exit */ return TRUE;
} else if (opt_idx == 0) { /* add new */ } else if (opt_idx == 0) { /* add new */
getlin("What new message pattern?", mtbuf); getlin("What new message pattern?", mtbuf);
if (*mtbuf == '\033' || !*mtbuf) if (*mtbuf == '\033')
goto msgtypes_again; return TRUE;
mttyp = query_msgtype(); if (*mtbuf
if (mttyp == -1) && (mttyp = query_msgtype()) != -1
goto msgtypes_again; && !msgtype_add(mttyp, mtbuf)) {
if (!msgtype_add(mttyp, mtbuf)) {
pline("Error adding the message type."); pline("Error adding the message type.");
wait_synch(); wait_synch();
goto msgtypes_again;
} }
} else { /* list or remove */ goto msgtypes_again;
} else { /* list (1) or remove (2) */
int pick_idx, pick_cnt; int pick_idx, pick_cnt;
int mt_idx; int mt_idx;
const char *mtype;
menu_item *pick_list = (menu_item *) 0; menu_item *pick_list = (menu_item *) 0;
struct plinemsg_type *tmp = plinemsg_types; struct plinemsg_type *tmp = plinemsg_types;
@@ -4313,8 +4313,7 @@ boolean setinitial, setfromfile;
any = zeroany; any = zeroany;
mt_idx = 0; mt_idx = 0;
while (tmp) { while (tmp) {
const char *mtype = msgtype2name(tmp->msgtype); mtype = msgtype2name(tmp->msgtype);
any.a_int = ++mt_idx; any.a_int = ++mt_idx;
Sprintf(mtbuf, "%-5s \"%s\"", mtype, tmp->pattern); Sprintf(mtbuf, "%-5s \"%s\"", mtype, tmp->pattern);
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf, add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf,
@@ -4344,26 +4343,24 @@ boolean setinitial, setfromfile;
menucolors_again: menucolors_again:
nmc = count_menucolors(); nmc = count_menucolors();
opt_idx = handle_add_list_remove("menucolor", nmc); opt_idx = handle_add_list_remove("menucolor", nmc);
if (opt_idx == 3) { if (opt_idx == 3) { /* done */
; /* done--fall through to function exit */ return TRUE;
} else if (opt_idx == 0) { /* add new */ } else if (opt_idx == 0) { /* add new */
getlin("What new menucolor pattern?", mcbuf); getlin("What new menucolor pattern?", mcbuf);
if (*mcbuf == '\033' || !*mcbuf) if (*mcbuf == '\033')
goto menucolors_again; return TRUE;
mcclr = query_color(); if (*mcbuf
if (mcclr == -1) && (mcclr = query_color()) != -1
goto menucolors_again; && (mcattr = query_attr((char *) 0)) != -1
mcattr = query_attr(NULL); && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) {
if (mcattr == -1)
goto menucolors_again;
if (!add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) {
pline("Error adding the menu color."); pline("Error adding the menu color.");
wait_synch(); wait_synch();
goto menucolors_again;
} }
} else { /* list or remove */ goto menucolors_again;
} else { /* list (1) or remove (2) */
int pick_idx, pick_cnt; int pick_idx, pick_cnt;
int mc_idx; int mc_idx;
const char *sattr, *sclr;
menu_item *pick_list = (menu_item *) 0; menu_item *pick_list = (menu_item *) 0;
struct menucoloring *tmp = menu_colorings; struct menucoloring *tmp = menu_colorings;
@@ -4372,10 +4369,9 @@ boolean setinitial, setfromfile;
any = zeroany; any = zeroany;
mc_idx = 0; mc_idx = 0;
while (tmp) { while (tmp) {
const char *sattr = attr2attrname(tmp->attr); sattr = attr2attrname(tmp->attr);
const char *sclr = clr2colorname(tmp->color); sclr = clr2colorname(tmp->color);
any.a_int = ++mc_idx;
any.a_int = (++mc_idx);
Sprintf(mcbuf, "\"%s\"=%s%s%s", tmp->origstr, sclr, Sprintf(mcbuf, "\"%s\"=%s%s%s", tmp->origstr, sclr,
(tmp->attr != ATR_NONE) ? " & " : "", (tmp->attr != ATR_NONE) ? " & " : "",
(tmp->attr != ATR_NONE) ? sattr : ""); (tmp->attr != ATR_NONE) ? sattr : "");
@@ -4407,26 +4403,24 @@ boolean setinitial, setfromfile;
ape_again: ape_again:
totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]); totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]);
opt_idx = handle_add_list_remove("autopickup exception", totalapes); opt_idx = handle_add_list_remove("autopickup exception", totalapes);
if (opt_idx == 3) { if (opt_idx == 3) { /* done */
; /* done--fall through to function exit */ return TRUE;
} else if (opt_idx == 0) { /* add new */ } else if (opt_idx == 0) { /* add new */
getlin("What new autopickup exception pattern?", &apebuf[1]); getlin("What new autopickup exception pattern?", &apebuf[1]);
mungspaces(&apebuf[1]); /* regularize whitespace */ mungspaces(&apebuf[1]); /* regularize whitespace */
if (apebuf[1] == '\033') { if (apebuf[1] == '\033')
; /* fall through to function exit */ return TRUE;
} else { if (apebuf[1]) {
if (apebuf[1]) { apebuf[0] = '\"';
apebuf[0] = '\"'; /* guarantee room for \" prefix and \"\0 suffix;
/* guarantee room for \" prefix and \"\0 suffix; -2 is good enough for apebuf[] but -3 makes
-2 is good enough for apebuf[] but -3 makes sure the whole thing fits within normal BUFSZ */
sure the whole thing fits within normal BUFSZ */ apebuf[sizeof apebuf - 3] = '\0';
apebuf[sizeof apebuf - 3] = '\0'; Strcat(apebuf, "\"");
Strcat(apebuf, "\""); add_autopickup_exception(apebuf);
add_autopickup_exception(apebuf);
}
goto ape_again;
} }
} else { /* list or remove */ goto ape_again;
} else { /* list (1) or remove (2) */
int pick_idx, pick_cnt; int pick_idx, pick_cnt;
menu_item *pick_list = (menu_item *) 0; menu_item *pick_list = (menu_item *) 0;