mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-20 03:25:47 +00:00
pass ncsharedstats down through to input layer #1914
This commit is contained in:
parent
b1b35a56e7
commit
fe150bff95
@ -869,7 +869,7 @@ ncdirect* ncdirect_core_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
shortname_term = termname();
|
||||
if(interrogate_terminfo(&ret->tcache, ret->ctermfd, shortname_term, utf8,
|
||||
1, flags & NCDIRECT_OPTION_INHIBIT_CBREAK,
|
||||
TERMINAL_UNKNOWN, NULL, NULL)){
|
||||
TERMINAL_UNKNOWN, NULL, NULL, NULL)){
|
||||
goto err;
|
||||
}
|
||||
if(ncvisual_init(loglevel)){
|
||||
|
@ -1394,7 +1394,8 @@ err:
|
||||
}
|
||||
|
||||
int ncinputlayer_init(tinfo* tcache, FILE* infp, queried_terminals_e* detected,
|
||||
unsigned* appsync, int* cursor_y, int* cursor_x){
|
||||
unsigned* appsync, int* cursor_y, int* cursor_x,
|
||||
ncsharedstats* stats){
|
||||
ncinputlayer* nilayer = &tcache->input;
|
||||
// FIXME unsafe to do after infp has been used; do we need this?
|
||||
setbuffer(infp, NULL, 0);
|
||||
|
@ -12,6 +12,7 @@ extern "C" {
|
||||
struct tinfo;
|
||||
struct termios;
|
||||
struct ncinputlayer;
|
||||
struct ncsharedstats;
|
||||
|
||||
typedef enum {
|
||||
TERMINAL_UNKNOWN, // no useful information from queries; use termname
|
||||
@ -37,7 +38,8 @@ typedef enum {
|
||||
// non-zero.
|
||||
int ncinputlayer_init(struct tinfo* tcache, FILE* infp,
|
||||
queried_terminals_e* detected, unsigned* appsync,
|
||||
int* cursor_y, int* cursor_x);
|
||||
int* cursor_y, int* cursor_x,
|
||||
struct ncsharedstats* stats);
|
||||
|
||||
void ncinputlayer_stop(struct ncinputlayer* nilayer);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "internal.h"
|
||||
#include <ncurses.h> // needed for some definitions, see terminfo(3ncurses)
|
||||
#include <poll.h>
|
||||
#include <zlib.h>
|
||||
#include <time.h>
|
||||
#include <term.h>
|
||||
#include <fcntl.h>
|
||||
@ -930,7 +931,7 @@ init_banner(const notcurses* nc){
|
||||
14 % nc->tcache.caps.colors : 0x2080e0);
|
||||
}
|
||||
fprintf(nc->ttyfp, "\ncompiled with gcc-%s, %zuB %s-endian cells\n"
|
||||
"terminfo from %s\n",
|
||||
"terminfo from %s zlib %s\n",
|
||||
__VERSION__,
|
||||
sizeof(nccell),
|
||||
#ifdef __BYTE_ORDER__
|
||||
@ -942,7 +943,7 @@ init_banner(const notcurses* nc){
|
||||
#else
|
||||
#error "No __BYTE_ORDER__ definition"
|
||||
#endif
|
||||
, curses_version());
|
||||
, curses_version(), zlibVersion());
|
||||
ncvisual_printbanner(nc);
|
||||
init_banner_warnings(nc, nc->ttyfp);
|
||||
const char* esc;
|
||||
@ -1089,6 +1090,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
memset(&ret->stats.s, 0, sizeof(ret->stats.s));
|
||||
if(pthread_mutex_init(&ret->stats.lock, NULL)){
|
||||
pthread_mutex_destroy(&ret->pilelock);
|
||||
free(ret);
|
||||
@ -1131,7 +1133,8 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
opts->flags & NCOPTION_NO_ALTERNATE_SCREEN, 0,
|
||||
opts->flags & NCOPTION_NO_FONT_CHANGES,
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &ret->rstate.logendy : NULL,
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &ret->rstate.logendx : NULL)){
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &ret->rstate.logendx : NULL,
|
||||
&ret->stats)){
|
||||
goto err;
|
||||
}
|
||||
int dimy, dimx;
|
||||
|
@ -582,7 +582,7 @@ build_supported_styles(tinfo* ti){
|
||||
// full round trip before getting the reply, which is likely to pace init.
|
||||
int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
|
||||
unsigned noaltscreen, unsigned nocbreak, unsigned nonewfonts,
|
||||
int* cursor_y, int* cursor_x){
|
||||
int* cursor_y, int* cursor_x, ncsharedstats* stats){
|
||||
queried_terminals_e qterm = TERMINAL_UNKNOWN;
|
||||
memset(ti, 0, sizeof(*ti));
|
||||
ti->linux_fb_fd = -1;
|
||||
@ -725,7 +725,8 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
|
||||
cursor_y = &foolcursor_y;
|
||||
}
|
||||
*cursor_x = *cursor_y = 0;
|
||||
if(ncinputlayer_init(ti, stdin, &qterm, &appsync_advertised, cursor_y, cursor_x)){
|
||||
if(ncinputlayer_init(ti, stdin, &qterm, &appsync_advertised,
|
||||
cursor_y, cursor_x, stats)){
|
||||
goto err;
|
||||
}
|
||||
if(nocbreak){
|
||||
|
@ -14,6 +14,7 @@ extern "C" {
|
||||
struct ncpile;
|
||||
struct sprixel;
|
||||
struct notcurses;
|
||||
struct ncsharedstats;
|
||||
|
||||
// we store all our escape sequences in a single large block, and use
|
||||
// 16-bit one-biased byte-granularity indices to get the location in said
|
||||
@ -211,10 +212,12 @@ term_supported_styles(const tinfo* ti){
|
||||
// be connected to a terminal device, or -1 if no terminal is available.
|
||||
// if already *certain* of the terminal type (basically, if it's the Linux
|
||||
// console, identified via ioctl(2)s), pass it as qterm; otherwise use
|
||||
// TERMINAL_UNKNOWN.
|
||||
// TERMINAL_UNKNOWN. |stats| may be NULL; either way, it will be handed to the
|
||||
// input layer so that its stats can be recorded.
|
||||
int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
|
||||
unsigned noaltscreen, unsigned nocbreak,
|
||||
unsigned nonewfonts, int* cursor_y, int* cursor_x);
|
||||
unsigned nonewfonts, int* cursor_y, int* cursor_x,
|
||||
struct ncsharedstats* stats);
|
||||
|
||||
void free_terminfo_cache(tinfo* ti);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user