curses EDIT_GETLIN - discarding preloaded answer
EDIT_GETLIN is more complicated on curses than on tty due to way that long lines are handled.... Using ESC to get rid of the default response removed it from the answer buffer but didn't erase back to the end of actual prompt, making it look as if it was still there. Fixing that for a one-line prompt+answer was needed and would have been easy but it also needs to be prepared to go back to prior lines. Both the prompt and the answer could conceivably span lines although in practice it will usually just be one line or else prompt+answer combined spanning to a second line. This hasn't been exhaustively tested been seems to be working correctly.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.48 $ $NHDT-Date: 1560085861 2019/06/09 13:11:01 $
|
||||
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.49 $ $NHDT-Date: 1560089250 2019/06/09 14:07:30 $
|
||||
|
||||
This fixes36.3 file is here to capture information about updates in the 3.6.x
|
||||
lineage following the release of 3.6.2 in May 2019. Please note, however,
|
||||
@@ -109,6 +109,8 @@ curses: don't convert ^M (or <return> or <enter> key) into ^J; both ^J and ^M
|
||||
commands, ^J means run toward bottom of screen (when number_pad is
|
||||
off) and ^M is not bound to any command, so accidental <return> won't
|
||||
cause the hero to try to move
|
||||
curses+EDIT_GETLIN: when a prompt's answer was preloaded, using ESC to discard
|
||||
it deleted it from the answer buffer but didn't erase it from screen
|
||||
tty: re-do one optimization used when status conditions have all been removed
|
||||
and remove another that tried to check whether condition text to be
|
||||
displayed next was the same as the existing value; sometimes new
|
||||
|
||||
@@ -469,7 +469,7 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer)
|
||||
int maxy, maxx; /* linewrap / scroll */
|
||||
int ch;
|
||||
int border_space = 0;
|
||||
int len; /* of answer string */
|
||||
int ltmp, len; /* of answer string */
|
||||
boolean border = curses_window_has_border(MESSAGE_WIN);
|
||||
WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
|
||||
|
||||
@@ -531,9 +531,30 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer)
|
||||
my--;
|
||||
}
|
||||
}
|
||||
mvwaddstr(win, my, mx, linestarts[nlines - 1]);
|
||||
mx = promptx = (int) strlen(linestarts[nlines - 1]) + border_space;
|
||||
promptline = nlines - 1;
|
||||
mvwaddstr(win, my, mx, linestarts[promptline]);
|
||||
ltmp = (int) strlen(linestarts[promptline]);
|
||||
mx = promptx = ltmp + border_space;
|
||||
#ifdef EDIT_GETLIN
|
||||
if (len <= ltmp) {
|
||||
/* preloaded answer fits on same line as [last line of] prompt */
|
||||
promptx -= len;
|
||||
} else {
|
||||
int ltmp2 = len;
|
||||
|
||||
/* preloaded answer spans lines so will be trickier to erase
|
||||
if that is called for; find where the end of the prompt will
|
||||
be without the answer appended */
|
||||
while (ltmp2 > 0) {
|
||||
ltmp2 -= ltmp;
|
||||
promptline -= 1;
|
||||
ltmp = (int) strlen(linestarts[promptline]);
|
||||
}
|
||||
if (ltmp2 < 0)
|
||||
ltmp = -ltmp2;
|
||||
promptx = ltmp + border_space;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
mx = (int) strlen(linestarts[nlines - 1]) + border_space;
|
||||
|
||||
Reference in New Issue
Block a user