public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: console: Unify workaround code for CSI3J and CSI?1049h/l.
@ 2020-02-26 20:22 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-02-26 20:22 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3b42762e0b02ad53cc01dd752b94a044b7a42ebf

commit 3b42762e0b02ad53cc01dd752b94a044b7a42ebf
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Feb 27 00:33:00 2020 +0900

    Cygwin: console: Unify workaround code for CSI3J and CSI?1049h/l.
    
    - This patch unifies workaround code for CSI3J and CSI?1049h/l into
      the code handling other escape sequences in xterm mode.

Diff:
---
 winsup/cygwin/fhandler_console.cc | 43 ++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 3f756c5..fbeccff 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1786,24 +1786,6 @@ static const wchar_t __vt100_conv[31] = {
 inline bool
 fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done)
 {
-  bool need_fix_tab_position = false;
-  /* Check if screen will be alternated. */
-  if (wincap.has_con_24bit_colors () && !con_is_legacy
-      && memmem (buf, len*sizeof (WCHAR), L"\033[?1049", 7*sizeof (WCHAR)))
-    need_fix_tab_position = true;
-  /* Workaround for broken CSI3J (ESC[3J) support in xterm compatible mode. */
-  if (wincap.has_con_24bit_colors () && !con_is_legacy &&
-      wincap.has_con_broken_csi3j ())
-    {
-      WCHAR *p = buf;
-      while ((p = (WCHAR *) memmem (p, (len - (p - buf))*sizeof (WCHAR),
-				    L"\033[3J", 4*sizeof (WCHAR))))
-	{
-	  memmove (p, p+4, (len - (p+4 - buf))*sizeof (WCHAR));
-	  len -= 4;
-	}
-    }
-
   if (con.iso_2022_G1
 	? con.vt100_graphics_mode_G1
 	: con.vt100_graphics_mode_G0)
@@ -1822,9 +1804,6 @@ fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done)
       len -= done;
       buf += done;
     }
-  /* Call fix_tab_position() if screen has been alternated. */
-  if (need_fix_tab_position)
-    fix_tab_position ();
   return true;
 }
 
@@ -2089,6 +2068,28 @@ fhandler_console::char_command (char c)
 	      WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
 	    }
 	  break;
+	case 'J': /* ED */
+	  wpbuf_put (c);
+	  /* Ignore CSI3J in Win10 1809 because it is broken. */
+	  if (con.args[0] != 3 || !wincap.has_con_broken_csi3j ())
+	    WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
+	  break;
+	case 'h': /* DECSET */
+	case 'l': /* DECRST */
+	  wpbuf_put (c);
+	  /* Just send the sequence */
+	  WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
+	  if (con.saw_question_mark)
+	    {
+	      bool need_fix_tab_position = false;
+	      for (int i = 0; i < con.nargs; i++)
+		if (con.args[i] == 1049)
+		  need_fix_tab_position = true;
+	      /* Call fix_tab_position() if screen has been alternated. */
+	      if (need_fix_tab_position)
+		fix_tab_position ();
+	    }
+	  break;
 	default:
 	  /* Other escape sequences */
 	  wpbuf_put (c);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-26 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 20:22 [newlib-cygwin] Cygwin: console: Unify workaround code for CSI3J and CSI?1049h/l Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).