Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ncurses extended keycode values. A better method than prev PR #1049 #1074

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,19 @@ init_display(void)
if (atexit(done_display))
die("Failed to register done_display");

#ifdef NCURSES_VERSION
/* Disable 'unsupported' extended keys so that esc-codes will be
* received instead of unnamed extended keycode values (> KEY_MAX).
* These keys can then be mapped with esc-codes in .tigrc.
* An example would be <c-down>:
* bind generic <esc>[1;5B scroll-line-down
* Without this change <c-down> could return a keycode value of 531
* (terminfo name kDN5), which is larger than KEY_MAX and has no
* pre-defined curses key name.
* NOTE: this MUST be called before initscr() */
use_extended_names(false);
#endif

/* Initialize the curses library */
if (!no_display && isatty(STDIN_FILENO)) {
/* Needed for ncurses 5.4 compatibility. */
Expand Down Expand Up @@ -678,15 +691,6 @@ 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