Browse Source

Merge branch '3697_ncurses_bsdcurses'

* 3697_ncurses_bsdcurses:
  (tty_init): support curses other than ncurses.
  Ticket #3697: fix broken compatibility with ncurses.
Andrew Borodin 8 years ago
parent
commit
fc3d153b67
1 changed files with 17 additions and 5 deletions
  1. 17 5
      lib/tty/tty-ncurses.c

+ 17 - 5
lib/tty/tty-ncurses.c

@@ -179,7 +179,6 @@ mc_tty_normalize_lines_char (const char *ch)
 void
 tty_init (gboolean mouse_enable, gboolean is_xterm)
 {
-    struct termios mode;
     initscr ();
 
 #ifdef HAVE_ESCDELAY
@@ -195,12 +194,25 @@ tty_init (gboolean mouse_enable, gboolean is_xterm)
     ESCDELAY = 200;
 #endif /* HAVE_ESCDELAY */
 
-    tcgetattr (STDIN_FILENO, &mode);
+#ifdef NCURSES_VERSION
     /* use Ctrl-g to generate SIGINT */
-    mode.c_cc[VINTR] = CTRL ('g');      /* ^g */
+    cur_term->Nttyb.c_cc[VINTR] = CTRL ('g');   /* ^g */
     /* disable SIGQUIT to allow use Ctrl-\ key */
-    mode.c_cc[VQUIT] = NULL_VALUE;
-    tcsetattr (STDIN_FILENO, TCSANOW, &mode);
+    cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE;
+    tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
+#else
+    /* other curses implementation (bsd curses, ...) */
+    {
+        struct termios mode;
+
+        tcgetattr (STDIN_FILENO, &mode);
+        /* use Ctrl-g to generate SIGINT */
+        mode.c_cc[VINTR] = CTRL ('g');  /* ^g */
+        /* disable SIGQUIT to allow use Ctrl-\ key */
+        mode.c_cc[VQUIT] = NULL_VALUE;
+        tcsetattr (STDIN_FILENO, TCSANOW, &mode);
+    }
+#endif /* NCURSES_VERSION */
 
     tty_start_interrupt_key ();