mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
declare ncdirect input layer #919
This commit is contained in:
parent
39d0989a5e
commit
8f65211bf8
10
NEWS.md
10
NEWS.md
@ -1,6 +1,16 @@
|
||||
This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 1.6.19 (not yet released)
|
||||
* Direct mode now places the terminal into "cbreak mode". This disables
|
||||
echo and line-buffering of input. If this is undesirable, you can restore
|
||||
the terminal state following `ncdirect_init()`, but this will break the
|
||||
semantics of `ncdirect_getc()` and derivatives (due to line buffering).
|
||||
* The notcurses input layer has been reproduced for direct mode, including
|
||||
`ncdirect_getc()`, `ncdirect_getc_nblock()`, `ncdirect_getc_blocking()`,
|
||||
and `ncdirect_inputready_fd()`. Mouse support is not yet available in
|
||||
direct mode, but becomes possible through these additions.
|
||||
|
||||
* 1.6.18 (2020-08-25)
|
||||
* `nc_err_e` has been taken behind the shed and shot in the face. All
|
||||
functions which once returned `nc_err_e` now return a bimodal `int`. Those
|
||||
|
@ -135,6 +135,43 @@ API int ncdirect_double_box(struct ncdirect* n, uint64_t ul, uint64_t ur,
|
||||
uint64_t ll, uint64_t lr,
|
||||
int ylen, int xlen, unsigned ctlword);
|
||||
|
||||
API int ncdirect_getc_nonblocking(struct ncdirect* n);
|
||||
|
||||
// See ppoll(2) for more detail. Provide a NULL 'ts' to block at length, a 'ts'
|
||||
// of 0 for non-blocking operation, and otherwise a timespec to bound blocking.
|
||||
// Signals in sigmask (less several we handle internally) will be atomically
|
||||
// masked and unmasked per ppoll(2). '*sigmask' should generally contain all
|
||||
// signals. Returns a single Unicode code point, or (char32_t)-1 on error.
|
||||
// 'sigmask' may be NULL. Returns 0 on a timeout. If an event is processed, the
|
||||
// return value is the 'id' field from that event. 'ni' may be NULL.
|
||||
API char32_t ncdirect_getc(struct ncdirect* n, const struct timespec* ts,
|
||||
sigset_t* sigmask, ncinput* ni);
|
||||
|
||||
// Get a file descriptor suitable for input event poll()ing. When this
|
||||
// descriptor becomes available, you can call ncdirect_getc_nblock(),
|
||||
// and input ought be ready. This file descriptor is *not* necessarily
|
||||
// the file descriptor associated with stdin (but it might be!).
|
||||
API int ncdirect_inputready_fd(struct ncdirect* n);
|
||||
|
||||
// 'ni' may be NULL if the caller is uninterested in event details. If no event
|
||||
// is ready, returns 0.
|
||||
static inline char32_t
|
||||
ncdirect_getc_nblock(struct ncdirect* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigfillset(&sigmask);
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
|
||||
return ncdirect_getc(n, &ts, &sigmask, ni);
|
||||
}
|
||||
|
||||
// 'ni' may be NULL if the caller is uninterested in event details. Blocks
|
||||
// until an event is processed or a signal is received.
|
||||
static inline char32_t
|
||||
ncdirect_getc_blocking(struct ncdirect* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigemptyset(&sigmask);
|
||||
return ncdirect_getc(n, NULL, &sigmask, ni);
|
||||
}
|
||||
|
||||
// Release 'nc' and any associated resources. 0 on success, non-0 on failure.
|
||||
API int ncdirect_stop(struct ncdirect* nc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user