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: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.
Date: Fri, 11 Feb 2022 00:11:47 +0000 (GMT)	[thread overview]
Message-ID: <20220211001147.6F27F3858D1E@sourceware.org> (raw)

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

commit 8a95249d738cd46299c72a5da8150b4bba0a7e95
Author: Mitchell Hentges <mhentges@mozilla.com>
Date:   Thu Feb 10 10:38:08 2022 -0500

    Cygwin: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.
    
    - Currently, ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE are cleared
      if cygwin is started in console. These flags will not be recovered
      even when exiting from cygwin. Also note that if ENABLE_EXTENDED_FLAGS
      is once unset, then the flag ENABLE_QUICK_EDIT_MODE it's associated
      with will no longer be preserved. Unfortunately, we're accidentally
      stepping on this in fhandler_console::set_input_mode().
    
      This patch solves this by carrying forward these flags in the place
      where it had been ignoring them. Since the previous behaviour of
      leaving these flags unset would essentially maintain their existing
      state, adding the carry-over of the flags now should not alter console
      behaviour.

Diff:
---
 winsup/cygwin/fhandler_console.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 7a1a45bc1..b28dd66f5 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -458,16 +458,18 @@ void
 fhandler_console::set_input_mode (tty::cons_mode m, const termios *t,
 				  const handle_set_t *p)
 {
-  DWORD flags = 0, oflags;
+  DWORD oflags;
   WaitForSingleObject (p->input_mutex, mutex_timeout);
   GetConsoleMode (p->input_handle, &oflags);
+  DWORD flags = oflags
+    & (ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE);
   switch (m)
     {
     case tty::restore:
-      flags = ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
+      flags |= ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
       break;
     case tty::cygwin:
-      flags = ENABLE_WINDOW_INPUT;
+      flags |= ENABLE_WINDOW_INPUT;
       if (wincap.has_con_24bit_colors () && !con_is_legacy)
 	flags |= ENABLE_VIRTUAL_TERMINAL_INPUT;
       else


                 reply	other threads:[~2022-02-11  0:11 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=20220211001147.6F27F3858D1E@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).