[PATCH] Cygwin: pty: Fix screen distortion after less for native apps again.
Takashi Yano
takashi.yano@nifty.ne.jp
Tue Jun 2 12:44:40 GMT 2020
- Commit c4b060e3fe3bed05b3a69ccbcc20993ad85e163d seems to be not
enough. Fixed again.
---
winsup/cygwin/fhandler_tty.cc | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index bcc7648f3..742fa7e33 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1394,10 +1394,6 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char *ptr, size_t len,
nlen = p0 - buf;
}
}
- if (!nlen) /* Nothing to be synchronized */
- goto cleanup;
- if (get_ttyp ()->switch_to_pcon_out && !is_echo)
- goto cleanup;
/* Remove ESC sequence which returns results to console
input buffer. Without this, cursor position report
is put into the input buffer as a garbage. */
@@ -1413,6 +1409,10 @@ fhandler_pty_slave::push_to_pcon_screenbuffer (const char *ptr, size_t len,
memmove (p0, p0+4, nlen - (p0+4 - buf));
nlen -= 4;
}
+ if (!nlen) /* Nothing to be synchronized */
+ goto cleanup;
+ if (get_ttyp ()->switch_to_pcon_out && !is_echo)
+ goto cleanup;
/* If the ESC sequence ESC[?3h or ESC[?3l which clears console screen
buffer is pushed, set need_redraw_screen to trigger redraw screen. */
@@ -1504,6 +1504,15 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
reset_switch_to_pcon ();
+ bool screen_alternated_orig = get_ttyp ()->screen_alternated;
+ /* Push slave output to pseudo console screen buffer */
+ if (get_pseudo_console () && !screen_alternated_orig)
+ {
+ acquire_output_mutex (INFINITE);
+ push_to_pcon_screenbuffer ((char *)ptr, len, false);
+ release_output_mutex ();
+ }
+
bool output_to_pcon =
get_ttyp ()->switch_to_pcon_out && !get_ttyp ()->screen_alternated;
@@ -1564,7 +1573,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
restore_reattach_pcon ();
/* Push slave output to pseudo console screen buffer */
- if (get_pseudo_console ())
+ if (get_pseudo_console () && screen_alternated_orig)
{
acquire_output_mutex (INFINITE);
push_to_pcon_screenbuffer ((char *)ptr, len, false);
--
2.26.2
More information about the Cygwin-patches
mailing list