Add key rebinding
This is a modified version of Jason Dorje Short's key rebinding patch, and allows also binding special keys, such as the ones used in getloc and getpos. One of the ways to play NetHack on nethack.alt.org is via a HTML terminal in browser. Unfortunately this means several ctrl-key combinations cannot be entered, because the browser intercepts those. Similar thing applies to some international keyboard layouts on Windows. With this patch, the user can just rebind the command to a key that works best for them. I've tested this on Linux TTY, X11, and Windows TTY and GUI.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
char * ucase (char *)
|
||||
char * upstart (char *)
|
||||
char * mungspaces (char *)
|
||||
char * trimspaces (char *)
|
||||
char * strip_newline (char *)
|
||||
char * eos (char *)
|
||||
boolean str_end_is (const char *, const char *)
|
||||
@@ -159,6 +160,22 @@ char *bp;
|
||||
return bp;
|
||||
}
|
||||
|
||||
/* remove leading and trailing whitespace, in place */
|
||||
char*
|
||||
trimspaces(txt)
|
||||
char* txt;
|
||||
{
|
||||
char* end;
|
||||
|
||||
while (*txt == ' ' || *txt == '\t')
|
||||
txt++;
|
||||
end = eos(txt);
|
||||
while (--end >= txt && (*end == ' ' || *end == '\t'))
|
||||
*end = '\0';
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
/* remove \n from end of line; remove \r too if one is there */
|
||||
char *
|
||||
strip_newline(str)
|
||||
@@ -385,13 +402,17 @@ char *sbuf;
|
||||
return strcpy(sbuf, buf);
|
||||
}
|
||||
|
||||
#define VISCTRL_NBUF 5
|
||||
/* make a displayable string from a character */
|
||||
char *
|
||||
visctrl(c)
|
||||
char c;
|
||||
{
|
||||
Static char ccc[5];
|
||||
Static char visctrl_bufs[VISCTRL_NBUF][5];
|
||||
static int nbuf = 0;
|
||||
register int i = 0;
|
||||
char *ccc = visctrl_bufs[nbuf];
|
||||
nbuf = (nbuf + 1) % VISCTRL_NBUF;
|
||||
|
||||
if ((uchar) c & 0200) {
|
||||
ccc[i++] = 'M';
|
||||
|
||||
Reference in New Issue
Block a user