bug-ncurses
[Top][All Lists]
Advanced

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

Re: Numeric codes of non-standard function keys


From: Thomas Dickey
Subject: Re: Numeric codes of non-standard function keys
Date: Thu, 14 Dec 2023 19:00:38 -0500

On Thu, Dec 14, 2023 at 04:54:25PM +0100, Anton Vidovic wrote:
> Hello,
> 
> The numeric codes retured by getch for the more common function
> keys KEY_BREAK (257) to KEY_RESIZE (410) are hard-coded in
> curses.h.

They're generated rather than hard-coded.
The values actually are "predefined" (they happen to match Solaris,
with KEY_RESIZE added.

https://github.com/ThomasDickey/ncurses-snapshots/blob/master/include/MKkey_defs.sh

ncurses can be compiled for a few other arrangements).

https://invisible-island.net/ncurses/INSTALL.html#option:with-caps
 
> Is there a logic behind the assignmet of the numeric codes of the
> non-standard function keys, for example the xterm range 517 (kDC3)

Those are generated automatically, as a terminal description is loaded.
They're basically just a table index (as the predefined codes are).

infocmp calls an internal function to align the tables so that
same names have the same index.  (The "-u" option of infocmp works
by aligning multiple entries - I've been developing a script using
this, recently, making some fixes to "-u").

In an ncurses application, you can use key_defined() with the string
returned by tigetstr() to get the key code.  The test/demo_defkey.c
program demonstrates this.

https://github.com/ThomasDickey/ncurses-snapshots/blob/master/test/demo_defkey.c

test/foldkeys.c shows another use for key_defined().

https://github.com/ThomasDickey/ncurses-snapshots/blob/master/test/foldkeys.c

key_defined() relies upon some initialization done to support the keypad
function, which I realize is more limited than I'd like -- wouldn't work for a
dumb termcap program -- another fix for todo's.

Though I added those key_defined and define_key functions about 20 years ago,
few developers notice them.

> to 568 (kUP7)? Are those used as bitmasks for the modifiers
> Ctrl, Shift and Alt? If yes, could you point me to where this is
> described? If not, is there a way to find out which modifier is
> active for that key other than parsing the escape sequences?

ncurses doesn't do anything with modifiers.  Unlike PDCurses which
deals with systems that provide that information, curses is more
general.  Not everything is xterm or something that copies from xterm.

The key definitions for modified keys are named according to a convention.
Those names are described in user_caps(5).

https://invisible-island.net/ncurses/man/user_caps.5.html
 
> If other terminals/emulators have other function keys, which
> codes are assigned to them?
> 
> Which numeric codes are used for new sequences that can be added
> by `define_key', is there a logic or a defined range behind that?

no - that's up to an application developer

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

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