diff --git a/src/lib/internal.h b/src/lib/internal.h index c35937d9c..6f64c00fb 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -110,6 +110,15 @@ typedef struct notcurses { ncplane* top; // the contents of our topmost plane (initially entire screen) ncplane* stdscr;// aliases some plane from the z-buffer, covers screen FILE* renderfp; // debugging FILE* to which renderings are written + char inputbuf[BUFSIZ]; + // we keep a wee ringbuffer of input queued up for delivery. if + // inputbuf_occupied == sizeof(inputbuf), there is no room. otherwise, data + // can be read to inputbuf_write_at until we fill up. the first datum + // available for the app is at inputbuf_valid_starts iff inputbuf_occupied is + // not 0. the main purpose is working around bad predictions of escapes. + unsigned inputbuf_occupied; + unsigned inputbuf_valid_starts; + unsigned inputbuf_write_at; } notcurses; #ifdef __cplusplus diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 8502091e7..beac01259 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -613,6 +613,9 @@ notcurses* notcurses_init(const notcurses_options* opts){ free(ret); return NULL; } + ret->inputbuf_occupied = 0; + ret->inputbuf_valid_starts = 0; + ret->inputbuf_write_at = 0; if((ret->ttyfd = fileno(ret->ttyfp)) < 0){ fprintf(stderr, "No file descriptor was available in opts->outfp\n"); free(ret);