altmeta Alt key hack, mainly for unix (trunk only)
Some time ago we received a patch submission which attempted to
handle the Alt key for terminals or emulators which transmit two char
sequence "ESC c" when Alt+c is pressed, but I can't find it. I don't
remember the details but recall that it had at least once significant
problem (perhaps just that it was unconditional, although it may have
been implemented in a way which interferred with using ESC to cancel).
This patch reimplements the desired fix, making the new behavior be
conditional on a boolean option: altmeta. That option already exists
for the Amiga port, where it deals with low-level keyboard handling but
essentially affects the same thing: whether Alt+key can be used as a
shortcut for various extended commands. This one affects how the core
processes commands, and is only available if ALTMETA is defined at
compile time. I've defined that for Unix and VMS; other ports don't
seem to need it. (I'm not sure whether "options" created by makedefs
ought to mention it. So far, it doesn't since this isn't something
users are expected to tweak. The setting of the non-Amiga altmeta
option doesn't get saved and restored, so won't affect saved data if
someone does toggle ALTMETA and then rebuild.)
When [non-Amiga] altmeta is set, nethack's core will give special
handling to ESC, but only during top level command processing. If ESC
is seen while reading a command, it will be consumed and then the next
character seen will have its meta bit set. This introduces a potential
problem: typing ESC as a command will result in waiting for another
character instead of reporting that that isn't a valid command. Since it
isn't a valid command, this shouldn't be a big deal, but starting a count
intended to prefix your next command and then typing ESC after deciding
to abort that count runs into the same situation: nethack will wait for
another character to complete the two character sequence expected for
"ESC c". There's not much that can be done with this, other than have
the Guidebook mention that an extra ESC is needed to cancel the pending
count, because digits followed by ESC could actually be a numeric prefix
for Alt+something rather than an attempt to abort the count.
This commit is contained in:
@@ -180,6 +180,9 @@ struct instance_flags {
|
||||
int menu_headings; /* ATR for menu headings */
|
||||
int *opt_booldup; /* for duplication of boolean opts in config file */
|
||||
int *opt_compdup; /* for duplication of compound opts in config file */
|
||||
#ifdef ALTMETA
|
||||
boolean altmeta; /* Alt-c sends ESC c rather than M-c */
|
||||
#endif
|
||||
boolean cbreak; /* in cbreak mode, rogue format */
|
||||
boolean deferred_X; /* deferred entry into explore mode */
|
||||
boolean num_pad; /* use numbers for movement commands */
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* NetHack 3.5 unixconf.h $Date$ $Revision$ */
|
||||
/* SCCS Id: @(#)unixconf.h 3.5 2007/12/12 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -198,6 +197,12 @@
|
||||
#define MAILCKFREQ 50
|
||||
#endif /* MAIL */
|
||||
|
||||
/*
|
||||
* Some terminals or terminal emulators send two character sequence "ESC c"
|
||||
* when Alt+c is pressed. The altmeta run-time option allows the user to
|
||||
* request that "ESC c" be treated as M-c.
|
||||
*/
|
||||
#define ALTMETA /* support altmeta run-time option */
|
||||
|
||||
|
||||
#ifdef COMPRESS
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* NetHack 3.5 vmsconf.h $Date$ $Revision$ */
|
||||
/* SCCS Id: @(#)vmsconf.h 3.5 2007/10/27 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -137,6 +136,16 @@
|
||||
#define SHELL /* do not delete the '!' command */
|
||||
#define SUSPEND /* don't delete the ^Z command, such as it is */
|
||||
|
||||
/*
|
||||
* Some terminals or terminal emulators send two character sequence "ESC c"
|
||||
* when Alt+c is pressed. The altmeta run-time option allows the user to
|
||||
* request that "ESC c" be treated as M-c, which means that if nethack sees
|
||||
* ESC when it is waiting for a command, it will wait for another character
|
||||
* (even if user intended that ESC to be standalone to cancel a count prefix).
|
||||
*/
|
||||
#define ALTMETA /* support altmeta run-time option */
|
||||
|
||||
|
||||
#define RANDOM /* use sys/share/random.c instead of vaxcrtl rand */
|
||||
|
||||
#define FCMASK 0660 /* file creation mask */
|
||||
|
||||
Reference in New Issue
Block a user