curses vs extended commands

Extend the earlier support for Delete/Rubout in getline() to the
text entry for extended commands.  In other words, treat <delete>
and <backspace> as synonyms in both places.

Some reformatting too, but only in a couple of the files.
This commit is contained in:
PatR
2019-03-10 14:53:31 -07:00
parent 02b21865fd
commit 683226c3c5
3 changed files with 45 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.270 $ $NHDT-Date: 1551920371 2019/03/07 00:59:31 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.271 $ $NHDT-Date: 1552254771 2019/03/10 21:52:51 $
This fixes36.2 file is here to capture information about updates in the 3.6.x This fixes36.2 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.1 in April 2018. Please note, however, lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -477,6 +477,7 @@ curses: if the interface code ran out of memory, it would crash rather than
curses: when getting multi-character responses from player, support <delete> curses: when getting multi-character responses from player, support <delete>
as well as <backspace> to remove last character entered; also, return as well as <backspace> to remove last character entered; also, return
<escape> to core if ESC is typed when there is no input entered <escape> to core if ESC is typed when there is no input entered
curses: extend preceding <delete> support to typing of extended command names
vms: add compile of isaac64.c to Makefile.src and vmsbuild.com vms: add compile of isaac64.c to Makefile.src and vmsbuild.com

View File

