Commit | Line | Data |
---|---|---|
d116f1b0 FF |
1 | From 4d46a108629beb66a293672db7b44f863b6598ba Mon Sep 17 00:00:00 2001 |
2 | From: Thomas Dickey <dickey@his.com> | |
3 | Date: Fri, 14 Apr 2017 14:06:13 +0300 | |
4 | Subject: [PATCH] Ticket #3697: (tty_init): unify curses initialization | |
5 | ||
6 | ...for various curses implementations. | |
7 | ||
8 | Signed-off-by: Andrew Borodin <aborodin@vmail.ru> | |
9 | --- | |
10 | lib/tty/tty-ncurses.c | 26 +++++++++----------------- | |
11 | 1 file changed, 9 insertions(+), 17 deletions(-) | |
12 | ||
13 | diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c | |
14 | index a7a11f368..8e69b39f6 100644 | |
15 | --- a/lib/tty/tty-ncurses.c | |
16 | +++ b/lib/tty/tty-ncurses.c | |
17 | @@ -179,6 +179,8 @@ mc_tty_normalize_lines_char (const char *ch) | |
18 | void | |
19 | tty_init (gboolean mouse_enable, gboolean is_xterm) | |
20 | { | |
21 | + struct termios mode; | |
22 | + | |
23 | initscr (); | |
24 | ||
25 | #ifdef HAVE_ESCDELAY | |
26 | @@ -194,25 +196,15 @@ tty_init (gboolean mouse_enable, gboolean is_xterm) | |
27 | ESCDELAY = 200; | |
28 | #endif /* HAVE_ESCDELAY */ | |
29 | ||
30 | -#ifdef NCURSES_VERSION | |
31 | + tcgetattr (STDIN_FILENO, &mode); | |
32 | /* use Ctrl-g to generate SIGINT */ | |
33 | - cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */ | |
34 | + mode.c_cc[VINTR] = CTRL ('g'); /* ^g */ | |
35 | /* disable SIGQUIT to allow use Ctrl-\ key */ | |
36 | - cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE; | |
37 | - tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb); | |
38 | -#else | |
39 | - /* other curses implementation (bsd curses, ...) */ | |
40 | - { | |
41 | - struct termios mode; | |
42 | - | |
43 | - tcgetattr (STDIN_FILENO, &mode); | |
44 | - /* use Ctrl-g to generate SIGINT */ | |
45 | - mode.c_cc[VINTR] = CTRL ('g'); /* ^g */ | |
46 | - /* disable SIGQUIT to allow use Ctrl-\ key */ | |
47 | - mode.c_cc[VQUIT] = NULL_VALUE; | |
48 | - tcsetattr (STDIN_FILENO, TCSANOW, &mode); | |
49 | - } | |
50 | -#endif /* NCURSES_VERSION */ | |
51 | + mode.c_cc[VQUIT] = NULL_VALUE; | |
52 | + tcsetattr (STDIN_FILENO, TCSANOW, &mode); | |
53 | + | |
54 | + /* curses remembers the "in-program" modes after this call */ | |
55 | + def_prog_mode (); | |
56 | ||
57 | tty_start_interrupt_key (); | |
58 |