|
|
@ -49,7 +49,6 @@ typedef struct ncplane {
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct notcurses {
|
|
|
|
typedef struct notcurses {
|
|
|
|
int ttyfd; // file descriptor for controlling tty (takes stdin)
|
|
|
|
int ttyfd; // file descriptor for controlling tty (takes stdin)
|
|
|
|
timer_t timer; // CLOCK_MONOTONIC timer for benchmarking
|
|
|
|
|
|
|
|
int colors; // number of colors usable for this screen
|
|
|
|
int colors; // number of colors usable for this screen
|
|
|
|
// We verify that some capabilities exist (see required_caps). Those needn't
|
|
|
|
// We verify that some capabilities exist (see required_caps). Those needn't
|
|
|
|
// be checked before further use; just use tiparm() directly. These might be
|
|
|
|
// be checked before further use; just use tiparm() directly. These might be
|
|
|
@ -346,16 +345,10 @@ notcurses* notcurses_init(const notcurses_options* opts){
|
|
|
|
if(ret == NULL){
|
|
|
|
if(ret == NULL){
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(timer_create(CLOCK_MONOTONIC, NULL, &ret->timer)){
|
|
|
|
|
|
|
|
fprintf(stderr, "Error initializing monotonic clock (%s)\n", strerror(errno));
|
|
|
|
|
|
|
|
free(ret);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->ttyfd = opts->outfd;
|
|
|
|
ret->ttyfd = opts->outfd;
|
|
|
|
if(tcgetattr(ret->ttyfd, &ret->tpreserved)){
|
|
|
|
if(tcgetattr(ret->ttyfd, &ret->tpreserved)){
|
|
|
|
fprintf(stderr, "Couldn't preserve terminal state for %d (%s)\n",
|
|
|
|
fprintf(stderr, "Couldn't preserve terminal state for %d (%s)\n",
|
|
|
|
ret->ttyfd, strerror(errno));
|
|
|
|
ret->ttyfd, strerror(errno));
|
|
|
|
timer_delete(ret->timer);
|
|
|
|
|
|
|
|
free(ret);
|
|
|
|
free(ret);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -397,7 +390,6 @@ notcurses* notcurses_init(const notcurses_options* opts){
|
|
|
|
|
|
|
|
|
|
|
|
err:
|
|
|
|
err:
|
|
|
|
tcsetattr(ret->ttyfd, TCSANOW, &ret->tpreserved);
|
|
|
|
tcsetattr(ret->ttyfd, TCSANOW, &ret->tpreserved);
|
|
|
|
timer_delete(ret->timer);
|
|
|
|
|
|
|
|
free(ret);
|
|
|
|
free(ret);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -594,7 +586,7 @@ advance_cursor(ncplane* n){
|
|
|
|
// world every time
|
|
|
|
// world every time
|
|
|
|
int notcurses_render(notcurses* nc){
|
|
|
|
int notcurses_render(notcurses* nc){
|
|
|
|
struct timespec start, done;
|
|
|
|
struct timespec start, done;
|
|
|
|
clock_gettime(nc->timer, &start);
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
|
|
|
int ret = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int y, x;
|
|
|
|
int y, x;
|
|
|
|
if(term_movyx(0, 0)){
|
|
|
|
if(term_movyx(0, 0)){
|
|
|
@ -618,7 +610,7 @@ int notcurses_render(notcurses* nc){
|
|
|
|
term_putc(nc, nc->stdscr, c);
|
|
|
|
term_putc(nc, nc->stdscr, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clock_gettime(nc->timer, &done);
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &done);
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|