altmeta revisited
Put the flag that parse() uses to tell readchar() that the next keystroke is a command into the program_state structure instead of having it be a static variable in cmd.c. Conceivably an interface could make use of it, and even if none do, it is program state.... More #558
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 decl.h $NHDT-Date: 1607641577 2020/12/10 23:06:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.248 $ */
|
||||
/* NetHack 3.7 decl.h $NHDT-Date: 1627408982 2021/07/27 18:03:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.265 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2007. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -105,6 +105,10 @@ struct sinfo {
|
||||
int in_paniclog;
|
||||
#endif
|
||||
int wizkit_wishing;
|
||||
/* getting_a_command: only used for ALTMETA config to process ESC, but
|
||||
present and updated unconditionally; set by parse() when requesting
|
||||
next command keystroke, reset by readchar() as it returns a key */
|
||||
int getting_a_command;
|
||||
};
|
||||
|
||||
/* Flags for controlling uptodate */
|
||||
|
||||
18
src/cmd.c
18
src/cmd.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 cmd.c $NHDT-Date: 1621377703 2021/05/18 22:41:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.464 $ */
|
||||
/* NetHack 3.7 cmd.c $NHDT-Date: 1627408993 2021/07/27 18:03:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.481 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -171,9 +171,6 @@ static const char unavailcmd[] = "Unavailable command '%s'.";
|
||||
/* for rejecting #if !SHELL, !SUSPEND */
|
||||
static const char cmdnotavail[] = "'%s' command not available.";
|
||||
|
||||
/* only needed for #if ALTMETA config but present unconditionally */
|
||||
static boolean getting_cmd = FALSE; /* True when parse() gets next command */
|
||||
|
||||
static int
|
||||
doprev_message(void)
|
||||
{
|
||||
@@ -4478,8 +4475,9 @@ parse(void)
|
||||
g.context.move = 1;
|
||||
flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */
|
||||
|
||||
getting_cmd = TRUE; /* affects readchar() behavior if the 'altmeta'
|
||||
* option is On; reset to False by readchar() */
|
||||
g.program_state.getting_a_command = 1; /* affects readchar() behavior for
|
||||
* ESC iff 'altmeta' option is On;
|
||||
* reset to 0 by readchar() */
|
||||
if (!g.Cmd.num_pad || (foo = readchar()) == g.Cmd.spkeys[NHKF_COUNT]) {
|
||||
foo = get_count((char *) 0, '\0', LARGEST_INT,
|
||||
&g.command_count, FALSE);
|
||||
@@ -4627,7 +4625,8 @@ readchar_core(int *x, int *y, int *mod)
|
||||
#endif
|
||||
sym = '\033';
|
||||
#ifdef ALTMETA
|
||||
} else if (sym == '\033' && iflags.altmeta && getting_cmd) {
|
||||
} else if (sym == '\033' && iflags.altmeta
|
||||
&& g.program_state.getting_a_command) {
|
||||
/* iflags.altmeta: treat two character ``ESC c'' as single `M-c' but
|
||||
only when we're called by parse() [possibly via get_count()] */
|
||||
sym = *readchar_queue ? *readchar_queue++ : pgetchar();
|
||||
@@ -4641,8 +4640,9 @@ readchar_core(int *x, int *y, int *mod)
|
||||
readchar_queue = click_to_cmd(*x, *y, *mod);
|
||||
sym = *readchar_queue++;
|
||||
}
|
||||
getting_cmd = FALSE; /* next readchar() will be for an ordinary char
|
||||
* unless parse() sets this back to True */
|
||||
g.program_state.getting_a_command = 0; /* next readchar() will be for an
|
||||
* ordinary char unless parse()
|
||||
* sets this back to 1 */
|
||||
return (char) sym;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user