Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2019-09-05 03:24:26 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-09-05 14:59:37 +0300
commit433c6b8e0a667f9eae41a52efadec35ac62730df (patch)
treeb642cdcf2ece53d82c99d98d1ddf901b270c3b27
parentd4045fdbef60d8e7e0d11dfe38b048ea2cb8708b (diff)
Cygwin: pty: Disable clear screen on new pty if TERM=dumb or emacs*.
- Pseudo console support introduced by commit 169d65a5774acc76ce3f3feeedcbae7405aa9b57 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.
-rw-r--r--winsup/cygwin/fhandler_tty.cc19
-rw-r--r--winsup/cygwin/tty.cc1
-rw-r--r--winsup/cygwin/tty.h1
3 files changed, 16 insertions, 5 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index fadff59a3..a6844832b 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -962,6 +962,19 @@ skip_console_setting:
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)
return;
if (isHybrid)
@@ -2798,14 +2811,10 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe)
/* Clear screen to synchronize pseudo console screen buffer
with real terminal. This is necessary because pseudo
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
&& !ALWAYS_USE_PCON)
/* Assume this is the first process using this pty slave. */
- WriteFile (get_output_handle_cyg (),
- "\033[H\033[J", 6, &n, NULL);
+ get_ttyp ()->need_clear_screen = true;
get_ttyp ()->num_pcon_attached_slaves ++;
}
diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc
index 9244267c0..c94aee3ba 100644
--- a/winsup/cygwin/tty.cc
+++ b/winsup/cygwin/tty.cc
@@ -243,6 +243,7 @@ tty::init ()
pcon_pid = 0;
num_pcon_attached_slaves = 0;
TermCodePage = 20127; /* ASCII */
+ need_clear_screen = false;
}
HANDLE
diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h
index d59b2027d..c2b0490d0 100644
--- a/winsup/cygwin/tty.h
+++ b/winsup/cygwin/tty.h
@@ -104,6 +104,7 @@ private:
pid_t pcon_pid;
int num_pcon_attached_slaves;
UINT TermCodePage;
+ bool need_clear_screen;
public:
HANDLE from_master () const { return _from_master; }