mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
[input] on construction failure, return NULL initdata #2289
This commit is contained in:
parent
7071cb42fa
commit
d6e574f131
17
src/lib/in.c
17
src/lib/in.c
@ -108,6 +108,7 @@ typedef struct inputctx {
|
||||
ipipe readypipes[2]; // pipes[0]: poll()able fd indicating the presence of user input
|
||||
struct initial_responses* initdata;
|
||||
struct initial_responses* initdata_complete;
|
||||
bool failed; // error initializing input automaton, abort
|
||||
} inputctx;
|
||||
|
||||
static inline void
|
||||
@ -1265,7 +1266,6 @@ build_cflow_automaton(inputctx* ictx){
|
||||
// CSI (\e[)
|
||||
{ "[<\\N;\\N;\\NM", mouse_press_cb, },
|
||||
{ "[<\\N;\\N;\\Nm", mouse_release_cb, },
|
||||
{ "[\\N;\\NR", cursor_location_cb, },
|
||||
// technically these must begin with "4" or "8"; enforce in callbacks
|
||||
{ "[\\N;\\N;\\Nt", geom_cb, },
|
||||
{ "[\\Nu", kitty_cb_simple, },
|
||||
@ -1287,6 +1287,7 @@ build_cflow_automaton(inputctx* ictx){
|
||||
{ "[1;\\N:\\NH", kitty_cb_home, },
|
||||
{ "[?\\Nu", kitty_keyboard_cb, },
|
||||
{ "[?2026;\\N$y", decrpm_asu_cb, },
|
||||
{ "[\\N;\\NR", cursor_location_cb, },
|
||||
{ "[?1;1S", NULL, }, // negative cregs XTSMGRAPHICS
|
||||
{ "[?1;2S", NULL, }, // negative cregs XTSMGRAPHICS
|
||||
{ "[?1;3;0S", NULL, }, // negative cregs XTSMGRAPHICS
|
||||
@ -1425,6 +1426,7 @@ create_inputctx(tinfo* ti, FILE* infp, int lmargin, int tmargin, int rmargin,
|
||||
i->rmargin = rmargin;
|
||||
i->bmargin = bmargin;
|
||||
i->drain = drain;
|
||||
i->failed = false;
|
||||
logdebug("input descriptors: %d/%d\n", i->stdinfd, i->termfd);
|
||||
return i;
|
||||
}
|
||||
@ -2000,11 +2002,9 @@ read_inputs_nblock(inputctx* ictx){
|
||||
static void*
|
||||
input_thread(void* vmarshall){
|
||||
inputctx* ictx = vmarshall;
|
||||
if(prep_all_keys(ictx)){
|
||||
abort(); // FIXME?
|
||||
}
|
||||
if(build_cflow_automaton(ictx)){
|
||||
abort(); // FIXME?
|
||||
if(prep_all_keys(ictx) || build_cflow_automaton(ictx)){
|
||||
ictx->failed = true;
|
||||
handoff_initial_responses(ictx);
|
||||
}
|
||||
for(;;){
|
||||
read_inputs_nblock(ictx);
|
||||
@ -2299,5 +2299,10 @@ struct initial_responses* inputlayer_get_responses(inputctx* ictx){
|
||||
iresp = ictx->initdata_complete;
|
||||
ictx->initdata_complete = NULL;
|
||||
pthread_mutex_unlock(&ictx->ilock);
|
||||
if(ictx->failed){
|
||||
logpanic("aborting after automaton construction failure\n");
|
||||
free(iresp);
|
||||
return NULL;
|
||||
}
|
||||
return iresp;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user