input buffer

pull/124/head
nick black 5 years ago committed by Nick Black
parent c0a1ee0f31
commit 29f55049f4

@ -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

@ -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);

Loading…
Cancel
Save