mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
char32_t is C++, not C -- move to uint32_t
This commit is contained in:
parent
0d68b62bee
commit
15b9b64cad
@ -240,12 +240,12 @@ namespace ncpp
|
||||
return static_cast<CellStyle>(notcurses_supported_styles (nc));
|
||||
}
|
||||
|
||||
char32_t getc (const timespec *ts, sigset_t *sigmask = nullptr, ncinput *ni = nullptr) const noexcept
|
||||
uint32_t getc (const timespec *ts, sigset_t *sigmask = nullptr, ncinput *ni = nullptr) const noexcept
|
||||
{
|
||||
return notcurses_getc (nc, ts, sigmask, ni);
|
||||
}
|
||||
|
||||
char32_t getc (bool blocking = false, ncinput *ni = nullptr) const noexcept
|
||||
uint32_t getc (bool blocking = false, ncinput *ni = nullptr) const noexcept
|
||||
{
|
||||
if (blocking)
|
||||
return notcurses_getc_blocking (nc, ni);
|
||||
@ -293,7 +293,7 @@ namespace ncpp
|
||||
return notcurses_stats_alloc (nc);
|
||||
}
|
||||
|
||||
static bool ucs32_to_utf8 (const char32_t *ucs32, unsigned ucs32count, unsigned char *resultbuf, size_t buflen) NOEXCEPT_MAYBE
|
||||
static bool ucs32_to_utf8 (const uint32_t *ucs32, unsigned ucs32count, unsigned char *resultbuf, size_t buflen) NOEXCEPT_MAYBE
|
||||
{
|
||||
return error_guard (notcurses_ucs32_to_utf8 (ucs32, ucs32count, resultbuf, buflen), -1);
|
||||
}
|
||||
|
@ -310,10 +310,10 @@ API int ncdirect_double_box(struct ncdirect* n, uint64_t ul, uint64_t ur,
|
||||
// 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.
|
||||
// signals. Returns a single Unicode code point, or (uint32_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,
|
||||
API uint32_t ncdirect_getc(struct ncdirect* n, const struct timespec* ts,
|
||||
sigset_t* sigmask, ncinput* ni)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
@ -326,7 +326,7 @@ 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
|
||||
static inline uint32_t
|
||||
ncdirect_getc_nblock(struct ncdirect* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigfillset(&sigmask);
|
||||
@ -336,7 +336,7 @@ ncdirect_getc_nblock(struct ncdirect* n, ncinput* 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
|
||||
static inline uint32_t
|
||||
ncdirect_getc_blocking(struct ncdirect* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigemptyset(&sigmask);
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define NOTCURSES_NOTCURSES
|
||||
|
||||
#include <time.h>
|
||||
#include <uchar.h>
|
||||
#include <ctype.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
@ -104,12 +103,12 @@ typedef enum {
|
||||
// -1 if a non-printable/illegal character is encountered.
|
||||
API int ncstrwidth(const char* mbs);
|
||||
|
||||
// input functions like notcurses_getc() return ucs32-encoded char32_t. convert
|
||||
// a series of char32_t to utf8. result must be at least 4 bytes per input
|
||||
// char32_t (6 bytes per char32_t will future-proof against Unicode expansion).
|
||||
// input functions like notcurses_getc() return ucs32-encoded uint32_t. convert
|
||||
// a series of uint32_t to utf8. result must be at least 4 bytes per input
|
||||
// uint32_t (6 bytes per uint32_t will future-proof against Unicode expansion).
|
||||
// the number of bytes used is returned, or -1 if passed illegal ucs32, or too
|
||||
// small of a buffer.
|
||||
API int notcurses_ucs32_to_utf8(const char32_t* ucs32, unsigned ucs32count,
|
||||
API int notcurses_ucs32_to_utf8(const uint32_t* ucs32, unsigned ucs32count,
|
||||
unsigned char* resultbuf, size_t buflen);
|
||||
|
||||
// background cannot be highcontrast, only foreground
|
||||
@ -999,23 +998,23 @@ API void notcurses_drop_planes(struct notcurses* nc);
|
||||
//
|
||||
// In the case of a valid read, a 32-bit Unicode codepoint is returned. 0 is
|
||||
// returned to indicate that no input was available, but only by
|
||||
// notcurses_getc(). Otherwise (including on EOF) (char32_t)-1 is returned.
|
||||
// notcurses_getc(). Otherwise (including on EOF) (uint32_t)-1 is returned.
|
||||
|
||||
// Is this char32_t a Supplementary Private Use Area-B codepoint?
|
||||
// Is this uint32_t a Supplementary Private Use Area-B codepoint?
|
||||
static inline bool
|
||||
nckey_supppuab_p(char32_t w){
|
||||
nckey_supppuab_p(uint32_t w){
|
||||
return w >= 0x100000 && w <= 0x10fffd;
|
||||
}
|
||||
|
||||
// Is the event a synthesized mouse event?
|
||||
static inline bool
|
||||
nckey_mouse_p(char32_t r){
|
||||
nckey_mouse_p(uint32_t r){
|
||||
return r >= NCKEY_BUTTON1 && r <= NCKEY_RELEASE;
|
||||
}
|
||||
|
||||
// An input event. Cell coordinates are currently defined only for mouse events.
|
||||
typedef struct ncinput {
|
||||
char32_t id; // identifier. Unicode codepoint or synthesized NCKEY event
|
||||
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
|
||||
bool alt; // was alt held?
|
||||
@ -1045,10 +1044,10 @@ ncinput_equal_p(const ncinput* n1, const ncinput* n2){
|
||||
// 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). It should generally contain all signals.
|
||||
// Returns a single Unicode code point, or (char32_t)-1 on error. 'sigmask' may
|
||||
// Returns a single Unicode code point, or (uint32_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 notcurses_getc(struct notcurses* n, const struct timespec* ts,
|
||||
API uint32_t notcurses_getc(struct notcurses* n, const struct timespec* ts,
|
||||
const sigset_t* sigmask, ncinput* ni)
|
||||
__attribute__ ((nonnull (1)));
|
||||
|
||||
@ -1061,7 +1060,7 @@ API int notcurses_inputready_fd(struct notcurses* n)
|
||||
|
||||
// 'ni' may be NULL if the caller is uninterested in event details. If no event
|
||||
// is ready, returns 0.
|
||||
static inline char32_t
|
||||
static inline uint32_t
|
||||
notcurses_getc_nblock(struct notcurses* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigfillset(&sigmask);
|
||||
@ -1071,7 +1070,7 @@ notcurses_getc_nblock(struct notcurses* n, ncinput* 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
|
||||
static inline uint32_t
|
||||
notcurses_getc_blocking(struct notcurses* n, ncinput* ni){
|
||||
sigset_t sigmask;
|
||||
sigemptyset(&sigmask);
|
||||
|
@ -62,11 +62,11 @@ void interrupt_and_restart_demos(void);
|
||||
// demos should not call notcurses_getc() directly, as it's being monitored by
|
||||
// the toplevel event listener. instead, call this intermediate API. just
|
||||
// replace 'notcurses' with 'demo'.
|
||||
char32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni);
|
||||
uint32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni);
|
||||
|
||||
// 'ni' may be NULL if the caller is uninterested in event details. If no event
|
||||
// is ready, returns 0.
|
||||
static inline char32_t
|
||||
static inline uint32_t
|
||||
demo_getc_nblock(struct notcurses* nc, ncinput* ni){
|
||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
|
||||
return demo_getc(nc, &ts, ni);
|
||||
@ -78,7 +78,7 @@ int demo_input_fd(void);
|
||||
|
||||
// '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
|
||||
static inline uint32_t
|
||||
demo_getc_blocking(struct notcurses* nc, ncinput* ni){
|
||||
return demo_getc(nc, NULL, ni);
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ int demo_render(struct notcurses* nc){
|
||||
ncplane_off_styles(hud, NCSTYLE_BOLD);
|
||||
}
|
||||
ncinput ni;
|
||||
char32_t id;
|
||||
uint32_t id;
|
||||
id = demo_getc_nblock(nc, &ni);
|
||||
int ret = notcurses_render(nc);
|
||||
if(ret){
|
||||
|
@ -45,7 +45,7 @@ handle_mouse(const ncinput* ni){
|
||||
|
||||
// incoming timespec is relative (or even NULL, for blocking), but we need
|
||||
// absolute deadline, so convert it up.
|
||||
char32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni){
|
||||
uint32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni){
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
uint64_t ns;
|
||||
@ -64,7 +64,7 @@ char32_t demo_getc(struct notcurses* nc, const struct timespec* ts, ncinput* ni)
|
||||
struct timespec abstime;
|
||||
ns_to_timespec(ns + timespec_to_ns(&now), &abstime);
|
||||
bool handoff = false; // does the input go back to the user?
|
||||
char32_t id;
|
||||
uint32_t id;
|
||||
do{
|
||||
pthread_mutex_lock(&lock);
|
||||
while(!queue){
|
||||
@ -130,8 +130,8 @@ static void *
|
||||
ultramegaok_demo(void* vnc){
|
||||
ncinput ni;
|
||||
struct notcurses* nc = vnc;
|
||||
char32_t id;
|
||||
while((id = notcurses_getc_blocking(nc, &ni)) != (char32_t)-1){
|
||||
uint32_t id;
|
||||
while((id = notcurses_getc_blocking(nc, &ni)) != (uint32_t)-1){
|
||||
if(id == 0){
|
||||
continue;
|
||||
}
|
||||
|
@ -147,8 +147,8 @@ reader_post(struct notcurses* nc, struct ncselector* selector, struct ncmultisel
|
||||
struct timespec rel;
|
||||
ns_to_timespec(targ - cur, &rel);
|
||||
ncinput ni;
|
||||
char32_t wc = demo_getc(nc, &rel, &ni);
|
||||
if(wc == (char32_t)-1){
|
||||
uint32_t wc = demo_getc(nc, &rel, &ni);
|
||||
if(wc == (uint32_t)-1){
|
||||
return -1;
|
||||
}else if(wc){
|
||||
ncmultiselector_offer_input(mselector, &ni);
|
||||
@ -281,8 +281,8 @@ selector_run(struct notcurses* nc, struct ncplane* p, struct ncselector* selecto
|
||||
struct ncinput ni;
|
||||
struct timespec inputtime;
|
||||
ns_to_timespec(deadline_ns - timespec_to_ns(&now), &inputtime);
|
||||
char32_t wc = demo_getc(nc, &inputtime, &ni);
|
||||
if(wc == (char32_t)-1){
|
||||
uint32_t wc = demo_getc(nc, &inputtime, &ni);
|
||||
if(wc == (uint32_t)-1){
|
||||
return -1;
|
||||
}else if(wc){
|
||||
ncselector_offer_input(selector, &ni);
|
||||
@ -355,8 +355,8 @@ mselector_run(struct notcurses* nc, struct ncplane* p, struct ncmultiselector* m
|
||||
struct ncinput ni;
|
||||
struct timespec inputtime;
|
||||
ns_to_timespec(deadline_ns - timespec_to_ns(&now), &inputtime);
|
||||
char32_t wc = demo_getc(nc, &inputtime, &ni);
|
||||
if(wc == (char32_t)-1){
|
||||
uint32_t wc = demo_getc(nc, &inputtime, &ni);
|
||||
if(wc == (uint32_t)-1){
|
||||
return -1;
|
||||
}else if(wc){
|
||||
ncmultiselector_offer_input(mselector, &ni);
|
||||
|
@ -11,7 +11,7 @@
|
||||
// not reported in their bare form to the user. For our purposes, these usually
|
||||
// indicate a mouse event.
|
||||
#define CSIPREFIX "\x1b["
|
||||
static const char32_t NCKEY_CSI = 0x90; // guaranteed not to match anything else
|
||||
static const uint32_t NCKEY_CSI = 0x90; // guaranteed not to match anything else
|
||||
|
||||
static sig_atomic_t resize_seen;
|
||||
|
||||
@ -102,7 +102,7 @@ unpop_keypress(ncinputlayer* nc, int kpress){
|
||||
|
||||
// we assumed escapes can only be composed of 7-bit chars
|
||||
typedef struct esctrie {
|
||||
char32_t special; // composed key terminating here
|
||||
uint32_t special; // composed key terminating here
|
||||
struct esctrie** trie; // if non-NULL, next level of radix-128 trie
|
||||
} esctrie;
|
||||
|
||||
@ -134,7 +134,7 @@ input_free_esctrie(esctrie** eptr){
|
||||
}
|
||||
|
||||
static int
|
||||
ncinputlayer_add_input_escape(ncinputlayer* nc, const char* esc, char32_t special){
|
||||
ncinputlayer_add_input_escape(ncinputlayer* nc, const char* esc, uint32_t special){
|
||||
if(esc[0] != NCKEY_ESC || strlen(esc) < 2){ // assume ESC prefix + content
|
||||
logerror("Not an escape: %s (0x%x)\n", esc, special);
|
||||
return -1;
|
||||
@ -181,7 +181,7 @@ ncinputlayer_add_input_escape(ncinputlayer* nc, const char* esc, char32_t specia
|
||||
// mouse and cursor location reports. The former is three parameters starting
|
||||
// with '<' and ending with 'm' or 'M'; the latter is two ending with 'R'.
|
||||
// Both use 1-biased coordinates, so a 0 can be safely rejected.
|
||||
static char32_t
|
||||
static uint32_t
|
||||
handle_csi(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
// stash the first parameter away. it's encoded if the CSI ends up being a
|
||||
// mouse event, and otherwise it's the cursor's column (x) coordinate.
|
||||
@ -193,7 +193,7 @@ handle_csi(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
PARAM3, // reading third param (y coordinate) plus terminator
|
||||
} state = PARAM1;
|
||||
int param = 0; // numeric translation of param thus far
|
||||
char32_t id = (char32_t)-1;
|
||||
uint32_t id = (uint32_t)-1;
|
||||
while(nc->inputbuf_occupied){
|
||||
int candidate = pop_input_keypress(nc);
|
||||
logdebug("Candidate: %c (%d)\n", candidate, candidate);
|
||||
@ -285,7 +285,7 @@ handle_csi(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
// FIXME ungetc on failure! walk trie backwards or something
|
||||
// FIXME increment the input_error stat
|
||||
logerror("Error processing CSI (%d left)\n", nc->inputbuf_occupied);
|
||||
return (char32_t)-1;
|
||||
return (uint32_t)-1;
|
||||
}
|
||||
|
||||
// add the keypress we just read to our input queue (assuming there is room).
|
||||
@ -315,7 +315,7 @@ handle_csi(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
// CSI is most relevant to us here, since mouse and cursor reports arrive that
|
||||
// way. CSI is properly terminated by 0x40--0x7e. the parameter space covers
|
||||
// 0x30--0x39 and the delimiter 0x3b (';').
|
||||
static char32_t
|
||||
static uint32_t
|
||||
handle_getc(ncinputlayer* nc, int kpress, ncinput* ni, int leftmargin, int topmargin){
|
||||
if(kpress < 0){
|
||||
return -1;
|
||||
@ -443,14 +443,14 @@ enqueue_cursor_report(ncinputlayer* nc, const ncinput* ni){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char32_t
|
||||
static uint32_t
|
||||
handle_queued_input(ncinputlayer* nc, ncinput* ni,
|
||||
int leftmargin, int topmargin){
|
||||
ncinput nireal;
|
||||
if(ni == NULL){
|
||||
ni = &nireal;
|
||||
}
|
||||
char32_t ret;
|
||||
uint32_t ret;
|
||||
do{
|
||||
// if there was some error in getc(), we still dole out the existing queue
|
||||
if(nc->inputbuf_occupied == 0){
|
||||
@ -458,7 +458,7 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni,
|
||||
}
|
||||
int r = pop_input_keypress(nc);
|
||||
ret = handle_getc(nc, r, ni, leftmargin, topmargin);
|
||||
if(ret != (char32_t)-1){
|
||||
if(ret != (uint32_t)-1){
|
||||
ni->id = ret;
|
||||
}
|
||||
if(ret == NCKEY_CURSOR_LOCATION_REPORT){
|
||||
@ -500,7 +500,7 @@ fill_buffer(ncinputlayer* nc){
|
||||
|
||||
// user-mode call to actual input i/o, which will get the next character from
|
||||
// the input buffer.
|
||||
static char32_t
|
||||
static uint32_t
|
||||
handle_input(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
fill_buffer(nc);
|
||||
// highest priority is resize notifications, since they don't queue
|
||||
@ -511,12 +511,12 @@ handle_input(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
return handle_queued_input(nc, ni, leftmargin, topmargin);
|
||||
}
|
||||
|
||||
static char32_t
|
||||
static uint32_t
|
||||
handle_ncinput(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
if(ni){
|
||||
memset(ni, 0, sizeof(*ni));
|
||||
}
|
||||
char32_t r = handle_input(nc, ni, leftmargin, topmargin);
|
||||
uint32_t r = handle_input(nc, ni, leftmargin, topmargin);
|
||||
// ctrl (*without* alt) + letter maps to [1..26], and is independent of shift
|
||||
// FIXME need to distinguish between:
|
||||
// - Enter and ^J
|
||||
@ -543,7 +543,7 @@ handle_ncinput(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin){
|
||||
}
|
||||
|
||||
// helper so we can do counter increment at a single location
|
||||
static inline char32_t
|
||||
static inline uint32_t
|
||||
ncinputlayer_prestamp(ncinputlayer* nc, const struct timespec *ts,
|
||||
const sigset_t* sigmask, ncinput* ni, int leftmargin,
|
||||
int topmargin){
|
||||
@ -561,11 +561,11 @@ ncinputlayer_prestamp(ncinputlayer* nc, const struct timespec *ts,
|
||||
}
|
||||
|
||||
// infp has already been set non-blocking
|
||||
char32_t notcurses_getc(notcurses* nc, const struct timespec *ts,
|
||||
uint32_t notcurses_getc(notcurses* nc, const struct timespec *ts,
|
||||
const sigset_t* sigmask, ncinput* ni){
|
||||
char32_t r = ncinputlayer_prestamp(&nc->tcache.input, ts, sigmask, ni,
|
||||
uint32_t r = ncinputlayer_prestamp(&nc->tcache.input, ts, sigmask, ni,
|
||||
nc->margin_l, nc->margin_t);
|
||||
if(r != (char32_t)-1){
|
||||
if(r != (uint32_t)-1){
|
||||
uint64_t stamp = nc->tcache.input.input_events++; // need increment even if !ni
|
||||
if(ni){
|
||||
ni->seqnum = stamp;
|
||||
@ -574,10 +574,10 @@ char32_t notcurses_getc(notcurses* nc, const struct timespec *ts,
|
||||
return r;
|
||||
}
|
||||
|
||||
char32_t ncdirect_getc(ncdirect* nc, const struct timespec *ts,
|
||||
uint32_t ncdirect_getc(ncdirect* nc, const struct timespec *ts,
|
||||
sigset_t* sigmask, ncinput* ni){
|
||||
char32_t r = ncinputlayer_prestamp(&nc->tcache.input, ts, sigmask, ni, 0, 0);
|
||||
if(r != (char32_t)-1){
|
||||
uint32_t r = ncinputlayer_prestamp(&nc->tcache.input, ts, sigmask, ni, 0, 0);
|
||||
if(r != (uint32_t)-1){
|
||||
uint64_t stamp = nc->tcache.input.input_events++; // need increment even if !ni
|
||||
if(ni){
|
||||
ni->seqnum = stamp;
|
||||
@ -591,7 +591,7 @@ static int
|
||||
prep_special_keys(ncinputlayer* nc){
|
||||
static const struct {
|
||||
const char* tinfo;
|
||||
char32_t key;
|
||||
uint32_t key;
|
||||
} keys[] = {
|
||||
{ .tinfo = "kcub1", .key = NCKEY_LEFT, },
|
||||
{ .tinfo = "kcuf1", .key = NCKEY_RIGHT, },
|
||||
|
@ -5,7 +5,7 @@
|
||||
// codepoint appears in 'col', and the byte offset as the return value. If not
|
||||
// found, -1 is returned, and 'col' is meaningless.
|
||||
static int
|
||||
mbstr_find_codepoint(const char* s, char32_t cp, int* col){
|
||||
mbstr_find_codepoint(const char* s, uint32_t cp, int* col){
|
||||
mbstate_t ps;
|
||||
memset(&ps, 0, sizeof(ps));
|
||||
size_t bytes = 0;
|
||||
|
@ -3000,7 +3000,7 @@ int ncplane_putnstr_yx(struct ncplane* n, int y, int x, size_t s, const char* gc
|
||||
return ret;
|
||||
}
|
||||
|
||||
int notcurses_ucs32_to_utf8(const char32_t* ucs32, unsigned ucs32count,
|
||||
int notcurses_ucs32_to_utf8(const uint32_t* ucs32, unsigned ucs32count,
|
||||
unsigned char* resultbuf, size_t buflen){
|
||||
if(u32_to_u8(ucs32, ucs32count, resultbuf, &buflen) == NULL){
|
||||
return -1;
|
||||
|
@ -1115,7 +1115,7 @@ notcurses_rasterize_inner(notcurses* nc, ncpile* p, FILE* out, unsigned* asu){
|
||||
if(rasterize_core(nc, p, out, 1)){
|
||||
return -1;
|
||||
}
|
||||
#define MIN_SUMODE_SIZE 4096 // FIXME
|
||||
#define MIN_SUMODE_SIZE BUFSIZ
|
||||
if(*asu){
|
||||
if(nc->rstate.mstrsize >= MIN_SUMODE_SIZE){
|
||||
const char* endasu = get_escape(&nc->tcache, ESCAPE_ESUM);
|
||||
|
@ -9,8 +9,8 @@ int main(void){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ncinput ni;
|
||||
char32_t i;
|
||||
while((i = ncdirect_getc_blocking(n, &ni)) != (char32_t)-1){
|
||||
uint32_t i;
|
||||
while((i = ncdirect_getc_blocking(n, &ni)) != (uint32_t)-1){
|
||||
unsigned char utf8[5] = {};
|
||||
notcurses_ucs32_to_utf8(&i, 1, utf8, sizeof(utf8));
|
||||
printf("Read input: [%c%c%c] %s\n", ni.ctrl ? 'C' : 'c',
|
||||
@ -19,7 +19,7 @@ int main(void){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(ncdirect_stop(n) || i == (char32_t)-1){
|
||||
if(ncdirect_stop(n) || i == (uint32_t)-1){
|
||||
fprintf(stderr, "Failure reading input (%s)\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ run_menu(struct notcurses* nc, struct ncmenu* ncm){
|
||||
if(ncplane_set_base(selplane, " ", 0, channels) < 0){
|
||||
goto err;
|
||||
}
|
||||
char32_t keypress;
|
||||
uint32_t keypress;
|
||||
ncinput ni;
|
||||
notcurses_render(nc);
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (char32_t)-1){
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (uint32_t)-1){
|
||||
if(!ncmenu_offer_input(ncm, &ni)){
|
||||
if(keypress == 'q'){
|
||||
ncmenu_destroy(ncm);
|
||||
|
@ -41,9 +41,9 @@ run_mselect(struct notcurses* nc, struct ncmultiselector* ns){
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
notcurses_render(nc);
|
||||
char32_t keypress;
|
||||
uint32_t keypress;
|
||||
ncinput ni;
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (char32_t)-1){
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (uint32_t)-1){
|
||||
if(!ncmultiselector_offer_input(ns, &ni)){
|
||||
switch(keypress){
|
||||
case NCKEY_ENTER: ncmultiselector_destroy(ns); return;
|
||||
|
@ -31,9 +31,9 @@ run_selector(struct notcurses* nc, struct ncselector* ns){
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
notcurses_render(nc);
|
||||
char32_t keypress;
|
||||
uint32_t keypress;
|
||||
ncinput ni;
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (char32_t)-1){
|
||||
while((keypress = notcurses_getc_blocking(nc, &ni)) != (uint32_t)-1){
|
||||
if(!ncselector_offer_input(ns, &ni)){
|
||||
switch(keypress){
|
||||
case NCKEY_ENTER: ncselector_destroy(ns, NULL); return;
|
||||
|
@ -96,7 +96,7 @@ int main(int argc, char** argv){
|
||||
REDRAW();
|
||||
t_ = nctabbed_add(nct, NULL, NULL, tabcbfn, "gamma", NULL);
|
||||
REDRAW();
|
||||
char32_t c;
|
||||
uint32_t c;
|
||||
while((c = notcurses_getc_blocking(nc, NULL)) != 'q'){
|
||||
switch(c){
|
||||
case NCKEY_RIGHT:
|
||||
|
@ -391,7 +391,7 @@ callback(struct ncplane* ncp, void* curry, int dizzy){
|
||||
static int
|
||||
tree_ui(struct notcurses* nc, struct nctree* tree){
|
||||
ncinput ni;
|
||||
while(notcurses_getc_blocking(nc, &ni) != (char32_t)-1){
|
||||
while(notcurses_getc_blocking(nc, &ni) != (uint32_t)-1){
|
||||
if(nctree_offer_input(tree, &ni)){
|
||||
if(nctree_redraw(tree)){
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user