From 2fd15afb0b3b00caf0090650043645e085e01444 Mon Sep 17 00:00:00 2001
From: Yuri Khan <yurivkhan@gmail.com>
Date: Tue, 3 May 2016 16:08:01 +0600
Subject: [PATCH] Ticket #3640: Do not duplicate alternate screen switching
S-Lang already handles that in `SLsmg_init_smg` and `SLsmg_reset_smg`.
---
lib/tty/tty-ncurses.c | 30 +++++++++++++++++++++++++++---
lib/tty/tty-slang.c | 22 +++++++++++++++++++---
lib/tty/tty.h | 3 +++
lib/tty/win.c | 24 ------------------------
lib/tty/win.h | 3 ---
lib/widget/dialog-switch.c | 2 --
src/execute.c | 8 ++++----
src/filemanager/cmd.c | 1 -
src/main.c | 2 +-
9 files changed, 54 insertions(+), 41 deletions(-)
diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c
index 74da01b..110d26c 100644
a
|
b
|
tty_init (gboolean mouse_enable, gboolean is_xterm) |
204 | 204 | |
205 | 205 | if (!mouse_enable) |
206 | 206 | use_mouse_p = MOUSE_DISABLED; |
207 | | tty_init_xterm_support (is_xterm); /* do it before do_enter_ca_mode() call */ |
208 | | do_enter_ca_mode (); |
| 207 | tty_init_xterm_support (is_xterm); /* do it before tty_enter_ca_mode() call */ |
| 208 | tty_enter_ca_mode (); |
209 | 209 | tty_raw_mode (); |
210 | 210 | noecho (); |
211 | 211 | keypad (stdscr, TRUE); |
… |
… |
tty_shutdown (void) |
225 | 225 | tty_noraw_mode (); |
226 | 226 | tty_keypad (FALSE); |
227 | 227 | tty_reset_screen (); |
228 | | do_exit_ca_mode (); |
| 228 | tty_exit_ca_mode (); |
| 229 | } |
| 230 | |
| 231 | /* --------------------------------------------------------------------------------------------- */ |
| 232 | |
| 233 | void |
| 234 | tty_enter_ca_mode (void) |
| 235 | { |
| 236 | if (mc_global.tty.xterm_flag && smcup != NULL) |
| 237 | { |
| 238 | fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h"); |
| 239 | fflush (stdout); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* --------------------------------------------------------------------------------------------- */ |
| 244 | |
| 245 | void |
| 246 | tty_exit_ca_mode (void) |
| 247 | { |
| 248 | if (mc_global.tty.xterm_flag && rmcup != NULL) |
| 249 | { |
| 250 | fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m"); |
| 251 | fflush (stdout); |
| 252 | } |
229 | 253 | } |
230 | 254 | |
231 | 255 | /* --------------------------------------------------------------------------------------------- */ |
diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c
index 51b014f..b296119 100644
a
|
b
|
tty_init (gboolean mouse_enable, gboolean is_xterm) |
326 | 326 | SLsmg_init_smg (); |
327 | 327 | if (!mouse_enable) |
328 | 328 | use_mouse_p = MOUSE_DISABLED; |
329 | | tty_init_xterm_support (is_xterm); /* do it before do_enter_ca_mode() call */ |
330 | | do_enter_ca_mode (); |
| 329 | tty_init_xterm_support (is_xterm); /* do it before tty_enter_ca_mode() call */ |
| 330 | tty_enter_ca_mode (); |
331 | 331 | tty_keypad (TRUE); |
332 | 332 | tty_nodelay (FALSE); |
333 | 333 | |
… |
… |
tty_shutdown (void) |
347 | 347 | tty_noraw_mode (); |
348 | 348 | tty_keypad (FALSE); |
349 | 349 | tty_reset_screen (); |
350 | | do_exit_ca_mode (); |
| 350 | tty_exit_ca_mode (); |
351 | 351 | SLang_reset_tty (); |
352 | 352 | |
353 | 353 | /* Load the op capability to reset the colors to those that were |
… |
… |
tty_shutdown (void) |
364 | 364 | /* --------------------------------------------------------------------------------------------- */ |
365 | 365 | |
366 | 366 | void |
| 367 | tty_enter_ca_mode (void) |
| 368 | { |
| 369 | /* S-Lang handles alternate screen switching and cursor position saving */ |
| 370 | } |
| 371 | |
| 372 | /* --------------------------------------------------------------------------------------------- */ |
| 373 | |
| 374 | void |
| 375 | tty_exit_ca_mode (void) |
| 376 | { |
| 377 | /* S-Lang handles alternate screen switching and cursor position restoring */ |
| 378 | } |
| 379 | |
| 380 | /* --------------------------------------------------------------------------------------------- */ |
| 381 | |
| 382 | void |
367 | 383 | tty_change_screen_size (void) |
368 | 384 | { |
369 | 385 | SLtt_get_screen_size (); |
diff --git a/lib/tty/tty.h b/lib/tty/tty.h
index 7a40553..4b162de 100644
a
|
b
|
extern void tty_change_screen_size (void); |
137 | 137 | |
138 | 138 | extern int mc_tty_normalize_lines_char (const char *); |
139 | 139 | |
| 140 | extern void tty_enter_ca_mode (void); |
| 141 | extern void tty_exit_ca_mode (void); |
| 142 | |
140 | 143 | /*** inline functions ****************************************************************************/ |
141 | 144 | #endif /* MC_TTY_H */ |
diff --git a/lib/tty/win.c b/lib/tty/win.c
index e7cf59c..86150d1 100644
a
|
b
|
anything_ready (void) |
93 | 93 | /* --------------------------------------------------------------------------------------------- */ |
94 | 94 | |
95 | 95 | void |
96 | | do_enter_ca_mode (void) |
97 | | { |
98 | | if (mc_global.tty.xterm_flag && smcup != NULL) |
99 | | { |
100 | | fprintf (stdout, /* ESC_STR ")0" */ ESC_STR "7" ESC_STR "[?47h"); |
101 | | fflush (stdout); |
102 | | } |
103 | | } |
104 | | |
105 | | /* --------------------------------------------------------------------------------------------- */ |
106 | | |
107 | | void |
108 | | do_exit_ca_mode (void) |
109 | | { |
110 | | if (mc_global.tty.xterm_flag && rmcup != NULL) |
111 | | { |
112 | | fprintf (stdout, ESC_STR "[?47l" ESC_STR "8" ESC_STR "[m"); |
113 | | fflush (stdout); |
114 | | } |
115 | | } |
116 | | |
117 | | /* --------------------------------------------------------------------------------------------- */ |
118 | | |
119 | | void |
120 | 96 | show_rxvt_contents (int starty, unsigned char y1, unsigned char y2) |
121 | 97 | { |
122 | 98 | unsigned char *k; |
diff --git a/lib/tty/win.h b/lib/tty/win.h
index c829f07..4c31607 100644
a
|
b
|
|
17 | 17 | |
18 | 18 | /*** declarations of public functions ************************************************************/ |
19 | 19 | |
20 | | void do_enter_ca_mode (void); |
21 | | void do_exit_ca_mode (void); |
22 | | |
23 | 20 | void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2); |
24 | 21 | gboolean look_for_rxvt_extensions (void); |
25 | 22 | |
diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c
index d9a85f2..5dc5963 100644
a
|
b
|
|
36 | 36 | #include "lib/tty/tty.h" /* LINES, COLS */ |
37 | 37 | #include "lib/tty/color.h" /* tty_set_normal_attrs() */ |
38 | 38 | #ifdef HAVE_SLANG |
39 | | #include "lib/tty/win.h" /* do_enter_ca_mode() */ |
40 | 39 | #endif |
41 | 40 | #include "lib/widget.h" |
42 | 41 | #include "lib/event.h" |
… |
… |
dialog_change_screen_size (void) |
372 | 371 | tty_change_screen_size (); |
373 | 372 | |
374 | 373 | #ifdef HAVE_SLANG |
375 | | do_enter_ca_mode (); |
376 | 374 | tty_keypad (TRUE); |
377 | 375 | tty_nodelay (FALSE); |
378 | 376 | #endif |
diff --git a/src/execute.c b/src/execute.c
index c12d58c..951e572 100644
a
|
b
|
char *execute_get_external_cmd_opts_from_config (const char *command, |
78 | 78 | static void |
79 | 79 | edition_post_exec (void) |
80 | 80 | { |
81 | | do_enter_ca_mode (); |
| 81 | tty_enter_ca_mode (); |
82 | 82 | |
83 | 83 | /* FIXME: Missing on slang endwin? */ |
84 | 84 | tty_reset_prog_mode (); |
… |
… |
edition_pre_exec (void) |
122 | 122 | * Do not move this before endwin: in some systems rmcup includes |
123 | 123 | * a call to clear screen, so it will end up clearing the shell screen. |
124 | 124 | */ |
125 | | do_exit_ca_mode (); |
| 125 | tty_exit_ca_mode (); |
126 | 126 | } |
127 | 127 | |
128 | 128 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
toggle_panels (void) |
467 | 467 | tty_noecho (); |
468 | 468 | tty_keypad (FALSE); |
469 | 469 | tty_reset_screen (); |
470 | | do_exit_ca_mode (); |
| 470 | tty_exit_ca_mode (); |
471 | 471 | tty_raw_mode (); |
472 | 472 | if (mc_global.tty.console_flag != '\0') |
473 | 473 | handle_console (CONSOLE_RESTORE); |
… |
… |
toggle_panels (void) |
497 | 497 | if (mc_global.tty.console_flag != '\0') |
498 | 498 | handle_console (CONSOLE_SAVE); |
499 | 499 | |
500 | | do_enter_ca_mode (); |
| 500 | tty_enter_ca_mode (); |
501 | 501 | |
502 | 502 | tty_reset_prog_mode (); |
503 | 503 | tty_keypad (TRUE); |
diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c
index d384273..b2809ae 100644
a
|
b
|
|
53 | 53 | |
54 | 54 | #include "lib/tty/tty.h" /* LINES, tty_touch_screen() */ |
55 | 55 | #include "lib/tty/key.h" /* ALT() macro */ |
56 | | #include "lib/tty/win.h" /* do_enter_ca_mode() */ |
57 | 56 | #include "lib/mcconfig.h" |
58 | 57 | #include "lib/filehighlight.h" /* MC_FHL_INI_FILE */ |
59 | 58 | #include "lib/vfs/vfs.h" |
diff --git a/src/main.c b/src/main.c
index 492980b..f36c411 100644
a
|
b
|
main (int argc, char *argv[]) |
383 | 383 | w/o Shift button in subshell in the native console */ |
384 | 384 | init_mouse (); |
385 | 385 | |
386 | | /* Done after do_enter_ca_mode (tty_init) because in VTE bracketed mode is |
| 386 | /* Done after tty_enter_ca_mode (tty_init) because in VTE bracketed mode is |
387 | 387 | separate for the normal and alternate screens */ |
388 | 388 | enable_bracketed_paste (); |
389 | 389 | |