@@ -76,7 +76,8 @@ static int menu_max_height(void);
static nhmenu *nhmenus = NULL; /* NetHack menu array */ static nhmenu *nhmenus = NULL; /* NetHack menu array */
/* Get a line of text from the player, such as asking for a character name or a wish */ /* Get a line of text from the player, such as asking for a character name
or a wish */
void void
curses_line_input_dialog(const char *prompt, char *answer, int buffer) curses_line_input_dialog(const char *prompt, char *answer, int buffer)
@@ -341,9 +342,9 @@ curses_ext_cmd()
extwin2 = curses_create_window(25, 1, UP); extwin2 = curses_create_window(25, 1, UP);
wrefresh(extwin2); wrefresh(extwin2);
/* create window inside window to prevent overwriting of border */ /* create window inside window to prevent overwriting of border */
getbegyx(extwin2,y0,x0); getbegyx(extwin2, y0, x0);
getmaxyx(extwin2,h,w); getmaxyx(extwin2, h, w);
extwin = newwin(1, w-2, y0+1, x0+1); extwin = newwin(1, w - 2, y0 + 1, x0 + 1);
if (w - 4 < maxlen) maxlen = w - 4; if (w - 4 < maxlen) maxlen = w - 4;
} else { } else {
curses_get_window_xy(MESSAGE_WIN, &winx, &winy); curses_get_window_xy(MESSAGE_WIN, &winx, &winy);
@@ -355,8 +356,9 @@ curses_ext_cmd()
} }
winy += messageh - 1; winy += messageh - 1;
extwin = newwin(1, messagew-2, winy, winx); extwin = newwin(1, messagew - 2, winy, winx);
if (messagew - 4 < maxlen) maxlen = messagew - 4; if (messagew - 4 < maxlen)
maxlen = messagew - 4;
pline("#"); pline("#");
} }
@@ -390,7 +392,7 @@ curses_ext_cmd()
break; break;
} }
if ((letter == '\r') || (letter == '\n')) { if (letter == '\r' || letter == '\n') {
if (ret == -1) { if (ret == -1) {
for (count = 0; extcmdlist[count].ef_txt; count++) { for (count = 0; extcmdlist[count].ef_txt; count++) {
if (!strcasecmp(cur_choice, extcmdlist[count].ef_txt)) { if (!strcasecmp(cur_choice, extcmdlist[count].ef_txt)) {
@@ -402,7 +404,9 @@ curses_ext_cmd()
break; break;
} }
if ((letter == '\b') || (letter == KEY_BACKSPACE)) { if (letter == '\177') /* DEL/Rubout */
letter = '\b';
if (letter == '\b' || letter == KEY_BACKSPACE) {
if (prompt_width == 0) { if (prompt_width == 0) {
ret = -1; ret = -1;
break; break;
@@ -749,10 +753,9 @@ menu_get_accel(boolean first)
ret = next_letter; ret = next_letter;
if (((next_letter < 'z') && (next_letter >= 'a')) || ((next_letter < 'Z') if ((next_letter < 'z' && next_letter >= 'a')
&& (next_letter >= || (next_letter < 'Z' && next_letter >= 'A')
'A')) || || (next_letter < '9' && next_letter >= '0')) {
((next_letter < '9') && (next_letter >= '0'))) {
next_letter++; next_letter++;
} else if (next_letter == 'z') { } else if (next_letter == 'z') {
next_letter = 'A'; next_letter = 'A';
@@ -789,8 +792,8 @@ menu_is_multipage(nhmenu *menu, int width, int height)
menu_item_ptr->num_lines = num_lines; menu_item_ptr->num_lines = num_lines;
curline += num_lines; curline += num_lines;
menu_item_ptr = menu_item_ptr->next_item; menu_item_ptr = menu_item_ptr->next_item;
if ((curline > height) || ((curline > height - 2) && if (curline > height
(height == menu_max_height()))) { || (curline > height - 2 && height == menu_max_height())) {
break; break;
} }
} }
@@ -895,7 +898,7 @@ menu_win_size(nhmenu *menu)
menu_item_ptr = menu_item_ptr->next_item; menu_item_ptr = menu_item_ptr->next_item;
} }
/* If the widest entry is smaller than maxwidth, reduce maxwidth accordingly */ /* If widest entry is smaller than maxwidth, reduce maxwidth accordingly */
if (maxentrywidth < maxwidth) { if (maxentrywidth < maxwidth) {
maxwidth = maxentrywidth; maxwidth = maxentrywidth;
} }
@@ -922,7 +925,7 @@ menu_win_size(nhmenu *menu)
if (lastline < maxheight) { if (lastline < maxheight) {
maxheight = lastline; maxheight = lastline;
} }
} else { /* If multipage, make sure we have enough width for page footer */ } else { /* If multipage, make sure we have enough width for page footer */
if (width < 20) { if (width < 20) {
width = 20; width = 20;
@@ -1218,8 +1221,8 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
menu_item_ptr = menu->entries; menu_item_ptr = menu->entries;
while (menu_item_ptr != NULL) { while (menu_item_ptr != NULL) {
if ((menu_item_ptr->identifier.a_void != NULL) && if (menu_item_ptr->identifier.a_void != NULL
(strstri(menu_item_ptr->str, search_key))) { && strstri(menu_item_ptr->str, search_key)) {
if (how == PICK_ONE) { if (how == PICK_ONE) {
menu_clear_selections(menu); menu_clear_selections(menu);
menu_select_deselect(win, menu_item_ptr, SELECT); menu_select_deselect(win, menu_item_ptr, SELECT);
@@ -1247,12 +1250,11 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
menu_item_ptr = menu->entries; menu_item_ptr = menu->entries;
while (menu_item_ptr != NULL) { while (menu_item_ptr != NULL) {
if (menu_item_ptr->identifier.a_void != NULL) { if (menu_item_ptr->identifier.a_void != NULL) {
if (((curletter == menu_item_ptr->accelerator) && if ((curletter == menu_item_ptr->accelerator
((curpage == menu_item_ptr->page_num) || && (curpage == menu_item_ptr->page_num
(!menu->reuse_accels))) || ((menu_item_ptr->group_accel) || !menu->reuse_accels))
&& (curletter == || (menu_item_ptr->group_accel
menu_item_ptr-> && curletter == menu_item_ptr->group_accel)) {
group_accel))) {
if (curpage != menu_item_ptr->page_num) { if (curpage != menu_item_ptr->page_num) {
curpage = menu_item_ptr->page_num; curpage = menu_item_ptr->page_num;
menu_display_page(menu, win, curpage); menu_display_page(menu, win, curpage);
@@ -1266,7 +1268,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
num_selected = 1; num_selected = 1;
dismiss = TRUE; dismiss = TRUE;
break; break;
} else if ((how == PICK_ANY) && (curletter == count_letter)) { } else if (how == PICK_ANY && curletter == count_letter) {
menu_select_deselect(win, menu_item_ptr, SELECT); menu_select_deselect(win, menu_item_ptr, SELECT);
menu_item_ptr->count = count; menu_item_ptr->count = count;
count = 0; count = 0;
@@ -1280,7 +1282,7 @@ menu_get_selections(WINDOW * win, nhmenu *menu, int how)
} }
} }
if ((how == PICK_ANY) && (num_selected != -1)) { if (how == PICK_ANY && num_selected != -1) {
num_selected = 0; num_selected = 0;
menu_item_ptr = menu->entries; menu_item_ptr = menu->entries;

View File

@@ -86,7 +86,7 @@ struct window_procs curses_procs = {
*/ */
int term_rows, term_cols; /* size of underlying terminal */ int term_rows, term_cols; /* size of underlying terminal */
int orig_cursor; /* Preserve initial cursor state */ int orig_cursor; /* Preserve initial cursor state */
WINDOW *base_term; /* underlying terminal window */ WINDOW *base_term; /* underlying terminal window */
boolean counting; /* Count window is active */ boolean counting; /* Count window is active */
WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */ WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */
@@ -307,6 +307,7 @@ void
curses_display_nhwindow(winid wid, BOOLEAN_P block) curses_display_nhwindow(winid wid, BOOLEAN_P block)
{ {
menu_item *selected = NULL; menu_item *selected = NULL;
if (curses_is_menu(wid) || curses_is_text(wid)) { if (curses_is_menu(wid) || curses_is_text(wid)) {
curses_end_menu(wid, ""); curses_end_menu(wid, "");
curses_select_menu(wid, PICK_NONE, &selected); curses_select_menu(wid, PICK_NONE, &selected);
@@ -314,9 +315,9 @@ curses_display_nhwindow(winid wid, BOOLEAN_P block)
} }
/* don't overwrite the splash screen first time through */ /* don't overwrite the splash screen first time through */
if (!iflags.window_inited && wid == MAP_WIN) if (!iflags.window_inited && wid == MAP_WIN) {
iflags.window_inited = TRUE; iflags.window_inited = TRUE;
else { } else {
/* actually display the window */ /* actually display the window */
wnoutrefresh(curses_get_nhwin(wid)); wnoutrefresh(curses_get_nhwin(wid));
/* flush pending writes from other windows too */ /* flush pending writes from other windows too */
@@ -847,8 +848,8 @@ preference_update(preference)
void void
curses_preference_update(const char *pref) curses_preference_update(const char *pref)
{ {
if ((strcmp(pref, "align_status") == 0) || if (!strcmp(pref, "align_status")
(strcmp(pref, "align_message") == 0)) { || !strcmp(pref, "align_message")) {
curses_create_main_windows(); curses_create_main_windows();
curses_last_messages(); curses_last_messages();
doredraw(); doredraw();