Skip to content

Commit

Permalink
Ticket #3665: fix compatibility with netbsd curses.
Browse files Browse the repository at this point in the history
The code that manipulates the ncurses backend into changing
the key combination to generate SIGINT from CTRL-c to CTRL-g does
so by accessing undocumented internal ncurses data structures.
This breaks compilation with netbsd-curses[0], and could also break
when the ncurses author decides to change internal structures in a
future release.

Fix it by using a portable approach that works everywhere using libc
primitives instead.

[0] https://github.com/sabotage-linux/netbsd-curses

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
  • Loading branch information
rofl0r authored and aborodin committed Jul 29, 2016
1 parent 837a210 commit 38d4c65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/tty/tty-ncurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ mc_tty_normalize_lines_char (const char *ch)
void
tty_init (gboolean mouse_enable, gboolean is_xterm)
{
struct termios mode;
initscr ();

#ifdef HAVE_ESCDELAY
Expand All @@ -194,11 +195,12 @@ tty_init (gboolean mouse_enable, gboolean is_xterm)
ESCDELAY = 200;
#endif /* HAVE_ESCDELAY */

tcgetattr (STDIN_FILENO, &mode);
/* use Ctrl-g to generate SIGINT */
cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */
mode.c_cc[VINTR] = CTRL ('g'); /* ^g */
/* disable SIGQUIT to allow use Ctrl-\ key */
cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE;
tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
mode.c_cc[VQUIT] = NULL_VALUE;
tcsetattr (STDIN_FILENO, TCSANOW, &mode);

tty_start_interrupt_key ();

Expand Down

0 comments on commit 38d4c65

Please # to comment.