Skip to content

Commit 38d4c65

Browse files
rofl0raborodin
authored andcommitted
Ticket #3665: fix compatibility with netbsd curses.
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 <[email protected]>
1 parent 837a210 commit 38d4c65

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/tty/tty-ncurses.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ mc_tty_normalize_lines_char (const char *ch)
179179
void
180180
tty_init (gboolean mouse_enable, gboolean is_xterm)
181181
{
182+
struct termios mode;
182183
initscr ();
183184

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

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

203205
tty_start_interrupt_key ();
204206

0 commit comments

Comments
 (0)