mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
[input] introduce NCKEY_EOF #2185
This commit is contained in:
parent
ea5da346f0
commit
3faf8ee3fb
1
NEWS.md
1
NEWS.md
@ -19,6 +19,7 @@ rearrangements of Notcurses.
|
|||||||
`NCKEY_RELEASE` definition is no longer returned; instead, the
|
`NCKEY_RELEASE` definition is no longer returned; instead, the
|
||||||
appropriate `NCKEY_BUTTONx` synthesized key is returned, with
|
appropriate `NCKEY_BUTTONx` synthesized key is returned, with
|
||||||
`EVTYPE_RELEASE` set.
|
`EVTYPE_RELEASE` set.
|
||||||
|
* `NCKEY_EOF` now indicates the end of input.
|
||||||
|
|
||||||
* 2.4.1 (2021-09-12)
|
* 2.4.1 (2021-09-12)
|
||||||
* `notcurses_check_pixel_support()` still returns 0 if there is no support
|
* `notcurses_check_pixel_support()` still returns 0 if there is no support
|
||||||
|
4
USAGE.md
4
USAGE.md
@ -668,7 +668,7 @@ must be readable without delay for it to be interpreted as such.
|
|||||||
#define NCKEY_BUTTON2 suppuabize(202)
|
#define NCKEY_BUTTON2 suppuabize(202)
|
||||||
#define NCKEY_BUTTON3 suppuabize(203)
|
#define NCKEY_BUTTON3 suppuabize(203)
|
||||||
// ... up to 11 mouse buttons
|
// ... up to 11 mouse buttons
|
||||||
#define NCKEY_RELEASE suppuabize(212)
|
#define NCKEY_EOF suppuabize(300)
|
||||||
|
|
||||||
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
|
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -760,7 +760,7 @@ int notcurses_mouse_disable(struct notcurses* n);
|
|||||||
// Is the event a synthesized mouse event?
|
// Is the event a synthesized mouse event?
|
||||||
static inline bool
|
static inline bool
|
||||||
nckey_mouse_p(uint32_t r){
|
nckey_mouse_p(uint32_t r){
|
||||||
return r >= NCKEY_BUTTON1 && r <= NCKEY_RELEASE;
|
return r >= NCKEY_BUTTON1 && r <= NCKEY_BUTTON11;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -126,6 +126,12 @@ next call to **notcurses_render**, when notcurses will pick up the resize
|
|||||||
itself. If the **SIGWINCH** handler is inhibited, **NCKEY_RESIZE** is never
|
itself. If the **SIGWINCH** handler is inhibited, **NCKEY_RESIZE** is never
|
||||||
generated.
|
generated.
|
||||||
|
|
||||||
|
## **NCKEY_EOF**
|
||||||
|
|
||||||
|
Upon reaching the end of input, **NCKEY_EOF** will be returned. At this point,
|
||||||
|
any further calls will immediately return **NCKEY_EOF**. Note that this does
|
||||||
|
not necessarily result from pressing e.g. Ctrl+D.
|
||||||
|
|
||||||
# RETURN VALUES
|
# RETURN VALUES
|
||||||
|
|
||||||
On error, the **get** family of functions return **(uint32_t)-1**. The cause
|
On error, the **get** family of functions return **(uint32_t)-1**. The cause
|
||||||
|
@ -113,6 +113,10 @@ extern "C" {
|
|||||||
#define NCKEY_BUTTON10 suppuabize(210)
|
#define NCKEY_BUTTON10 suppuabize(210)
|
||||||
#define NCKEY_BUTTON11 suppuabize(211)
|
#define NCKEY_BUTTON11 suppuabize(211)
|
||||||
|
|
||||||
|
// indicates that we have reached the end of input. any further calls
|
||||||
|
// will continute to return this immediately.
|
||||||
|
#define NCKEY_EOF suppuabize(300)
|
||||||
|
|
||||||
// Synonyms (so far as we're concerned)
|
// Synonyms (so far as we're concerned)
|
||||||
#define NCKEY_SCROLL_UP NCKEY_BUTTON4
|
#define NCKEY_SCROLL_UP NCKEY_BUTTON4
|
||||||
#define NCKEY_SCROLL_DOWN NCKEY_BUTTON5
|
#define NCKEY_SCROLL_DOWN NCKEY_BUTTON5
|
||||||
|
@ -280,7 +280,7 @@ int input_demo(ncpp::NotCurses* nc) {
|
|||||||
if(r == 0){ // interrupted by signal
|
if(r == 0){ // interrupted by signal
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((r == 'D' || r == 'd') && ni.ctrl){
|
if(((r == 'D' || r == 'd') && ni.ctrl) || r == NCKEY_EOF){
|
||||||
done = true;
|
done = true;
|
||||||
tid.join();
|
tid.join();
|
||||||
ncuplot_destroy(plot);
|
ncuplot_destroy(plot);
|
||||||
|
@ -1997,7 +1997,11 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
|
|||||||
if(ictx->stdineof){
|
if(ictx->stdineof){
|
||||||
pthread_mutex_unlock(&ictx->ilock);
|
pthread_mutex_unlock(&ictx->ilock);
|
||||||
logwarn("read eof on stdin\n");
|
logwarn("read eof on stdin\n");
|
||||||
return -1;
|
if(ni){
|
||||||
|
memset(ni, 0, sizeof(*ni));
|
||||||
|
ni->id = NCKEY_EOF;
|
||||||
|
}
|
||||||
|
return NCKEY_EOF;
|
||||||
}
|
}
|
||||||
if(ts == NULL){
|
if(ts == NULL){
|
||||||
pthread_cond_wait(&ictx->icond, &ictx->ilock);
|
pthread_cond_wait(&ictx->icond, &ictx->ilock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user