move synthesized events beyond unicode

pull/2345/head
nick black 3 years ago
parent 3e201adf38
commit 9065975a3c
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -647,76 +647,23 @@ must be readable without delay for it to be interpreted as such.
```c
// All input is taken from stdin. We attempt to read a single UTF8-encoded
// Unicode codepoint, *not* an entire Extended Grapheme Cluster. It is also
// possible that we will read a special keypress, i.e. anything that doesn't
// correspond to a Unicode codepoint (e.g. arrow keys, function keys, screen
// resize events, etc.). These are mapped into Unicode's Supplementary
// Private Use Area-B, starting at U+100000. See <notcurses/nckeys.h>.
// possible that we will produce a synthesized event, i.e. anything that
// doesn't correspond to a Unicode codepoint (e.g. arrow keys, function keys,
// screen resize events, etc.). The full list of synthesized events can be
// found in <notcurses/nckeys.h>.
//
// notcurses_get_nblock() is nonblocking. notcurses_get_blocking() blocks
// until a codepoint or special key is read, or until interrupted by a signal.
// notcurses_get() allows an optional timeout to be controlled.
//
// In the case of a valid read, a 32-bit Unicode codepoint is returned. 0 is
// returned to indicate that no input was available. Otherwise (including on
// EOF) (uint32_t)-1 is returned.
#define suppuabize(w) ((w) + 0x100000)
// Special composed key definitions. These values are added to 0x100000.
#define NCKEY_INVALID suppuabize(0)
#define NCKEY_RESIZE suppuabize(1) // generated internally in response to SIGWINCH
#define NCKEY_UP suppuabize(2)
#define NCKEY_RIGHT suppuabize(3)
#define NCKEY_DOWN suppuabize(4)
#define NCKEY_LEFT suppuabize(5)
#define NCKEY_INS suppuabize(6)
#define NCKEY_DEL suppuabize(7)
#define NCKEY_BACKSPACE suppuabize(8) // backspace (sometimes)
#define NCKEY_PGDOWN suppuabize(9)
#define NCKEY_PGUP suppuabize(10)
#define NCKEY_HOME suppuabize(11)
#define NCKEY_END suppuabize(12)
#define NCKEY_F00 suppuabize(20)
#define NCKEY_F01 suppuabize(21)
#define NCKEY_F02 suppuabize(22)
#define NCKEY_F03 suppuabize(23)
#define NCKEY_F04 suppuabize(24)
// ... up to 100 function keys, egads
#define NCKEY_ENTER suppuabize(121)
#define NCKEY_CLS suppuabize(122) // "clear-screen or erase"
#define NCKEY_DLEFT suppuabize(123) // down + left on keypad
#define NCKEY_DRIGHT suppuabize(124)
#define NCKEY_ULEFT suppuabize(125) // up + left on keypad
#define NCKEY_URIGHT suppuabize(126)
#define NCKEY_CENTER suppuabize(127) // the most truly neutral of keypresses
#define NCKEY_BEGIN suppuabize(128)
#define NCKEY_CANCEL suppuabize(129)
#define NCKEY_CLOSE suppuabize(130)
#define NCKEY_COMMAND suppuabize(131)
#define NCKEY_COPY suppuabize(132)
#define NCKEY_EXIT suppuabize(133)
#define NCKEY_PRINT suppuabize(134)
#define NCKEY_REFRESH suppuabize(135)
// Mouse events. We try to encode some details into the uint32_t (i.e. which
// button was pressed), but some is embedded in the ncinput event. The release
// event is generic across buttons; callers must maintain state, if they care.
#define NCKEY_BUTTON1 suppuabize(201)
#define NCKEY_BUTTON2 suppuabize(202)
#define NCKEY_BUTTON3 suppuabize(203)
// ... up to 11 mouse buttons
#define NCKEY_EOF suppuabize(300)
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
static inline bool
nckey_supppuab_p(uint32_t w){
return w >= 0x100000 && w <= 0x10fffd;
}
// In the case of a valid read, the provided ncinput is filled in, and the
// id field is returned. 0 is returned to indicate that no input was available.
// On any error, (uint32_t)-1 is returned.
// An input event. Cell coordinates are currently defined only for mouse events.
typedef struct ncinput {
uint32_t id; // identifier. Unicode codepoint or synthesized NCKEY event
int y; // y cell coordinate of event, -1 for undefined
int x; // x cell coordinate of event, -1 for undefined
uint32_t id; // identifier (unicode codepoint or synthesized NCKEY event)
int y, x; // y/x cell coordinate of event, -1 for undefined
bool alt; // was alt held?
bool shift; // was shift held?
bool ctrl; // was ctrl held?
@ -726,6 +673,7 @@ typedef struct ncinput {
NCTYPE_REPEAT,
NCTYPE_RELEASE,
} evtype;
int ypx, xpx; // pixel offsets within cell, -1 for undefined
} ncinput;
// Read a UTF-32-encoded Unicode codepoint from input. This might only be part

@ -45,11 +45,11 @@ typedef struct ncinput {
**int notcurses_getvec(struct notcurses* ***n***, const struct timespec* ***ts***, ncinput* ***ni***, int vcount);**
**uint32_t notcurses_getc_nblock(struct notcurses* ***n***, ncinput* ***ni***);**
**uint32_t notcurses_get_nblock(struct notcurses* ***n***, ncinput* ***ni***);**
**uint32_t notcurses_getc_blocking(struct notcurses* ***n***, ncinput* ***ni***);**
**uint32_t notcurses_get_blocking(struct notcurses* ***n***, ncinput* ***ni***);**
**int notcurses_mice_enable(struct notcurses* ***n***, unsigned ***eventmask***);**
**int cnotcurses_mice_enable(struct notcurses* ***n***, unsigned ***eventmask***);**
**int notcurses_mice_disable(struct notcurses* ***n***);**
@ -65,9 +65,9 @@ typedef struct ncinput {
notcurses supports input from keyboards and mice, and any device that looks
like them. Mouse support requires a broker such as GPM, Wayland, or Xorg, and
must be explicitly enabled via **notcurses_mouse_enable**. The full 32-bit
must be explicitly enabled via **notcurses_mice_enable**. The full 32-bit
range of Unicode is supported (see **unicode(7)**), with synthesized events
mapped into the [Supplementary Private Use Area-B](https://unicode.org/charts/PDF/U1.0.10.pdf).
mapped above the 1,114,112 codepoints of Unicode 14.0's seventeen Planes.
Unicode characters are returned directly as UCS-32, one codepoint at a time.
notcurses takes its keyboard input from **stdin**, which will be placed into
@ -77,11 +77,11 @@ notcurses maintains its own buffer of input characters, which it will attempt
to fill whenever it reads.
**notcurses_get** allows a **struct timespec** to be specified as a timeout.
If **ts** is **NULL**, **notcurses_get** will block until it reads input, or
If ***ts*** is **NULL**, **notcurses_get** will block until it reads input, or
is interrupted by a signal. If its values are zeroes, there will be no
blocking. Otherwise, **ts** specifies an absolute deadline (taken against
blocking. Otherwise, ***ts*** specifies an absolute deadline (taken against
**CLOCK_MONOTONIC**; see **clock_gettime(2)**). On timeout, 0 is returned.
Event details will be reported in **ni**, unless **ni** is NULL.
Event details will be reported in ***ni***, unless ***ni*** is NULL.
**notcurses_inputready_fd** provides a file descriptor suitable for use with
I/O multiplexors such as **poll(2)**. This file descriptor might or might not
@ -179,6 +179,8 @@ contexts).
When support is detected, the Kitty keyboard disambiguation protocol will be
requested. This eliminates most of the **BUGS** mentioned below.
The full list of synthesized events is available in **<notcurses/nckeys.h>**.
# BUGS
The Shift key is not indicated in conjunction with typical Unicode text.

@ -96,6 +96,12 @@ namespace ncpp
static constexpr char32_t Copy = NCKEY_COPY;
static constexpr char32_t Exit = NCKEY_EXIT;
static constexpr char32_t Print = NCKEY_PRINT;
static constexpr char32_t CapsLock = NCKEY_CAPS_LOCK;
static constexpr char32_t ScrollLock= NCKEY_SCROLL_LOCK;
static constexpr char32_t NumLock = NCKEY_NUM_LOCK;
static constexpr char32_t PrintScreen= NCKEY_PRINT_SCREEN;
static constexpr char32_t Pause = NCKEY_PAUSE;
static constexpr char32_t Menu = NCKEY_MENU;
static constexpr char32_t Refresh = NCKEY_REFRESH;
static constexpr char32_t Button1 = NCKEY_BUTTON1;
static constexpr char32_t Button2 = NCKEY_BUTTON2;
@ -117,7 +123,12 @@ namespace ncpp
return nckey_mouse_p (ch);
}
static bool IsSuppUAB (char32_t ch) noexcept
static bool IsSupPUAa (char32_t ch) noexcept
{
return nckey_supppuaa_p (ch);
}
static bool IsSupPUAb (char32_t ch) noexcept
{
return nckey_supppuab_p (ch);
}

@ -5,152 +5,168 @@
extern "C" {
#endif
#define suppuabize(w) ((w) + 0x100000)
// Synthesized input events, i.e. any input event we can report that isn't
// representative of some Unicode. This covers both keyboard and mouse events,
// as well as signals and even window events.
// Rather than using one of the Private Use Areas of Unicode, we use the area
// beyond the 17 65536-entry Planes (1114112). We round up to 5000 so that it's
// trivial to idenfity synthesized characters based on their numeric definition
// here. This is safe, since we needn't convert these synthesized characters
// into UTF8 (they would otherwise require more than four bytes).
#define PRETERUNICODEBASE 1115000
#define preterunicode(w) ((w) + PRETERUNICODEBASE)
// Special composed key definitions. These values are added to 0x100000.
#define NCKEY_INVALID suppuabize(0)
#define NCKEY_SIGNAL suppuabize(1) // we received either SIGWINCH or SIGCONT
#define NCKEY_UP suppuabize(2)
#define NCKEY_RIGHT suppuabize(3)
#define NCKEY_DOWN suppuabize(4)
#define NCKEY_LEFT suppuabize(5)
#define NCKEY_INS suppuabize(6)
#define NCKEY_DEL suppuabize(7)
#define NCKEY_BACKSPACE suppuabize(8) // backspace (sometimes)
#define NCKEY_PGDOWN suppuabize(9)
#define NCKEY_PGUP suppuabize(10)
#define NCKEY_HOME suppuabize(11)
#define NCKEY_END suppuabize(12)
#define NCKEY_F00 suppuabize(20)
#define NCKEY_F01 suppuabize(21)
#define NCKEY_F02 suppuabize(22)
#define NCKEY_F03 suppuabize(23)
#define NCKEY_F04 suppuabize(24)
#define NCKEY_F05 suppuabize(25)
#define NCKEY_F06 suppuabize(26)
#define NCKEY_F07 suppuabize(27)
#define NCKEY_F08 suppuabize(28)
#define NCKEY_F09 suppuabize(29)
#define NCKEY_F10 suppuabize(30)
#define NCKEY_F11 suppuabize(31)
#define NCKEY_F12 suppuabize(32)
#define NCKEY_F13 suppuabize(33)
#define NCKEY_F14 suppuabize(34)
#define NCKEY_F15 suppuabize(35)
#define NCKEY_F16 suppuabize(36)
#define NCKEY_F17 suppuabize(37)
#define NCKEY_F18 suppuabize(38)
#define NCKEY_F19 suppuabize(39)
#define NCKEY_F20 suppuabize(40)
#define NCKEY_F21 suppuabize(41)
#define NCKEY_F22 suppuabize(42)
#define NCKEY_F23 suppuabize(43)
#define NCKEY_F24 suppuabize(44)
#define NCKEY_F25 suppuabize(45)
#define NCKEY_F26 suppuabize(46)
#define NCKEY_F27 suppuabize(47)
#define NCKEY_F28 suppuabize(48)
#define NCKEY_F29 suppuabize(49)
#define NCKEY_F30 suppuabize(50)
#define NCKEY_F31 suppuabize(51)
#define NCKEY_F32 suppuabize(52)
#define NCKEY_F33 suppuabize(53)
#define NCKEY_F34 suppuabize(54)
#define NCKEY_F35 suppuabize(55)
#define NCKEY_F36 suppuabize(56)
#define NCKEY_F37 suppuabize(57)
#define NCKEY_F38 suppuabize(58)
#define NCKEY_F39 suppuabize(59)
#define NCKEY_F40 suppuabize(60)
#define NCKEY_F41 suppuabize(61)
#define NCKEY_F42 suppuabize(62)
#define NCKEY_F43 suppuabize(63)
#define NCKEY_F44 suppuabize(64)
#define NCKEY_F45 suppuabize(65)
#define NCKEY_F46 suppuabize(66)
#define NCKEY_F47 suppuabize(67)
#define NCKEY_F48 suppuabize(68)
#define NCKEY_F49 suppuabize(69)
#define NCKEY_F50 suppuabize(70)
#define NCKEY_F51 suppuabize(71)
#define NCKEY_F52 suppuabize(72)
#define NCKEY_F53 suppuabize(73)
#define NCKEY_F54 suppuabize(74)
#define NCKEY_F55 suppuabize(75)
#define NCKEY_F56 suppuabize(76)
#define NCKEY_F57 suppuabize(77)
#define NCKEY_F58 suppuabize(78)
#define NCKEY_F59 suppuabize(79)
#define NCKEY_F60 suppuabize(80)
#define NCKEY_INVALID preterunicode(0)
#define NCKEY_SIGNAL preterunicode(1) // we received either SIGWINCH or SIGCONT
#define NCKEY_UP preterunicode(2)
#define NCKEY_RIGHT preterunicode(3)
#define NCKEY_DOWN preterunicode(4)
#define NCKEY_LEFT preterunicode(5)
#define NCKEY_INS preterunicode(6)
#define NCKEY_DEL preterunicode(7)
#define NCKEY_BACKSPACE preterunicode(8) // backspace (sometimes)
#define NCKEY_PGDOWN preterunicode(9)
#define NCKEY_PGUP preterunicode(10)
#define NCKEY_HOME preterunicode(11)
#define NCKEY_END preterunicode(12)
#define NCKEY_F00 preterunicode(20)
#define NCKEY_F01 preterunicode(21)
#define NCKEY_F02 preterunicode(22)
#define NCKEY_F03 preterunicode(23)
#define NCKEY_F04 preterunicode(24)
#define NCKEY_F05 preterunicode(25)
#define NCKEY_F06 preterunicode(26)
#define NCKEY_F07 preterunicode(27)
#define NCKEY_F08 preterunicode(28)
#define NCKEY_F09 preterunicode(29)
#define NCKEY_F10 preterunicode(30)
#define NCKEY_F11 preterunicode(31)
#define NCKEY_F12 preterunicode(32)
#define NCKEY_F13 preterunicode(33)
#define NCKEY_F14 preterunicode(34)
#define NCKEY_F15 preterunicode(35)
#define NCKEY_F16 preterunicode(36)
#define NCKEY_F17 preterunicode(37)
#define NCKEY_F18 preterunicode(38)
#define NCKEY_F19 preterunicode(39)
#define NCKEY_F20 preterunicode(40)
#define NCKEY_F21 preterunicode(41)
#define NCKEY_F22 preterunicode(42)
#define NCKEY_F23 preterunicode(43)
#define NCKEY_F24 preterunicode(44)
#define NCKEY_F25 preterunicode(45)
#define NCKEY_F26 preterunicode(46)
#define NCKEY_F27 preterunicode(47)
#define NCKEY_F28 preterunicode(48)
#define NCKEY_F29 preterunicode(49)
#define NCKEY_F30 preterunicode(50)
#define NCKEY_F31 preterunicode(51)
#define NCKEY_F32 preterunicode(52)
#define NCKEY_F33 preterunicode(53)
#define NCKEY_F34 preterunicode(54)
#define NCKEY_F35 preterunicode(55)
#define NCKEY_F36 preterunicode(56)
#define NCKEY_F37 preterunicode(57)
#define NCKEY_F38 preterunicode(58)
#define NCKEY_F39 preterunicode(59)
#define NCKEY_F40 preterunicode(60)
#define NCKEY_F41 preterunicode(61)
#define NCKEY_F42 preterunicode(62)
#define NCKEY_F43 preterunicode(63)
#define NCKEY_F44 preterunicode(64)
#define NCKEY_F45 preterunicode(65)
#define NCKEY_F46 preterunicode(66)
#define NCKEY_F47 preterunicode(67)
#define NCKEY_F48 preterunicode(68)
#define NCKEY_F49 preterunicode(69)
#define NCKEY_F50 preterunicode(70)
#define NCKEY_F51 preterunicode(71)
#define NCKEY_F52 preterunicode(72)
#define NCKEY_F53 preterunicode(73)
#define NCKEY_F54 preterunicode(74)
#define NCKEY_F55 preterunicode(75)
#define NCKEY_F56 preterunicode(76)
#define NCKEY_F57 preterunicode(77)
#define NCKEY_F58 preterunicode(78)
#define NCKEY_F59 preterunicode(79)
#define NCKEY_F60 preterunicode(80)
// ... leave room for up to 100 function keys, egads
#define NCKEY_ENTER suppuabize(121)
#define NCKEY_CLS suppuabize(122) // "clear-screen or erase"
#define NCKEY_DLEFT suppuabize(123) // down + left on keypad
#define NCKEY_DRIGHT suppuabize(124)
#define NCKEY_ULEFT suppuabize(125) // up + left on keypad
#define NCKEY_URIGHT suppuabize(126)
#define NCKEY_CENTER suppuabize(127) // the most truly neutral of keypresses
#define NCKEY_BEGIN suppuabize(128)
#define NCKEY_CANCEL suppuabize(129)
#define NCKEY_CLOSE suppuabize(130)
#define NCKEY_COMMAND suppuabize(131)
#define NCKEY_COPY suppuabize(132)
#define NCKEY_EXIT suppuabize(133)
#define NCKEY_PRINT suppuabize(134)
#define NCKEY_REFRESH suppuabize(135)
#define NCKEY_ENTER preterunicode(121)
#define NCKEY_CLS preterunicode(122) // "clear-screen or erase"
#define NCKEY_DLEFT preterunicode(123) // down + left on keypad
#define NCKEY_DRIGHT preterunicode(124)
#define NCKEY_ULEFT preterunicode(125) // up + left on keypad
#define NCKEY_URIGHT preterunicode(126)
#define NCKEY_CENTER preterunicode(127) // the most truly neutral of keypresses
#define NCKEY_BEGIN preterunicode(128)
#define NCKEY_CANCEL preterunicode(129)
#define NCKEY_CLOSE preterunicode(130)
#define NCKEY_COMMAND preterunicode(131)
#define NCKEY_COPY preterunicode(132)
#define NCKEY_EXIT preterunicode(133)
#define NCKEY_PRINT preterunicode(134)
#define NCKEY_REFRESH preterunicode(135)
// these keys aren't generally available outside of the kitty protocol
#define NCKEY_CAPS_LOCK suppuabize(150)
#define NCKEY_SCROLL_LOCK suppuabize(151)
#define NCKEY_NUM_LOCK suppuabize(152)
#define NCKEY_PRINT_SCREEN suppuabize(153)
#define NCKEY_PAUSE suppuabize(154)
#define NCKEY_MENU suppuabize(155)
#define NCKEY_CAPS_LOCK preterunicode(150)
#define NCKEY_SCROLL_LOCK preterunicode(151)
#define NCKEY_NUM_LOCK preterunicode(152)
#define NCKEY_PRINT_SCREEN preterunicode(153)
#define NCKEY_PAUSE preterunicode(154)
#define NCKEY_MENU preterunicode(155)
// media keys, similarly only available through kitty's protocol
#define NCKEY_MEDIA_PLAY suppuabize(158)
#define NCKEY_MEDIA_PAUSE suppuabize(159)
#define NCKEY_MEDIA_PPAUSE suppuabize(160)
#define NCKEY_MEDIA_REV suppuabize(161)
#define NCKEY_MEDIA_STOP suppuabize(162)
#define NCKEY_MEDIA_FF suppuabize(163)
#define NCKEY_MEDIA_REWIND suppuabize(164)
#define NCKEY_MEDIA_NEXT suppuabize(165)
#define NCKEY_MEDIA_PREV suppuabize(166)
#define NCKEY_MEDIA_RECORD suppuabize(167)
#define NCKEY_MEDIA_LVOL suppuabize(168)
#define NCKEY_MEDIA_RVOL suppuabize(169)
#define NCKEY_MEDIA_MUTE suppuabize(170)
#define NCKEY_MEDIA_PLAY preterunicode(158)
#define NCKEY_MEDIA_PAUSE preterunicode(159)
#define NCKEY_MEDIA_PPAUSE preterunicode(160)
#define NCKEY_MEDIA_REV preterunicode(161)
#define NCKEY_MEDIA_STOP preterunicode(162)
#define NCKEY_MEDIA_FF preterunicode(163)
#define NCKEY_MEDIA_REWIND preterunicode(164)
#define NCKEY_MEDIA_NEXT preterunicode(165)
#define NCKEY_MEDIA_PREV preterunicode(166)
#define NCKEY_MEDIA_RECORD preterunicode(167)
#define NCKEY_MEDIA_LVOL preterunicode(168)
#define NCKEY_MEDIA_RVOL preterunicode(169)
#define NCKEY_MEDIA_MUTE preterunicode(170)
// modifiers when pressed by themselves. this ordering comes from the Kitty
// keyboard protocol, and mustn't be changed without updating handlers.
#define NCKEY_LSHIFT suppuabize(171)
#define NCKEY_LCTRL suppuabize(172)
#define NCKEY_LALT suppuabize(173)
#define NCKEY_LSUPER suppuabize(174)
#define NCKEY_LHYPER suppuabize(175)
#define NCKEY_LMETA suppuabize(176)
#define NCKEY_RSHIFT suppuabize(177)
#define NCKEY_RCTRL suppuabize(178)
#define NCKEY_RALT suppuabize(179)
#define NCKEY_RSUPER suppuabize(180)
#define NCKEY_RHYPER suppuabize(181)
#define NCKEY_RMETA suppuabize(182)
#define NCKEY_LSHIFT preterunicode(171)
#define NCKEY_LCTRL preterunicode(172)
#define NCKEY_LALT preterunicode(173)
#define NCKEY_LSUPER preterunicode(174)
#define NCKEY_LHYPER preterunicode(175)
#define NCKEY_LMETA preterunicode(176)
#define NCKEY_RSHIFT preterunicode(177)
#define NCKEY_RCTRL preterunicode(178)
#define NCKEY_RALT preterunicode(179)
#define NCKEY_RSUPER preterunicode(180)
#define NCKEY_RHYPER preterunicode(181)
#define NCKEY_RMETA preterunicode(182)
// mouse events. We encode which button was pressed into the char32_t,
// but position information is embedded in the larger ncinput event.
#define NCKEY_MOTION suppuabize(200) // no buttons pressed
#define NCKEY_BUTTON1 suppuabize(201)
#define NCKEY_BUTTON2 suppuabize(202)
#define NCKEY_BUTTON3 suppuabize(203)
#define NCKEY_BUTTON4 suppuabize(204) // scrollwheel up
#define NCKEY_BUTTON5 suppuabize(205) // scrollwheel down
#define NCKEY_BUTTON6 suppuabize(206)
#define NCKEY_BUTTON7 suppuabize(207)
#define NCKEY_BUTTON8 suppuabize(208)
#define NCKEY_BUTTON9 suppuabize(209)
#define NCKEY_BUTTON10 suppuabize(210)
#define NCKEY_BUTTON11 suppuabize(211)
#define NCKEY_MOTION preterunicode(200) // no buttons pressed
#define NCKEY_BUTTON1 preterunicode(201)
#define NCKEY_BUTTON2 preterunicode(202)
#define NCKEY_BUTTON3 preterunicode(203)
#define NCKEY_BUTTON4 preterunicode(204) // scrollwheel up
#define NCKEY_BUTTON5 preterunicode(205) // scrollwheel down
#define NCKEY_BUTTON6 preterunicode(206)
#define NCKEY_BUTTON7 preterunicode(207)
#define NCKEY_BUTTON8 preterunicode(208)
#define NCKEY_BUTTON9 preterunicode(209)
#define NCKEY_BUTTON10 preterunicode(210)
#define NCKEY_BUTTON11 preterunicode(211)
// indicates that we have reached the end of input. any further calls
// will continute to return this immediately.
#define NCKEY_EOF suppuabize(300)
#define NCKEY_EOF preterunicode(300)
// Is this uint32_t a synthesized event?
static inline bool
nckey_synthesized_p(uint32_t w){
return w >= PRETERUNICODEBASE && w <= (PRETERUNICODEBASE + 300);
}
// Synonyms (so far as we're concerned)
#define NCKEY_SCROLL_UP NCKEY_BUTTON4
@ -162,6 +178,24 @@ extern "C" {
#define NCKEY_ESC 0x1b
#define NCKEY_SPACE 0x20
// Is this uint32_t from the Private Use Area in the BMP (Plane 0)?
static inline bool
nckey_pua_p(uint32_t w){
return w >= 0xe000 && w <= 0xf8ff; // 6,400 codepoints
}
// Is this uint32_t a Supplementary Private Use Area-A codepoint?
static inline bool
nckey_supppuaa_p(uint32_t w){
return w >= 0xf0000 && w <= 0xffffd; // 65,534 codepoints
}
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
static inline bool
nckey_supppuab_p(uint32_t w){
return w >= 0x100000 && w <= 0x10fffd; // 65,534 codepoints
}
#ifdef __cplusplus
} // extern "C"
#endif

@ -1073,12 +1073,6 @@ API void notcurses_drop_planes(struct notcurses* nc)
// returned to indicate that no input was available. Otherwise (including on
// EOF) (uint32_t)-1 is returned.
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
static inline bool
nckey_supppuab_p(uint32_t w){
return w >= 0x100000 && w <= 0x10fffd;
}
// Is the event a synthesized mouse event?
static inline bool
nckey_mouse_p(uint32_t r){

@ -334,7 +334,7 @@ int input_demo(ncpp::NotCurses* nc) {
break;
}
}else{
if(nckey_supppuab_p(r)){
if(nckey_synthesized_p(r)){
n->set_fg_rgb8(250, 64, 128);
if(n->printf("Special: [0x%02x (%02d)] '%s'", r, r, nckeystr(r)) < 0){
break;

@ -1017,7 +1017,7 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
wpos = 1;
}else if(id == 'e' && ni.ctrl){
wpos = wused - 1;
}else if(nckey_supppuab_p(ni.id)){
}else if(nckey_synthesized_p(ni.id)){
continue;
}else{
if(wspace - 1 < wused){

@ -368,7 +368,7 @@ bool ncreader_offer_input(ncreader* n, const ncinput* ni){
}else if(ni->id == NCKEY_DOWN){
ncreader_move_down(n);
return true;
}else if(nckey_supppuab_p(ni->id)){
}else if(nckey_synthesized_p(ni->id)){
return false;
}
// FIXME need to collect full EGCs

@ -112,7 +112,7 @@ int main(void){
ncinput ni;
do{
notcurses_get_blocking(nc, &ni);
}while(ni.id != (uint32_t)-1 && ni.evtype != NCTYPE_RELEASE);
}while(ni.id != (uint32_t)-1 && ni.evtype == NCTYPE_RELEASE);
notcurses_stop(nc);
return EXIT_SUCCESS;

Loading…
Cancel
Save