public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: console: Fix OSC sequence handling.
Date: Thu,  2 Dec 2021 08:46:09 +0000 (GMT)	[thread overview]
Message-ID: <20211202084609.639D83858D28@sourceware.org> (raw)

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

commit 5cc4b92c25af1af9250e4498e60943fcc82b7487
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Dec 2 12:35:47 2021 +0900

    Cygwin: console: Fix OSC sequence handling.
    
    - Currently, some OSC escape sequences, such as 'OSC 110 BEL', are
      not handled correctly. This patch fixes the issue.

Diff:
---
 winsup/cygwin/fhandler_console.cc | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 4b7922dea..68567f9a8 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -3308,13 +3308,30 @@ fhandler_console::write (const void *vsrc, size_t len)
 	case gotrsquare:
 	  if (isdigit (*src))
 	    con.rarg = con.rarg * 10 + (*src - '0');
-	  else if (*src == ';' && (con.rarg == 2 || con.rarg == 0))
-	    con.state = gettitle;
-	  else if (*src == ';' && (con.rarg == 4 || con.rarg == 104
-				   || (con.rarg >= 10 && con.rarg <= 19)))
-	    con.state = eatpalette;
-	  else
-	    con.state = eattitle;
+	  else if (*src == ';')
+	    {
+	      if (con.rarg == 0 || con.rarg == 2)
+		con.state = gettitle;
+	      else if ((con.rarg >= 4 && con.rarg <= 6)
+		       || (con.rarg >=10 && con.rarg <= 19)
+		       || (con.rarg >=104 && con.rarg <= 106)
+		       || (con.rarg >=110 && con.rarg <= 119))
+		con.state = eatpalette;
+	      else
+		con.state = eattitle;
+	    }
+	  else if (*src == '\033')
+	    con.state = endpalette;
+	  else if (*src == '\007')
+	    {
+	      wpbuf.put (*src);
+	      if (wincap.has_con_24bit_colors () && !con_is_legacy)
+		wpbuf.send (get_output_handle ());
+	      wpbuf.empty ();
+	      con.state = normal;
+	      src++;
+	      break;
+	    }
 	  wpbuf.put (*src);
 	  src++;
 	  break;


                 reply	other threads:[~2021-12-02  8:46 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=20211202084609.639D83858D28@sourceware.org \
    --to=tyan0@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).