public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: console: Add support for REP escape sequence to xterm mode.
Date: Wed, 26 Feb 2020 20:22:00 -0000	[thread overview]
Message-ID: <20200226202232.25630.qmail@sourceware.org> (raw)

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

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

    Cygwin: console: Add support for REP escape sequence to xterm mode.
    
    - In Win10 upto 1809, xterm compatible mode does not have REP
      escape sequence which terminfo declares. This patch adds support
      for "CSI Ps b" (REP). With this patch, bvi (binary editor) works
      normally in Win10 1809. Also, xterm compatible mode does not have
      "CSI Pm `" (HPA), "CSI Pm a" (HPR) and "CSI Ps e" (VPR). However,
      they do not appear to be declared by terminfo. Therefore, these
      have been pending.

Diff:
---
 winsup/cygwin/fhandler_console.cc | 33 +++++++++++++++++++++++++++++++++
 winsup/cygwin/wincap.cc           | 10 ++++++++++
 winsup/cygwin/wincap.h            |  2 ++
 3 files changed, 45 insertions(+)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index fbeccff..f87d932 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -62,6 +62,7 @@ static struct fhandler_base::rabuf_t con_ra;
 #define WPBUF_LEN 256
 static unsigned char wpbuf[WPBUF_LEN];
 static int wpixput;
+static unsigned char last_char;
 #define wpbuf_put(x) \
   wpbuf[wpixput++] = x; \
   if (wpixput > WPBUF_LEN) \
@@ -2009,6 +2010,37 @@ fhandler_console::char_command (char c)
       DWORD wn;
       switch (c)
 	{
+#if 0 /* These sequences, which are supported by real xterm, are
+	 not supported by xterm compatible mode. Therefore they
+	 were implemented once. However, these are not declared
+	 in terminfo of xterm-256color, therefore, do not appear
+	 to be necessary. */
+	case '`': /* HPA */
+	  if (con.args[0] == 0)
+	    con.args[0] = 1;
+	  cursor_get (&x, &y);
+	  cursor_set (false, con.args[0]-1, y);
+	  break;
+	case 'a': /* HPR */
+	  if (con.args[0] == 0)
+	    con.args[0] = 1;
+	  cursor_rel (con.args[0], 0);
+	  break;
+	case 'e': /* VPR */
+	  if (con.args[0] == 0)
+	    con.args[0] = 1;
+	  cursor_rel (0, con.args[0]);
+	  break;
+#endif
+	case 'b': /* REP */
+	  wpbuf_put (c);
+	  if (wincap.has_con_esc_rep ())
+	    /* Just send the sequence */
+	    WriteConsoleA (get_output_handle (), wpbuf, wpixput, &wn, 0);
+	  else if (last_char && last_char != '\n')
+	    for (int i = 0; i < con.args[0]; i++)
+	      WriteConsoleA (get_output_handle (), &last_char, 1, &wn, 0);
+	  break;
 	case 'r': /* DECSTBM */
 	  con.scroll_region.Top = con.args[0] ? con.args[0] - 1 : 0;
 	  con.scroll_region.Bottom = con.args[1] ? con.args[1] - 1 : -1;
@@ -2746,6 +2778,7 @@ fhandler_console::write_normal (const unsigned char *src,
 	  break;
 	default:
 	  found += ret;
+	  last_char = *(found - 1);
 	  break;
 	}
     }
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 714a6d4..922705e 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -44,6 +44,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_24bit_colors:false,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -73,6 +74,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_24bit_colors:false,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -102,6 +104,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_24bit_colors:false,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -131,6 +134,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
     has_con_24bit_colors:false,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -160,6 +164,7 @@ wincaps  wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
     has_con_24bit_colors:false,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -189,6 +194,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_24bit_colors:true,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -218,6 +224,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_24bit_colors:true,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -247,6 +254,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_24bit_colors:true,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -276,6 +284,7 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_24bit_colors:true,
     has_con_broken_csi3j:true,
     has_con_broken_il_dl:false,
+    has_con_esc_rep:false,
   },
 };
 
@@ -305,6 +314,7 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) =
     has_con_24bit_colors:true,
     has_con_broken_csi3j:false,
     has_con_broken_il_dl:true,
+    has_con_esc_rep:true,
   },
 };
 
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index f85a888..6d7a1ea 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -38,6 +38,7 @@ struct wincaps
     unsigned has_con_24bit_colors		: 1;
     unsigned has_con_broken_csi3j		: 1;
     unsigned has_con_broken_il_dl		: 1;
+    unsigned has_con_esc_rep			: 1;
   };
 };
 
@@ -99,6 +100,7 @@ public:
   bool	IMPLEMENT (has_con_24bit_colors)
   bool	IMPLEMENT (has_con_broken_csi3j)
   bool	IMPLEMENT (has_con_broken_il_dl)
+  bool	IMPLEMENT (has_con_esc_rep)
 
   void disable_case_sensitive_dirs ()
   {


                 reply	other threads:[~2020-02-26 20:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226202232.25630.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).