[Top][All Lists]

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

[Nano-devel] Input overhaul: more info, need testing

From: David Lawrence Ramsey
Subject: [Nano-devel] Input overhaul: more info, need testing
Date: Tue, 12 Aug 2003 19:38:26 -0700 (PDT)

The mess with Backspace and Delete got me thinking about design issues. 
I figure that if you want to change how a key is interpreted, you
shouldn't have to hack two different input routines in two different
files (since we only use one interface) to do it.  With this basic idea
in mind, I want to try and clean up and/or consolidate the input code.

All the new input routines are now in one file: winio.c.  -K has been
removed, keypad() is now always TRUE, and -d has been added.  This was
tricky to graft onto CVS in some places due to the complexity of all the
nested switch statements used to interpret escape sequences and the
like, but after some testing, I think I got it right.

Details of the new input routines:

* Escape sequences are handled by the get_escape_seq_kbinput() function. 
This may seem like overkill seeing as how only one escape sequence is
currently handled by the new code, but if there are any other broken
terminals that generate escape sequences in keypad mode, it'll be easy
to add them with this function in place.

* Keys that should be globally ignored are now handled by
get_ignored_kbinput(): ERR, KEY_RESIZE (the "410" in the original
comment in nano.c), and the various PDCurses-specific keys for Alt,
Control, etc.

* The translation done by the new code adds some functionality.  For
example, KEY_NPAGE is translated into NANO_NEXTPAGE_KEY in
get_accepted_kbinput() before being returned in get_kbinput(), which
means that pressing Page Down (translated as Ctrl-V) at the statusbar
prompt will move to the end of the file, instead of being passed through
the statusbar input routine, cut down to ASCII range, and displayed as

* Reliance on hardcoded numeric values is minimal.  407, which is
generated by Ctrl-Z at the Linux console with keypad(TRUE), is
KEY_SUSPEND according to ncurses.h, and 343, which is sometimes
generated by Enter on the iris-ansi terminal, is KEY_ENTER.  Both of
these values are now handled in get_accepted_kbinput().

* Slang doesn't define KEY_SUSPEND at all, internally or in ncurses
emulation mode.  I've taken a cue from the workaround for KEY_UP and
KEY_DOWN's not being defined on HP-UX and defined KEY_SUSPEND as -1 if
slang is enabled.  Fortunately, pressing Ctrl-Z at the Linux console
with keypad(TRUE) under slang generates Ctrl-Z, so suspend still works
properly then.

* One of Pico's apparently undocumented features is now supported via
the get_ascii_kbinput() function: pressing Escape twice and then typing
in a three-digit number from 000 to 255 will now make nano act as though
you typed the character with the corresponding ASCII code.  The verbatim
input code now does that too if you type in a three-digit number from
000 to 255 while in verbatim input mode.

* Pressing Escape twice and then typing a character now works for all
the control sequences I've been able to find (except of course for Esc
Esc 2 [ASCII 0], which gets intercepted by the code for the above

* One minor input issue is now fixed: the keystroke commands included
for Pico compatibility in the file browser don't quite match those used
in the latest version of Pico.  Note that 'd' [delete file] and 'r'
[rename file] are not implemented.

The new routines should fix the FreeBSD input problems, but they need
testing so I can be sure of that.  So would everyone please test the
patch thoroughly on their boxes?  (It seems to work fine on my box and on
my account on Jordi's Debian box.)  Thanks.

Sluggy.Net: The Sluggy Freelance Community!

reply via email to

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