www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/04/11/08:28:24

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sun, 11 Apr 2010 14:28:09 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 1.7.3: Backspace key not working in GNU screen.
Message-ID: <20100411122809.GO28908@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <u2v49e721a81004081305q61e00044hba10b82e6900aa3d AT mail DOT gmail DOT com> <q2q49e721a81004081307q2db70190p176cd745b2a78388 AT mail DOT gmail DOT com> <m2n416096c61004100231je0fea482s7a9a7d2e82cd2792 AT mail DOT gmail DOT com> <20100410140811 DOT GA8593 AT ednor DOT casa DOT cgf DOT cx> <p2k416096c61004100900j2d3b3567gdd068feb17547ec3 AT mail DOT gmail DOT com> <20100410161626 DOT GA1904 AT ednor DOT casa DOT cgf DOT cx> <20100410173607 DOT GA3986 AT ednor DOT casa DOT cgf DOT cx> <20100410181700 DOT GA7321 AT ednor DOT casa DOT cgf DOT cx> <i2t416096c61004101409ka5c18517obfc3a09e284a0e98 AT mail DOT gmail DOT com> <20100411093305 DOT GN28908 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20100411093305.GN28908@calimero.vinschen.de>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Apr 11 11:33, Corinna Vinschen wrote:
> On Apr 10 22:09, Andy Koppe wrote:
> > Christopher Faylor wrote:
> > > The problem is that screen explicitly sets VERASE to 0.  I believe that
> > > it does that to mean "there is really no erase character since I'm
> > > handling that".
> > 
> > You're right. Zero is the value of the _POSIX_VDISABLE constant for
> > disabling special characters. Therefore, using c_cc[VERASE] as the
> > backspace keycode was a bad idea all along. Sorry for suggesting it in
> > the first place.
> > 
> > > That should not cause Cygwin to send a null character.
> > > I think it should probably just send the default \177 character.
> > 
> > Makes sense given the botched design, but of course it does mean that
> > the user's backspace keycode setting is ignored. Also, 'screen' would
> > be expecting what was set in c_cc[VERASE] as the backspace keycode.
> 
> That would be surprising.  If you set VEARSE to 0 on Linux, a following
> tcgetattr returns 0 as the VERASE value.  stty prints "<undef>".  The
> same holds true for other settings like VKILL, VINTR, etc.  So, if the
> process sets VERASE to 0, and is then puzzled to get a 0 VERASE value
> from the OS, it's the application's fault.

I think I see what you mean now.  The c_cc[VERASE] value is the one
which is expected for the VERASE functionality (unless it's set to
0 == _POSIX_VDISABLE), but it has nothing to do with the actual setting
of the backspace key in the terminal.  So, actually the key value should
not be stored in c_cc[VERASE] at all, and it should not be possible to
set the value returned by the backspace key via tcsetattr.

So, what we really need to implement is what you proposed.  I prepared
a patch, see below.  It seems to work nicely and you can easily switch
the backspace character now via the DECBKM escape codes.  If everybody
agrees with this solution, I'll check it in.


Corinna


	* fhandler.h (class dev_console): Add backspace_keycode member.
	* fhandler_console.cc (fhandler_console::get_tty_stuff): Initialize
	backspace_keycode with CERASE.
	(fhandler_console::read): Return dev_state->backspace_keycode if the
	backspace key is pressed.
	(fhandler_console::char_command): Implement DECBKM escape sequence.


Index: fhandler.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v
retrieving revision 1.398
diff -u -p -r1.398 fhandler.h
--- fhandler.h	2 Apr 2010 22:36:43 -0000	1.398
+++ fhandler.h	11 Apr 2010 12:24:51 -0000
@@ -924,6 +924,7 @@ class dev_console
   bool iso_2022_G1;
   bool alternate_charset_active;
   bool metabit;
+  char backspace_keycode;
 
   char my_title_buf [TITLESIZE + 1];
 
Index: fhandler_console.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_console.cc,v
retrieving revision 1.217
diff -u -p -r1.217 fhandler_console.cc
--- fhandler_console.cc	10 Apr 2010 18:05:52 -0000	1.217
+++ fhandler_console.cc	11 Apr 2010 12:24:51 -0000
@@ -118,6 +118,7 @@ fhandler_console::get_tty_stuff (int fla
       if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0))) == LANG_ENGLISH)
 	dev_state->meta_mask |= RIGHT_ALT_PRESSED;
       dev_state->set_default_attr ();
+      dev_state->backspace_keycode = CERASE;
       shared_console_info->tty_min_state.sethwnd ((HWND) INVALID_HANDLE_VALUE);
     }
 
@@ -374,10 +375,9 @@ fhandler_console::read (void *pv, size_t
 	  if (control_key_state & LEFT_ALT_PRESSED)
 	    dev_state->nModifiers |= 8;
 
-	  /* Send the VERASE character from the terminal settings as backspace keycode. */
 	  if (input_rec.Event.KeyEvent.wVirtualScanCode == 14)
 	    {
-	      char c = ti.c_cc[VERASE] ?: CERASE;
+	      char c = dev_state->backspace_keycode;
 	      nread = 0;
 	      if (control_key_state & ALT_PRESSED) {
 		if (dev_state->metabit)
@@ -1398,6 +1398,10 @@ fhandler_console::char_command (char c)
 	    }
 	  break;
 
+	case 67: /* DECBKM ("DEC Backarrow Key Mode") */
+	  dev_state->backspace_keycode = (c == 'h' ? CTRL('H') : CERASE);
+	  break;
+
 	case 1000: /* Mouse tracking */
 	  dev_state->use_mouse = (c == 'h') ? 1 : 0;
 	  syscall_printf ("mouse support set to mode %d", dev_state->use_mouse);

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019