prepare a cursor report queue #1692

pull/1923/head
nick black 3 years ago committed by nick black
parent 3df88384cd
commit 9746a06bde

@ -429,15 +429,21 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni, int leftmargin, int topmargin
if(ni == NULL){ if(ni == NULL){
ni = &nireal; ni = &nireal;
} }
char32_t ret;
do{
// if there was some error in getc(), we still dole out the existing queue // if there was some error in getc(), we still dole out the existing queue
if(nc->inputbuf_occupied == 0){ if(nc->inputbuf_occupied == 0){
return -1; return -1;
} }
int r = pop_input_keypress(nc); int r = pop_input_keypress(nc);
char32_t ret = handle_getc(nc, r, ni, leftmargin, topmargin); ret = handle_getc(nc, r, ni, leftmargin, topmargin);
if(ret != (char32_t)-1){ if(ret != (char32_t)-1){
ni->id = ret; ni->id = ret;
} }
if(ret == NCKEY_CURSOR_LOCATION_REPORT){
// process this internally
}
}while(ret == NCKEY_CURSOR_LOCATION_REPORT);
return ret; return ret;
} }

@ -145,6 +145,7 @@ void notcurses_stats_reset(notcurses* nc, ncstats* stats){
stash->sprixelelisions += nc->stats.sprixelelisions; stash->sprixelelisions += nc->stats.sprixelelisions;
stash->sprixelbytes += nc->stats.sprixelbytes; stash->sprixelbytes += nc->stats.sprixelbytes;
stash->appsync_updates += nc->stats.appsync_updates; stash->appsync_updates += nc->stats.appsync_updates;
stash->input_errors += nc->stats.input_errors;
stash->fbbytes = nc->stats.fbbytes; stash->fbbytes = nc->stats.fbbytes;
stash->planes = nc->stats.planes; stash->planes = nc->stats.planes;
@ -193,13 +194,11 @@ void summarize_stats(notcurses* nc){
totalbuf, minbuf, avgbuf, maxbuf); totalbuf, minbuf, avgbuf, maxbuf);
} }
if(stats->renders || stats->failed_renders){ if(stats->renders || stats->failed_renders){
fprintf(stderr, "%ju failed render%s, %ju failed raster%s, %ju refresh%s\n", fprintf(stderr, "%ju failed render%s, %ju failed raster%s, %ju refresh%s, %ju input error%s\n",
stats->failed_renders, stats->failed_renders, stats->failed_renders == 1 ? "" : "s",
stats->failed_renders == 1 ? "" : "s", stats->failed_writeouts, stats->failed_writeouts == 1 ? "" : "s",
stats->failed_writeouts, stats->refreshes, stats->refreshes == 1 ? "" : "es",
stats->failed_writeouts == 1 ? "" : "s", stats->input_errors, stats->input_errors == 1 ? "" : "s");
stats->refreshes,
stats->refreshes == 1 ? "" : "es");
fprintf(stderr, "RGB emits:elides: def %ju:%ju fg %ju:%ju bg %ju:%ju\n", fprintf(stderr, "RGB emits:elides: def %ju:%ju fg %ju:%ju bg %ju:%ju\n",
stats->defaultemissions, stats->defaultemissions,
stats->defaultelisions, stats->defaultelisions,

@ -69,6 +69,15 @@ typedef enum {
ESCAPE_MAX ESCAPE_MAX
} escape_e; } escape_e;
// when we read a cursor report, we put it on the queue for internal
// processing. this is necessary since it can be arbitrarily interleaved with
// other input when stdin is connected to our terminal. these are already
// processed to be 0-based.
typedef struct cursorreport {
int x, y;
struct cursorreport* next;
} cursorreport;
// we read input from one or two places. if stdin is connected to our // we read input from one or two places. if stdin is connected to our
// controlling tty, we read only from that file descriptor. if it is // controlling tty, we read only from that file descriptor. if it is
// connected to something else, and we have a controlling tty, we will // connected to something else, and we have a controlling tty, we will
@ -93,6 +102,7 @@ typedef struct ncinputlayer {
// be reset (semantics are relied upon by widgets for mouse click detection). // be reset (semantics are relied upon by widgets for mouse click detection).
uint64_t input_events; uint64_t input_events;
struct esctrie* inputescapes; // trie of input escapes -> ncspecial_keys struct esctrie* inputescapes; // trie of input escapes -> ncspecial_keys
cursorreport* creport_queue; // queue of cursor reports
} ncinputlayer; } ncinputlayer;
// terminal interface description. most of these are acquired from terminfo(5) // terminal interface description. most of these are acquired from terminfo(5)

Loading…
Cancel
Save