X11 getline: log prompt and response
After player has responded to a getline prompt, echo the prompt and the line of text response to the message window. Uses pline() so also gets put into core's message history for dumplog.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.456 $ $NHDT-Date: 1613723080 2021/02/19 08:24:40 $
|
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.459 $ $NHDT-Date: 1613777904 2021/02/19 23:38:24 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -835,6 +835,8 @@ tiles: male and female variations in monsters.txt; tested only with tile2bmp
|
|||||||
Unix: can define NOSUSPEND in config.h or src/Makefile's CFLAGS to prevent
|
Unix: can define NOSUSPEND in config.h or src/Makefile's CFLAGS to prevent
|
||||||
unixconf.h from enabling SUSPEND without need to modify unixconf.h
|
unixconf.h from enabling SUSPEND without need to modify unixconf.h
|
||||||
X11: implement 'selectsaved', restore via menu of saved games
|
X11: implement 'selectsaved', restore via menu of saved games
|
||||||
|
X11: echo getline prompt and response (wishes, applying names) to message
|
||||||
|
window and dumplog message history
|
||||||
|
|
||||||
|
|
||||||
NetHack Community Patches (or Variation) Included
|
NetHack Community Patches (or Variation) Included
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 winX.c $NHDT-Date: 1613444929 2021/02/16 03:08:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.98 $ */
|
/* NetHack 3.7 winX.c $NHDT-Date: 1613777904 2021/02/19 23:38:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.99 $ */
|
||||||
/* Copyright (c) Dean Luick, 1992 */
|
/* Copyright (c) Dean Luick, 1992 */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -1826,7 +1826,7 @@ X11_askname(void)
|
|||||||
static Widget getline_popup, getline_dialog;
|
static Widget getline_popup, getline_dialog;
|
||||||
|
|
||||||
#define CANCEL_STR "\033"
|
#define CANCEL_STR "\033"
|
||||||
static char *getline_input;
|
static char *getline_input; /* buffer to hold user input; getline's output */
|
||||||
|
|
||||||
/* Callback for getline dialog widget. */
|
/* Callback for getline dialog widget. */
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
@@ -1892,12 +1892,14 @@ release_getline_widgets(void)
|
|||||||
XtDestroyWidget(getline_popup), getline_popup = (Widget) 0;
|
XtDestroyWidget(getline_popup), getline_popup = (Widget) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ask user for a line of text */
|
||||||
void
|
void
|
||||||
X11_getlin(const char *question, char *input)
|
X11_getlin(const char *question, /* prompt */
|
||||||
|
char *input) /* user's input, getlin's _output_ buffer */
|
||||||
{
|
{
|
||||||
getline_input = input;
|
getline_input = input; /* used by popup actions */
|
||||||
|
|
||||||
flush_screen(1);
|
flush_screen(1); /* tell core to make sure that map is up to date */
|
||||||
if (!getline_popup) {
|
if (!getline_popup) {
|
||||||
Arg args[1];
|
Arg args[1];
|
||||||
|
|
||||||
@@ -1935,6 +1937,22 @@ X11_getlin(const char *question, char *input)
|
|||||||
|
|
||||||
/* The callback will enable the event loop exit. */
|
/* The callback will enable the event loop exit. */
|
||||||
(void) x_event(EXIT_ON_EXIT);
|
(void) x_event(EXIT_ON_EXIT);
|
||||||
|
|
||||||
|
/* we get here after the popup has exited;
|
||||||
|
put prompt and response into the message window (and into
|
||||||
|
core's dumplog history) unless play hasn't started yet */
|
||||||
|
if (g.program_state.in_moveloop || g.program_state.gameover) {
|
||||||
|
const char *visanswer = (*input == '\033') ? "ESC" : input;
|
||||||
|
int promptlen = (int) strlen(question),
|
||||||
|
answerlen = (int) strlen(visanswer);
|
||||||
|
|
||||||
|
pline("%.*s %.*s", /* note: (QBUFSZ-1 + 1 + QBUFSZ-1) == (BUFSZ-1) */
|
||||||
|
min(promptlen, QBUFSZ - 1), question,
|
||||||
|
min(answerlen, QBUFSZ - 1), visanswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clear static pointer that's about to go stale */
|
||||||
|
getline_input = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display file ----------------------------------------------------------- */
|
/* Display file ----------------------------------------------------------- */
|
||||||
|
|||||||
Reference in New Issue
Block a user