tlf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tlf-devel] Improved keyboard handling


From: Nate Bargmann
Subject: [Tlf-devel] Improved keyboard handling
Date: Sun, 3 Jan 2016 21:42:14 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

After much study and searching and playing around, writing and testing
code, and learning just how much difference there is between terminal
emulators (and I've hardly scratched the surface), I am attaching two
files for your testing pleasure.  ;-)

The idea is to enable Ncurses keypad mode and utilize the constants that
keyname() recognizes as much as possible.  The new-onechar.c file is
essentially a reworked copy of ui_utils.c that can be compiled with the
following command:

    gcc -o new-onechar -lncurses new-onechar.c

When the program runs it will print the decimal ordinal of the pressed
key and its name as returned by keyname().  Use Ctl-D exit.  In the
main() function ncurses is initialized as closely as possible to Tlf to
avoid such differences.

Of note is the use of the set_escdelay() function to lower the time
getch() will wait from the default of 1000 mS to 25 mS.  On my machines
this is fast enough to process Alt-keys and other keys that have codes
beginning with a value of 27 (^[ or Escape).  The downside is that
someone that must use Escape in place of Alt will not be able to.  The
small value was chosen to call stoptx() as soon as possible while
allowing sufficient time to receive multi value escaped keys.

A look at the new onechar() function show several test sections.  I
found this necessary to assign various Alt-key combinations into the
constants that keyname() will return as M-key--M-a, M-b, etc.  Also some
keys are terminal specific.  Thus far I have tested this on Xfce
Terminal, Gnome Terminal, Xterm, and the Linux console as found in
Debian 8.  Other peculiarities likely lurk out there.  I was surprised
just how much variation there is just between the ones I tested.  To
determine the sent codes I used 'showkey -a' in each terminal.  One
oddity I found is that on the Linux console on my ThinkPad T410 laptop
is that Shift-F9 through Shift-F12 produced no keystrokes.

At this time all keys among the terminals are processed into a
definition as found in the other attached file, names.txt.

Implementing this will require a fair amount of care and I have not yet
begun the process of doing so.  For the most part, the work will consist
of replacing one numeric constant with another in various places.
Sometimes a named constant like KEY_HOME or KEY_BACKSPACE may be
substituted.

Before that I would like to hear back from others who will test this on
various terminals and report back any unrecognized keys and their key
codes as shown by 'showkey -a'.

Have fun!

73, Nate

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Ham radio, Linux, bikes, and more: http://www.n0nb.us

Attachment: names.txt
Description: Text document

Attachment: new-onechar.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]