delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/24/05:10:12

Date: Mon, 24 May 1999 12:06:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mark E." <snowball3 AT bigfoot DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: ctrl+space and termios/tminit.c
In-Reply-To: <199905232203.WAA92108@out1.ibm.net>
Message-ID: <Pine.SUN.3.91.990524120254.14456N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 23 May 1999, Mark E. wrote:

> __direct_ctrlsense() returns the state of the ctrl key at the time of the 
> interrupt call. However, since the keyboard is buffered, it's possible the 
> key returned from __direct_keyinput() was typed long enough ago so 
> that the ctrl-key is longer pressed once __direct_ctrlsense() is called 
> and so the space will be left as-is or worse if a regular space is typed 
> before the ctrl+space then the regular space will be converted to ascii 
> 0.

Right.  There's no solution for that particular problem, unless you
maintain a keyboard queue which is filled by a hardware keyboard
interrupt handler.

The funny thing is, we already have such a handler in every DJGPP
program: it's the one that generates SIGINT when you press Ctrl-C.
The only thing we need is a few lines of code to stash away the scan
code, ASCII code, and the two keyboard status bytes, and then let the
application read from the queue (all conditioned on some flag variable
that application sets to use this input mode).

Btw, this problem is not limited to Ctrl-SPACE, Alt-modified keys have
it as well.  For example, any Alt-<x> (where <x> is any alphabetic key) 
will get you into the same problem, although in this case it can be 
worked around by looking at the scan code (which is always zero for
these combinations).

> Perhaps this feature should be removed?

I don't recommend removing it.  Emacs uses the same input through BIOS
as termios does.  While the possibility of such mishaps is real (I even
saw it several times), and it is greater still as Emacs does a lot of
processing on every key you press, in practice it is so rare that is
easily discarded as a typo.

FWIW, I really think we should implement interrupt-driven keyboard
queue in v2.04.  That would solve such problems with minimal fuss.

- Raw text -


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