0002-Ticket-3697-tty_init-unify-curses-initialization.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. ...for various curses implementations.
  6. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
  7. Upstream-Status: Backport [https://github.com/MidnightCommander/mc.git]
  8. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
  9. ---
  10. lib/tty/tty-ncurses.c | 26 +++++++++-----------------
  11. 1 file changed, 9 insertions(+), 17 deletions(-)
  12. diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c
  13. index a7a11f3..8e69b39 100644
  14. --- a/lib/tty/tty-ncurses.c
  15. +++ b/lib/tty/tty-ncurses.c
  16. @@ -179,6 +179,8 @@ mc_tty_normalize_lines_char (const char *ch)
  17. void
  18. tty_init (gboolean mouse_enable, gboolean is_xterm)
  19. {
  20. + struct termios mode;
  21. +
  22. initscr ();
  23. #ifdef HAVE_ESCDELAY
  24. @@ -194,25 +196,15 @@ tty_init (gboolean mouse_enable, gboolean is_xterm)
  25. ESCDELAY = 200;
  26. #endif /* HAVE_ESCDELAY */
  27. -#ifdef NCURSES_VERSION
  28. + tcgetattr (STDIN_FILENO, &mode);
  29. /* use Ctrl-g to generate SIGINT */
  30. - cur_term->Nttyb.c_cc[VINTR] = CTRL ('g'); /* ^g */
  31. + mode.c_cc[VINTR] = CTRL ('g'); /* ^g */
  32. /* disable SIGQUIT to allow use Ctrl-\ key */
  33. - cur_term->Nttyb.c_cc[VQUIT] = NULL_VALUE;
  34. - tcsetattr (cur_term->Filedes, TCSANOW, &cur_term->Nttyb);
  35. -#else
  36. - /* other curses implementation (bsd curses, ...) */
  37. - {
  38. - struct termios mode;
  39. -
  40. - tcgetattr (STDIN_FILENO, &mode);
  41. - /* use Ctrl-g to generate SIGINT */
  42. - mode.c_cc[VINTR] = CTRL ('g'); /* ^g */
  43. - /* disable SIGQUIT to allow use Ctrl-\ key */
  44. - mode.c_cc[VQUIT] = NULL_VALUE;
  45. - tcsetattr (STDIN_FILENO, TCSANOW, &mode);
  46. - }
  47. -#endif /* NCURSES_VERSION */
  48. + mode.c_cc[VQUIT] = NULL_VALUE;
  49. + tcsetattr (STDIN_FILENO, TCSANOW, &mode);
  50. +
  51. + /* curses remembers the "in-program" modes after this call */
  52. + def_prog_mode ();
  53. tty_start_interrupt_key ();
  54. --
  55. 2.7.4