Merge branch 'master' into win32-x64-working
This commit is contained in:
+13
-2
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 winX.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.5 winX.c $NHDT-Date: 1430040327 2015/04/26 09:25:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
|
||||
/* NetHack 3.5 winX.c $Date: 2012/01/24 04:26:26 $ $Revision: 1.27 $ */
|
||||
/* Copyright (c) Dean Luick, 1992 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1532,6 +1532,7 @@ static char yn_esc_map; /* ESC maps to this char. */
|
||||
static Widget yn_popup; /* popup for the yn fuction (created once) */
|
||||
static Widget yn_label; /* label for yn function (created once) */
|
||||
static boolean yn_getting_num; /* TRUE if accepting digits */
|
||||
static boolean yn_preserve_case; /* default is to force yn to lower case */
|
||||
static int yn_ndigits; /* digit count */
|
||||
static long yn_val; /* accumulated value */
|
||||
|
||||
@@ -1604,7 +1605,8 @@ yn_key(w, event, params, num_params)
|
||||
if (!yn_choices) { /* accept any input */
|
||||
yn_return = ch;
|
||||
} else {
|
||||
ch = lowc(ch); /* move to lower case */
|
||||
if (!yn_preserve_case)
|
||||
ch = lowc(ch); /* move to lower case */
|
||||
|
||||
if (ch == '\033') {
|
||||
yn_getting_num = FALSE;
|
||||
@@ -1664,6 +1666,7 @@ X11_yn_function(ques, choices, def)
|
||||
|
||||
yn_choices = choices; /* set up globals for callback to use */
|
||||
yn_def = def;
|
||||
yn_preserve_case = !choices; /* preserve when arbitrary response allowed */
|
||||
|
||||
/*
|
||||
* This is sort of a kludge. There are quite a few places in the main
|
||||
@@ -1679,6 +1682,14 @@ X11_yn_function(ques, choices, def)
|
||||
char *cb, choicebuf[QBUFSZ];
|
||||
|
||||
Strcpy(choicebuf, choices); /* anything beyond <esc> is hidden */
|
||||
/* default when choices are present is to force yn answer to
|
||||
lowercase unless one or more choices are explicitly uppercase;
|
||||
check this before stripping the hidden choices */
|
||||
for (cb = choicebuf; *cb; ++cb)
|
||||
if ('A' <= *cb && *cb <= 'Z') {
|
||||
yn_preserve_case = TRUE;
|
||||
break;
|
||||
}
|
||||
if ((cb = index(choicebuf, '\033')) != 0) *cb = '\0';
|
||||
/* ques [choices] (def) */
|
||||
if ((int)(1 + strlen(ques) + 2 + strlen(choicebuf) + 4) >= BUFSZ)
|
||||
|
||||
+16
-4
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1425081315 2015/02/27 23:55:15 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
|
||||
/* NetHack 3.5 topl.c $NHDT-Date: 1430040322 2015/04/26 09:25:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.29 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -333,7 +333,7 @@ char def;
|
||||
{
|
||||
register char q;
|
||||
char rtmp[40];
|
||||
boolean digit_ok, allow_num;
|
||||
boolean digit_ok, allow_num, preserve_case = FALSE;
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
boolean doprev = 0;
|
||||
char prompt[BUFSZ];
|
||||
@@ -347,6 +347,14 @@ char def;
|
||||
|
||||
allow_num = (index(resp, '#') != 0);
|
||||
Strcpy(respbuf, resp);
|
||||
/* normally we force lowercase, but if any uppercase letters
|
||||
are present in the allowed response, preserve case;
|
||||
check this before stripping the hidden choices */
|
||||
for (rb = respbuf; *rb; ++rb)
|
||||
if ('A' <= *rb && *rb <= 'Z') {
|
||||
preserve_case = TRUE;
|
||||
break;
|
||||
}
|
||||
/* any acceptable responses that follow <esc> aren't displayed */
|
||||
if ((rb = index(respbuf, '\033')) != 0) *rb = '\0';
|
||||
(void)strncpy(prompt, query, QBUFSZ-1);
|
||||
@@ -358,13 +366,16 @@ char def;
|
||||
Strcat(prompt, " ");
|
||||
pline("%s", prompt);
|
||||
} else {
|
||||
/* no restriction on allowed response, so always preserve case */
|
||||
/* preserve_case = TRUE; -- moot since we're jumping to the end */
|
||||
pline("%s ", query);
|
||||
q = readchar();
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
do { /* loop until we get valid input */
|
||||
q = lowc(readchar());
|
||||
q = readchar();
|
||||
if (!preserve_case) q = lowc(q);
|
||||
if (q == '\020') { /* ctrl-P */
|
||||
if (iflags.prevmsg_window != 's') {
|
||||
int sav = ttyDisplay->inread;
|
||||
@@ -422,7 +433,8 @@ char def;
|
||||
q = '#';
|
||||
}
|
||||
do { /* loop until we get a non-digit */
|
||||
z = lowc(readchar());
|
||||
z = readchar();
|
||||
if (!preserve_case) z = lowc(z);
|
||||
if (digit(z)) {
|
||||
value = (10 * value) + (z - '0');
|
||||
if (value < 0) break; /* overflow: try again */
|
||||
|
||||
Reference in New Issue
Block a user