X11 getlin()'s prompt

Reissuing getlin() with a different prompt wasn't reliably resizing the
X11 prompt widget.  After a lot of hacking away at win/X11/dialogs.c I
eventually tried setting the response portion of the widget first and
got much better results, enough to throw away the tentative changes to
dialogs.c.

There's still a lot of room from improvement but I think it would need
to replace the ghostview prompting instead of trying to massage that.
This commit is contained in:
PatR
2022-10-25 02:55:49 -07:00
parent d7d3becf24
commit eeb208b3a9
2 changed files with 19 additions and 8 deletions

View File

@@ -1665,6 +1665,8 @@ X11: with 'slow' resource set to False, the pop up yn_function didn't always
X11: (possibly X11+OSX): if persistent inventory was displayed at time of X11: (possibly X11+OSX): if persistent inventory was displayed at time of
end-of-game prompting, prompting would stall until that window was end-of-game prompting, prompting would stall until that window was
manually dismissed manually dismissed
X11: (possibly X11+OSX): try harder to resize the getlin() prompt, if needed,
when prompt text changes
X11: set all selectable menu lines to the same length, left justified X11: set all selectable menu lines to the same length, left justified
X11: initializing the get-extended-command widget modified memory beyond what X11: initializing the get-extended-command widget modified memory beyond what
it dynamically allocated it dynamically allocated

View File

@@ -1587,7 +1587,7 @@ X11_init_nhwindows(int *argcp, char **argv)
if (icon_pixmap != None) { if (icon_pixmap != None) {
XWMHints hints; XWMHints hints;
(void) memset((genericptr_t) &hints, 0, sizeof(XWMHints)); (void) memset((genericptr_t) &hints, 0, sizeof hints);
hints.flags = IconPixmapHint; hints.flags = IconPixmapHint;
hints.icon_pixmap = icon_pixmap; hints.icon_pixmap = icon_pixmap;
XSetWMHints(XtDisplay(toplevel), XtWindow(toplevel), XSetWMHints(XtDisplay(toplevel), XtWindow(toplevel),
@@ -1922,9 +1922,12 @@ release_getline_widgets(void)
/* ask user for a line of text */ /* ask user for a line of text */
void void
X11_getlin(const char *question, /* prompt */ X11_getlin(
char *input) /* user's input, getlin's _output_ buffer */ const char *question, /* prompt */
char *input) /* user's input, getlin's _output_ buffer */
{ {
unsigned upromptlen;
getline_input = input; /* used by popup actions */ getline_input = input; /* used by popup actions */
flush_screen(1); /* tell core to make sure that map is up to date */ flush_screen(1); /* tell core to make sure that map is up to date */
@@ -1947,18 +1950,24 @@ X11_getlin(const char *question, /* prompt */
XSetWMProtocols(XtDisplay(getline_popup), XtWindow(getline_popup), XSetWMProtocols(XtDisplay(getline_popup), XtWindow(getline_popup),
&wm_delete_window, 1); &wm_delete_window, 1);
} }
SetDialogPrompt(getline_dialog, (String) question); /* set prompt */
/* 60: make the answer widget be wide enough to hold 60 characters, /* 64: make the answer widget be wide enough to hold 64 characters,
or the length of the prompt string, whichever is bigger. User's or the length of the prompt string, whichever is bigger. User's
response can be longer--when limit is reached, value-so-far will response can be longer--when limit is reached, value-so-far will
slide left hiding some chars at the beginning of the response but slide left hiding some chars at the beginning of the response but
making room to type more. [Prior to 3.6.1, width wasn't specifiable making room to type more. [Prior to 3.6.1, width wasn't specifiable
and answer box always got sized to match the width of the prompt.] */ and answer box always got sized to match the width of the prompt.] */
upromptlen = (unsigned) strlen(question);
if (upromptlen < 64)
upromptlen = 64;
#ifdef EDIT_GETLIN #ifdef EDIT_GETLIN
SetDialogResponse(getline_dialog, input, 60); /* set default answer */ /* set default answer */
SetDialogResponse(getline_dialog, input, upromptlen);
#else #else
SetDialogResponse(getline_dialog, nhStr(""), 60); /* set default answer */ /* no default answer */
SetDialogResponse(getline_dialog, nhStr(""), upromptlen);
#endif #endif
SetDialogPrompt(getline_dialog, (String) question); /* set prompt */
positionpopup(getline_popup, TRUE); /* center,bottom */ positionpopup(getline_popup, TRUE); /* center,bottom */
nh_XtPopup(getline_popup, (int) XtGrabExclusive, getline_dialog); nh_XtPopup(getline_popup, (int) XtGrabExclusive, getline_dialog);
@@ -2338,7 +2347,7 @@ X11_yn_function_core(
* It also enforces a minimum prompt width, which wasn't being * It also enforces a minimum prompt width, which wasn't being
* done before, so that really short prompts are more noticeable * done before, so that really short prompts are more noticeable
* if they pop up where the pointer is parked and it happens to * if they pop up where the pointer is parked and it happens to
* be setting somewhere the player isn't looking. * be sitting somewhere the player isn't looking.
*/ */
Dimension promptwidth, labelwidth = 0; Dimension promptwidth, labelwidth = 0;