Add an instance flag for being inside parse()

Some windowports that are currently being written by third parties
need more information about the engine than they currently have.
Two specific reported problems: a) needing to know whether a
putstr() call relates to a count (so that it can be placed in a
different part of the user interface from the message area); b)
needing to know whether a request for a character relates to
command input (some hangup handling routines need this so that
they can determine what behaviour is potentially exploitable).
Knowing whether or not you're inside parse() fixes both of them.

This would be cleaner to do by changing the windowport API, but
that'd break existing windowports, which isn't really ideal.
Setting a globalish variable that the windowport can inspect, but
can ignore if it prefers, means that existing windowports will
continue to work fine, but new windowports will have more
information and thus more flexibility in how they handle command
entry.
This commit is contained in:
Alex Smith
2017-12-09 14:12:40 +00:00
parent 20accd4bb7
commit 045ee2a898
2 changed files with 4 additions and 0 deletions

View File

@@ -216,6 +216,7 @@ struct instance_flags {
boolean sanity_check; /* run sanity checks */
boolean mon_polycontrol; /* debug: control monster polymorphs */
boolean in_dumplog; /* doing the dumplog right now? */
boolean in_parse; /* is a command being parsed? */
/* stuff that is related to options and/or user or platform preferences
*/

View File

@@ -5125,6 +5125,7 @@ parse()
register int foo;
boolean prezero = FALSE;
iflags.in_parse = TRUE;
multi = 0;
context.move = 1;
flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */
@@ -5191,6 +5192,8 @@ parse()
clear_nhwindow(WIN_MESSAGE);
if (prezero)
in_line[0] = Cmd.spkeys[NHKF_ESC];
iflags.in_parse = FALSE;
return in_line;
}