Skip to content

Commit

Permalink
Disable ncurses extended key values (#1049)
Browse files Browse the repository at this point in the history
This makes it possible to use esc-codes in mappings for Shift/Ctrl/Alt
Up/Down/Left/Right/Home/End/Insert/Delete/PgUp/PgDn.

[tk: minor tweaks and NCURSES_EXT_FUNCS was only made visible in ncurses
 v5_6_20071117, so use NCURSES_VERSION instead for compatibility.]

References #1046
  • Loading branch information
mckellyln authored and koutcher committed Dec 22, 2020
1 parent 9e357e9 commit aee8eb1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "tig/display.h"
#include "tig/watch.h"

#define MAX_KEYS 2000

static void set_terminal_modes(void);

struct view *display[2];
Expand Down Expand Up @@ -638,6 +640,7 @@ init_display(void)
bool no_display = !!getenv("TIG_NO_DISPLAY");
const char *term;
int x, y;
int code;

if (!opt_tty.file)
die("Can't initialize display without tty");
Expand Down Expand Up @@ -675,6 +678,15 @@ init_display(void)
wbkgdset(status_win, get_line_attr(NULL, LINE_STATUS));
enable_mouse(opt_mouse);

#ifdef NCURSES_VERSION
/* Disable extended keys so that esc-codes will be received
* instead of extended key values (> KEY_MAX).
* Then these keys can be mapped in .tigrc etc. */
for (code = KEY_MAX; code < MAX_KEYS; code++) {
keyok(code, false);
}
#endif

#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH >= 20080119)
set_tabsize(opt_tab_size);
#else
Expand Down

0 comments on commit aee8eb1

Please sign in to comment.