Cygwin: pty: Disable clear screen on new pty if TERM=dumb or emacs*.
- Pseudo console support introduced by commit
169d65a577
shows garbage ^[[H^[[J in
some of emacs screens. These screens do not handle ANSI escape
sequences. Therefore, clear screen is disabled on these screens.
This commit is contained in:
parent
d4045fdbef
commit
433c6b8e0a
|
@ -962,6 +962,19 @@ skip_console_setting:
|
||||||
void
|
void
|
||||||
fhandler_pty_slave::reset_switch_to_pcon (void)
|
fhandler_pty_slave::reset_switch_to_pcon (void)
|
||||||
{
|
{
|
||||||
|
if (get_ttyp ()->need_clear_screen)
|
||||||
|
{
|
||||||
|
const char *term = getenv ("TERM");
|
||||||
|
if (term && strcmp (term, "dumb") && !strstr (term, "emacs"))
|
||||||
|
{
|
||||||
|
/* FIXME: Clearing sequence may not be "^[[H^[[J"
|
||||||
|
depending on the terminal type. */
|
||||||
|
DWORD n;
|
||||||
|
WriteFile (get_output_handle_cyg (), "\033[H\033[J", 6, &n, NULL);
|
||||||
|
}
|
||||||
|
get_ttyp ()->need_clear_screen = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ALWAYS_USE_PCON)
|
if (ALWAYS_USE_PCON)
|
||||||
return;
|
return;
|
||||||
if (isHybrid)
|
if (isHybrid)
|
||||||
|
@ -2798,14 +2811,10 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe)
|
||||||
/* Clear screen to synchronize pseudo console screen buffer
|
/* Clear screen to synchronize pseudo console screen buffer
|
||||||
with real terminal. This is necessary because pseudo
|
with real terminal. This is necessary because pseudo
|
||||||
console screen buffer is empty at start. */
|
console screen buffer is empty at start. */
|
||||||
/* FIXME: Clearing sequence may not be "^[[H^[[J"
|
|
||||||
depending on the terminal type. */
|
|
||||||
DWORD n;
|
|
||||||
if (get_ttyp ()->num_pcon_attached_slaves == 0
|
if (get_ttyp ()->num_pcon_attached_slaves == 0
|
||||||
&& !ALWAYS_USE_PCON)
|
&& !ALWAYS_USE_PCON)
|
||||||
/* Assume this is the first process using this pty slave. */
|
/* Assume this is the first process using this pty slave. */
|
||||||
WriteFile (get_output_handle_cyg (),
|
get_ttyp ()->need_clear_screen = true;
|
||||||
"\033[H\033[J", 6, &n, NULL);
|
|
||||||
|
|
||||||
get_ttyp ()->num_pcon_attached_slaves ++;
|
get_ttyp ()->num_pcon_attached_slaves ++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,6 +243,7 @@ tty::init ()
|
||||||
pcon_pid = 0;
|
pcon_pid = 0;
|
||||||
num_pcon_attached_slaves = 0;
|
num_pcon_attached_slaves = 0;
|
||||||
TermCodePage = 20127; /* ASCII */
|
TermCodePage = 20127; /* ASCII */
|
||||||
|
need_clear_screen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
pid_t pcon_pid;
|
pid_t pcon_pid;
|
||||||
int num_pcon_attached_slaves;
|
int num_pcon_attached_slaves;
|
||||||
UINT TermCodePage;
|
UINT TermCodePage;
|
||||||
|
bool need_clear_screen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HANDLE from_master () const { return _from_master; }
|
HANDLE from_master () const { return _from_master; }
|
||||||
|
|
Loading…
Reference in New Issue