Ticket #3640: 0001-Ticket-3640-Do-not-duplicate-alternate-screen-switch.patch

File 0001-Ticket-3640-Do-not-duplicate-alternate-screen-switch.patch, 8.1 KB (added by yurikhan, 6 years ago)
  • lib/tty/tty-ncurses.c

    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) 
    204204 
    205205    if (!mouse_enable) 
    206206        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 (); 
    209209    tty_raw_mode (); 
    210210    noecho (); 
    211211    keypad (stdscr, TRUE); 
    tty_shutdown (void) 
    225225    tty_noraw_mode (); 
    226226    tty_keypad (FALSE); 
    227227    tty_reset_screen (); 
    228     do_exit_ca_mode (); 
     228    tty_exit_ca_mode (); 
     229} 
     230 
     231/* --------------------------------------------------------------------------------------------- */ 
     232 
     233void 
     234tty_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 
     245void 
     246tty_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    } 
    229253} 
    230254 
    231255/* --------------------------------------------------------------------------------------------- */ 
  • lib/tty/tty-slang.c

    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) 
    326326    SLsmg_init_smg (); 
    327327    if (!mouse_enable) 
    328328        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 (); 
    331331    tty_keypad (TRUE); 
    332332    tty_nodelay (FALSE); 
    333333 
    tty_shutdown (void) 
    347347    tty_noraw_mode (); 
    348348    tty_keypad (FALSE); 
    349349    tty_reset_screen (); 
    350     do_exit_ca_mode (); 
     350    tty_exit_ca_mode (); 
    351351    SLang_reset_tty (); 
    352352 
    353353    /* Load the op capability to reset the colors to those that were  
    tty_shutdown (void) 
    364364/* --------------------------------------------------------------------------------------------- */ 
    365365 
    366366void 
     367tty_enter_ca_mode (void) 
     368{ 
     369    /* S-Lang handles alternate screen switching and cursor position saving */ 
     370} 
     371 
     372/* --------------------------------------------------------------------------------------------- */ 
     373 
     374void 
     375tty_exit_ca_mode (void) 
     376{ 
     377    /* S-Lang handles alternate screen switching and cursor position restoring */ 
     378} 
     379 
     380/* --------------------------------------------------------------------------------------------- */ 
     381 
     382void 
    367383tty_change_screen_size (void) 
    368384{ 
    369385    SLtt_get_screen_size (); 
  • lib/tty/tty.h

    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); 
    137137 
    138138extern int mc_tty_normalize_lines_char (const char *); 
    139139 
     140extern void tty_enter_ca_mode (void); 
     141extern void tty_exit_ca_mode (void); 
     142 
    140143/*** inline functions ****************************************************************************/ 
    141144#endif /* MC_TTY_H */ 
  • lib/tty/win.c

    diff --git a/lib/tty/win.c b/lib/tty/win.c
    index e7cf59c..86150d1 100644
    a b anything_ready (void) 
    9393/* --------------------------------------------------------------------------------------------- */ 
    9494 
    9595void 
    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 
    12096show_rxvt_contents (int starty, unsigned char y1, unsigned char y2) 
    12197{ 
    12298    unsigned char *k; 
  • lib/tty/win.h

    diff --git a/lib/tty/win.h b/lib/tty/win.h
    index c829f07..4c31607 100644
    a b  
    1717 
    1818/*** declarations of public functions ************************************************************/ 
    1919 
    20 void do_enter_ca_mode (void); 
    21 void do_exit_ca_mode (void); 
    22  
    2320void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2); 
    2421gboolean look_for_rxvt_extensions (void); 
    2522 
  • lib/widget/dialog-switch.c

    diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c
    index d9a85f2..5dc5963 100644
    a b  
    3636#include "lib/tty/tty.h"        /* LINES, COLS */ 
    3737#include "lib/tty/color.h"      /* tty_set_normal_attrs() */ 
    3838#ifdef HAVE_SLANG 
    39 #include "lib/tty/win.h"        /* do_enter_ca_mode() */ 
    4039#endif 
    4140#include "lib/widget.h" 
    4241#include "lib/event.h" 
    dialog_change_screen_size (void) 
    372371    tty_change_screen_size (); 
    373372 
    374373#ifdef HAVE_SLANG 
    375     do_enter_ca_mode (); 
    376374    tty_keypad (TRUE); 
    377375    tty_nodelay (FALSE); 
    378376#endif 
  • src/execute.c

    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, 
    7878static void 
    7979edition_post_exec (void) 
    8080{ 
    81     do_enter_ca_mode (); 
     81    tty_enter_ca_mode (); 
    8282 
    8383    /* FIXME: Missing on slang endwin? */ 
    8484    tty_reset_prog_mode (); 
    edition_pre_exec (void) 
    122122     * Do not move this before endwin: in some systems rmcup includes 
    123123     * a call to clear screen, so it will end up clearing the shell screen. 
    124124     */ 
    125     do_exit_ca_mode (); 
     125    tty_exit_ca_mode (); 
    126126} 
    127127 
    128128/* --------------------------------------------------------------------------------------------- */ 
    toggle_panels (void) 
    467467    tty_noecho (); 
    468468    tty_keypad (FALSE); 
    469469    tty_reset_screen (); 
    470     do_exit_ca_mode (); 
     470    tty_exit_ca_mode (); 
    471471    tty_raw_mode (); 
    472472    if (mc_global.tty.console_flag != '\0') 
    473473        handle_console (CONSOLE_RESTORE); 
    toggle_panels (void) 
    497497    if (mc_global.tty.console_flag != '\0') 
    498498        handle_console (CONSOLE_SAVE); 
    499499 
    500     do_enter_ca_mode (); 
     500    tty_enter_ca_mode (); 
    501501 
    502502    tty_reset_prog_mode (); 
    503503    tty_keypad (TRUE); 
  • src/filemanager/cmd.c

    diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c
    index d384273..b2809ae 100644
    a b  
    5353 
    5454#include "lib/tty/tty.h"        /* LINES, tty_touch_screen() */ 
    5555#include "lib/tty/key.h"        /* ALT() macro */ 
    56 #include "lib/tty/win.h"        /* do_enter_ca_mode() */ 
    5756#include "lib/mcconfig.h" 
    5857#include "lib/filehighlight.h"  /* MC_FHL_INI_FILE */ 
    5958#include "lib/vfs/vfs.h" 
  • src/main.c

    diff --git a/src/main.c b/src/main.c
    index 492980b..f36c411 100644
    a b main (int argc, char *argv[]) 
    383383       w/o Shift button in subshell in the native console */ 
    384384    init_mouse (); 
    385385 
    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 
    387387       separate for the normal and alternate screens */ 
    388388    enable_bracketed_paste (); 
    389389