Notcurses 3.0.16
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
internal.h File Reference
#include "version.h"
#include "builddef.h"
#include "compat/compat.h"
#include "notcurses/ncport.h"
#include "notcurses/notcurses.h"
#include "notcurses/direct.h"
#include <term.h>
#include <time.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <signal.h>
#include <wctype.h>
#include <pthread.h>
#include <stdbool.h>
#include <inttypes.h>
#include <unictype.h>
#include <langinfo.h>
#include "lib/termdesc.h"
#include "lib/egcpool.h"
#include "lib/sprite.h"
#include "lib/fbuf.h"
#include "lib/gpm.h"
#include "blitset.h"
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ncplane
 
struct  rasterstate
 
struct  nctablet
 
struct  ncreel
 
struct  ncfdplane
 
struct  ncsubproc
 
struct  ncreader
 
struct  ncprogbar
 
struct  nctab
 
struct  ncsharedstats
 
struct  ncdirect
 
struct  crender
 
struct  ncpile
 
struct  notcurses
 
struct  blitterargs
 
struct  blitset
 
struct  topolyfill
 
struct  ncvisual_implementation
 

Macros

#define API   __attribute__((visibility("default")))
 
#define ALLOC   __attribute__((malloc)) __attribute__((warn_unused_result))
 
#define __STDC_FORMAT_MACROS
 
#define NC_BLITTERSTACK_MASK   NC_NOBACKGROUND_MASK
 
#define SET_X10_MOUSE_PROT   "9"
 
#define SET_X11_MOUSE_PROT   "1000"
 
#define SET_HILITE_MOUSE_PROT   "1001"
 
#define SET_BTN_EVENT_MOUSE   "1002"
 
#define SET_ALL_EVENT_MOUSE   "1003"
 
#define SET_FOCUS_EVENT_MOUSE   "1004"
 
#define SET_UTF8_MOUSE_PROT   "1005"
 
#define SET_SGR_MOUSE_PROT   "1006"
 
#define SET_ALTERNATE_SCROLL   "1007"
 
#define SET_TTYOUTPUT_SCROLL   "1010"
 
#define SET_KEYPRESS_SCROLL   "1011"
 
#define SET_URXVT_MOUSE_PROT   "1015"
 
#define SET_PIXEL_MOUSE_PROT   "1016"
 
#define SET_ENABLE_ALTSCREEN   "1046"
 
#define SET_ALTERNATE_SCREEN   "1047"
 
#define SET_SAVE_CURSOR   "1048"
 
#define SET_SMCUP   "1049"
 
#define DECSET(p)   "\x1b[?" p "h"
 
#define DECRST(p)   "\x1b[?" p "l"
 

Typedefs

typedef struct ncplane ncplane
 
typedef struct rasterstate rasterstate
 
typedef struct nctablet nctablet
 
typedef struct ncreel ncreel
 
typedef struct ncfdplane ncfdplane
 
typedef struct ncsubproc ncsubproc
 
typedef struct ncreader ncreader
 
typedef struct ncprogbar ncprogbar
 
typedef struct nctab nctab
 
typedef struct ncsharedstats ncsharedstats
 
typedef struct ncdirect ncdirect
 
typedef struct ncpile ncpile
 
typedef struct notcurses notcurses
 
typedef struct blitterargs blitterargs
 
typedef struct ncvisual_implementation ncvisual_implementation
 

Functions

void reset_stats (ncstats *stats)
 
void summarize_stats (notcurses *nc)
 
void update_raster_stats (const struct timespec *time1, const struct timespec *time0, ncstats *stats)
 
void update_render_stats (const struct timespec *time1, const struct timespec *time0, ncstats *stats)
 
void update_raster_bytes (ncstats *stats, int bytes)
 
void update_write_stats (const struct timespec *time1, const struct timespec *time0, ncstats *stats, int bytes)
 
void sigwinch_handler (int signo)
 
void init_lang (void)
 
int reset_term_attributes (const tinfo *ti, fbuf *f)
 
int reset_term_palette (const tinfo *ti, fbuf *f, unsigned touchedpalette)
 
void warn_terminfo (const notcurses *nc, const tinfo *ti)
 
int resize_callbacks_children (ncplane *n)
 
int ncvisual_init (int loglevel)
 
int clear_and_home (notcurses *nc, tinfo *ti, fbuf *f)
 
int sprite_wipe (const notcurses *nc, sprixel *s, int y, int x)
 
void sprixel_free (sprixel *s)
 
void sprixel_hide (sprixel *s)
 
sprixelsprixel_alloc (ncplane *n, int dimy, int dimx)
 
sprixelsprixel_recycle (ncplane *n)
 
int sprite_clear_all (const tinfo *t, fbuf *f)
 
void sprixel_invalidate (sprixel *s, int y, int x)
 
void sprixel_movefrom (sprixel *s, int y, int x)
 
void sprixel_debug (const sprixel *s, FILE *out)
 
void sixelmap_free (struct sixelmap *s)
 
int ncplane_resize_internal (ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
 
int update_term_dimensions (unsigned *rows, unsigned *cols, tinfo *tcache, int margin_b, unsigned *cgeo_changed, unsigned *pgeo_changed) __attribute__((nonnull(3
 
ALLOC void * bgra_to_rgba (const void *data, int rows, int *rowstride, int cols, int alpha)
 
ALLOC void * rgb_loose_to_rgba (const void *data, int rows, int *rowstride, int cols, int alpha)
 
ALLOC void * rgb_packed_to_rgba (const void *data, int rows, int *rowstride, int cols, int alpha)
 
int ncvisual_bounding_box (const struct ncvisual *ncv, int *leny, int *lenx, int *offy, int *offx)
 
ncplanencplane_new_internal (notcurses *nc, ncplane *n, const ncplane_options *nopts)
 
void free_plane (ncplane *p)
 
ALLOC char * ncplane_vprintf_prep (const char *format, va_list ap)
 
int ncvisual_blit_internal (const struct ncvisual *ncv, int rows, int cols, ncplane *n, const struct blitset *bset, const blitterargs *bargs)
 
int set_fd_nonblocking (int fd, unsigned state, unsigned *oldstate)
 
int mouse_setup (tinfo *ti, unsigned eventmask)
 
void scroll_down (ncplane *n)
 
int get_tty_fd (FILE *ttyfp)
 
bool check_gradient_args (uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br)
 
void ncvisual_printbanner (fbuf *f)
 
int ncdirect_set_fg_rgb_f (ncdirect *nc, unsigned rgb, fbuf *f)
 
int ncdirect_set_bg_rgb_f (ncdirect *nc, unsigned rgb, fbuf *f)
 
int term_fg_rgb8 (const tinfo *ti, fbuf *f, unsigned r, unsigned g, unsigned b)
 
const struct blitsetlookup_blitset (const tinfo *tcache, ncblitter_e setid, bool may_degrade)
 
int ncvisual_geom_inner (const tinfo *ti, const struct ncvisual *n, const struct ncvisual_options *vopts, ncvgeom *geom, const struct blitset **bset, unsigned *disppxy, unsigned *disppxx, unsigned *outy, unsigned *outx, int *placey, int *placex)
 
int putenv_term (const char *termname) __attribute__((nonnull(1)))
 
int set_loglevel_from_env (ncloglevel_e *loglevel) __attribute__((nonnull(1)))
 
void ncmetric_use_utf8 (void)
 

Variables

API ncvisual_implementationvisual_implementation
 

Macro Definition Documentation

◆ __STDC_FORMAT_MACROS

#define __STDC_FORMAT_MACROS

Definition at line 39 of file internal.h.

◆ ALLOC

#define ALLOC   __attribute__((malloc)) __attribute__((warn_unused_result))

Definition at line 20 of file internal.h.

◆ API

#define API   __attribute__((visibility("default")))

Definition at line 16 of file internal.h.

◆ DECRST

#define DECRST (   p)    "\x1b[?" p "l"

Definition at line 1195 of file internal.h.

◆ DECSET

#define DECSET (   p)    "\x1b[?" p "h"

Definition at line 1194 of file internal.h.

◆ NC_BLITTERSTACK_MASK

#define NC_BLITTERSTACK_MASK   NC_NOBACKGROUND_MASK

Definition at line 57 of file internal.h.

◆ SET_ALL_EVENT_MOUSE

#define SET_ALL_EVENT_MOUSE   "1003"

Definition at line 1180 of file internal.h.

◆ SET_ALTERNATE_SCREEN

#define SET_ALTERNATE_SCREEN   "1047"

Definition at line 1190 of file internal.h.

◆ SET_ALTERNATE_SCROLL

#define SET_ALTERNATE_SCROLL   "1007"

Definition at line 1184 of file internal.h.

◆ SET_BTN_EVENT_MOUSE

#define SET_BTN_EVENT_MOUSE   "1002"

Definition at line 1179 of file internal.h.

◆ SET_ENABLE_ALTSCREEN

#define SET_ENABLE_ALTSCREEN   "1046"

Definition at line 1189 of file internal.h.

◆ SET_FOCUS_EVENT_MOUSE

#define SET_FOCUS_EVENT_MOUSE   "1004"

Definition at line 1181 of file internal.h.

◆ SET_HILITE_MOUSE_PROT

#define SET_HILITE_MOUSE_PROT   "1001"

Definition at line 1178 of file internal.h.

◆ SET_KEYPRESS_SCROLL

#define SET_KEYPRESS_SCROLL   "1011"

Definition at line 1186 of file internal.h.

◆ SET_PIXEL_MOUSE_PROT

#define SET_PIXEL_MOUSE_PROT   "1016"

Definition at line 1188 of file internal.h.

◆ SET_SAVE_CURSOR

#define SET_SAVE_CURSOR   "1048"

Definition at line 1191 of file internal.h.

◆ SET_SGR_MOUSE_PROT

#define SET_SGR_MOUSE_PROT   "1006"

Definition at line 1183 of file internal.h.

◆ SET_SMCUP

#define SET_SMCUP   "1049"

Definition at line 1192 of file internal.h.

◆ SET_TTYOUTPUT_SCROLL

#define SET_TTYOUTPUT_SCROLL   "1010"

Definition at line 1185 of file internal.h.

◆ SET_URXVT_MOUSE_PROT

#define SET_URXVT_MOUSE_PROT   "1015"

Definition at line 1187 of file internal.h.

◆ SET_UTF8_MOUSE_PROT

#define SET_UTF8_MOUSE_PROT   "1005"

Definition at line 1182 of file internal.h.

◆ SET_X10_MOUSE_PROT

#define SET_X10_MOUSE_PROT   "9"

Definition at line 1175 of file internal.h.

◆ SET_X11_MOUSE_PROT

#define SET_X11_MOUSE_PROT   "1000"

Definition at line 1177 of file internal.h.

Typedef Documentation

◆ blitterargs

typedef struct blitterargs blitterargs

◆ ncdirect

typedef struct ncdirect ncdirect

◆ ncfdplane

typedef struct ncfdplane ncfdplane

◆ ncpile

typedef struct ncpile ncpile

◆ ncplane

typedef struct ncplane ncplane

◆ ncprogbar

typedef struct ncprogbar ncprogbar

◆ ncreader

typedef struct ncreader ncreader

◆ ncreel

typedef struct ncreel ncreel

◆ ncsharedstats

typedef struct ncsharedstats ncsharedstats

◆ ncsubproc

typedef struct ncsubproc ncsubproc

◆ nctab

typedef struct nctab nctab

◆ nctablet

typedef struct nctablet nctablet

◆ ncvisual_implementation

◆ notcurses

typedef struct notcurses notcurses

◆ rasterstate

typedef struct rasterstate rasterstate

Function Documentation

◆ bgra_to_rgba()

ALLOC void * bgra_to_rgba ( const void *  data,
int  rows,
int *  rowstride,
int  cols,
int  alpha 
)

Definition at line 508 of file visual.c.

508 {
509 if(*rowstride % 4){ // must be a multiple of 4 bytes
510 return NULL;
511 }
512 if(*rowstride < cols * 4){
513 return NULL;
514 }
515 uint32_t* ret = malloc(4 * cols * rows);
516 if(ret){
517 for(int y = 0 ; y < rows ; ++y){
518 for(int x = 0 ; x < cols ; ++x){
519 const uint32_t* src = (const uint32_t*)data + (*rowstride / 4) * y + x;
520 uint32_t* dst = ret + cols * y + x;
521 *dst = 0; // kill scan-build warning about using uninitialized value below
522 ncpixel_set_a(dst, alpha);
523 ncpixel_set_r(dst, ncpixel_b(*src));
524 ncpixel_set_g(dst, ncpixel_g(*src));
525 ncpixel_set_b(dst, ncpixel_r(*src));
526 }
527 }
528 }
529 *rowstride = cols * 4;
530 return ret;
531}
int y
Definition notcurses.h:1905
int int x
Definition notcurses.h:1905
return NULL
Definition termdesc.h:229
Here is the caller graph for this function:

◆ check_gradient_args()

bool check_gradient_args ( uint64_t  ul,
uint64_t  ur,
uint64_t  bl,
uint64_t  br 
)

Definition at line 150 of file fill.c.

150 {
151 if(check_gradient_channel_args(ncchannels_fchannel(ul), ncchannels_fchannel(ur),
152 ncchannels_fchannel(bl), ncchannels_fchannel(br))){
153 return true;
154 }
155 if(check_gradient_channel_args(ncchannels_bchannel(ul), ncchannels_bchannel(ur),
156 ncchannels_bchannel(bl), ncchannels_bchannel(br))){
157 return true;
158 }
159 return false;
160}
API int API int API int uint64_t ul
Definition direct.h:215
API int API int API int uint64_t uint64_t ur
Definition direct.h:215
Here is the caller graph for this function:

◆ clear_and_home()

int clear_and_home ( notcurses nc,
tinfo ti,
fbuf f 
)

Definition at line 1399 of file render.c.

1399 {
1400 // clear clears the screen and homes the cursor by itself
1401 const char* clearscr = get_escape(ti, ESCAPE_CLEAR);
1402 if(clearscr){
1403 if(fbuf_emit(f, clearscr) == 0){
1404 nc->rstate.x = nc->rstate.y = 0;
1405 return 0;
1406 }
1407 }
1408 if(emit_scrolls_track(nc, ncplane_dim_y(notcurses_stdplane_const(nc)), f)){
1409 return -1;
1410 }
1411 if(goto_location(nc, f, 0, 0, NULL)){
1412 return -1;
1413 }
1414 return 0;
1415}
const ncplane * notcurses_stdplane_const(const notcurses *nc)
Definition notcurses.c:706
rasterstate rstate
Definition internal.h:336
@ ESCAPE_CLEAR
Definition termdesc.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_plane()

void free_plane ( ncplane p)

Definition at line 467 of file notcurses.c.

467 {
468 if(p){
469 // ncdirect fakes an ncplane with no ->pile
470 if(ncplane_pile(p)){
472 pthread_mutex_lock(&nc->stats.lock);
474 ncplane_notcurses(p)->stats.s.fbbytes -= sizeof(*p->fb) * p->leny * p->lenx;
475 pthread_mutex_unlock(&nc->stats.lock);
476 if(p->above == NULL && p->below == NULL){
477 pthread_mutex_lock(&nc->pilelock);
478 ncpile_destroy(ncplane_pile(p));
479 pthread_mutex_unlock(&nc->pilelock);
480 }
481 }
482 if(p->widget){
483 void* w = p->widget;
484 void (*wdestruct)(void*) = p->wdestruct;
485 p->widget = NULL;
486 p->wdestruct = NULL;
487 logdebug("calling widget destructor %p(%p)", wdestruct, w);
488 wdestruct(w);
489 logdebug("got the widget");
490 }
491 if(p->sprite){
493 }
494 destroy_tam(p);
495 egcpool_dump(&p->pool);
496 free(p->name);
497 free(p->fb);
498 free(p);
499 }
500}
void sprixel_hide(sprixel *s)
Definition sprite.c:83
#define logdebug(fmt,...)
Definition logging.h:52
notcurses * ncplane_notcurses(const ncplane *n)
Definition notcurses.c:2631
struct ncplane * below
Definition internal.h:94
sprixel * sprite
Definition internal.h:105
unsigned lenx
Definition internal.h:86
struct ncplane * above
Definition internal.h:93
char * name
Definition internal.h:111
void(* wdestruct)(void *)
Definition internal.h:124
unsigned leny
Definition internal.h:86
void * widget
Definition internal.h:123
egcpool pool
Definition internal.h:87
nccell * fb
Definition internal.h:77
ncstats s
Definition internal.h:247
pthread_mutex_t lock
Definition internal.h:246
unsigned planes
Definition notcurses.h:1820
uint64_t fbbytes
Definition notcurses.h:1819
ncsharedstats stats
Definition internal.h:356
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_tty_fd()

int get_tty_fd ( FILE *  ttyfp)

Definition at line 455 of file fd.c.

455 {
456 int fd = -1;
457 if(ttyfp){
458 if((fd = fileno(ttyfp)) < 0){
459 logwarn("no file descriptor was available in outfp %p", ttyfp);
460 }else{
461 if(tty_check(fd)){
462 fd = dup(fd);
463 }else{
464 loginfo("fd %d is not a TTY", fd);
465 fd = -1;
466 }
467 }
468 }
469 if(fd < 0){
470 fd = open("/dev/tty", O_RDWR | O_CLOEXEC | O_NOCTTY);
471 if(fd < 0){
472 loginfo("couldn't open /dev/tty (%s)", strerror(errno));
473 }else{
474 if(!tty_check(fd)){
475 loginfo("file descriptor for /dev/tty (%d) is not actually a TTY", fd);
476 close(fd);
477 fd = -1;
478 }
479 }
480 }
481 if(fd >= 0){
482 loginfo("returning TTY fd %d", fd);
483 }
484 return fd;
485}
#define loginfo(fmt,...)
Definition logging.h:42
#define logwarn(fmt,...)
Definition logging.h:37
Here is the caller graph for this function:

◆ init_lang()

void init_lang ( void  )

Definition at line 1097 of file notcurses.c.

1097 {
1098#ifdef __MINGW32__
1099 if(setlocale(LC_ALL, ".UTF8") == NULL){
1100 logwarn("couldn't set LC_ALL to utf8");
1101 }
1102#endif
1103 const char* encoding = nl_langinfo(CODESET);
1104 if(encoding && encoding_is_utf8(encoding)){
1105 return; // already utf-8, great!
1106 }
1107 const char* lang = getenv("LANG");
1108 // if LANG was explicitly set to C/POSIX, life sucks, roll with it
1109 if(lang && (!strcmp(lang, "C") || !strcmp(lang, "POSIX"))){
1110 loginfo("LANG was explicitly set to %s, not changing locale", lang);
1111 return;
1112 }
1113#ifndef __MINGW32__
1114 if(setlocale(LC_ALL, "") == NULL){
1115 logwarn("setting locale based on LANG failed");
1116 }
1117#endif
1118 encoding = nl_langinfo(CODESET);
1119 if(encoding && encoding_is_utf8(encoding)){
1120 loginfo("set locale from LANG; client should call setlocale(2)!");
1121 return;
1122 }
1123 setlocale(LC_CTYPE, "C.UTF-8");
1124 encoding = nl_langinfo(CODESET);
1125 if(encoding && encoding_is_utf8(encoding)){
1126 loginfo("forced UTF-8 encoding; client should call setlocale(2)!");
1127 return;
1128 }
1129}
Here is the caller graph for this function:

◆ lookup_blitset()

const struct blitset * lookup_blitset ( const tinfo tcache,
ncblitter_e  setid,
bool  may_degrade 
)

Definition at line 1297 of file blit.c.

1298 {
1299 if(setid == NCBLIT_DEFAULT){ // ought have resolved NCBLIT_DEFAULT before now
1300 return NULL;
1301 }
1302 // without braille support, NCBLIT_BRAILLE decays to NCBLIT_4x2
1303 if(setid == NCBLIT_BRAILLE){
1304 if(tcache->caps.braille){
1305 return &notcurses_blitters[setid - 1];
1306 }else if(!may_degrade){
1307 return NULL;
1308 }
1309 setid = NCBLIT_4x2;
1310 }
1311 // without octant support, NCBLIT_4x2 decays to NCBLIT_3x2
1312 if(setid == NCBLIT_4x2){
1313 if(tcache->caps.octants){
1314 return &notcurses_blitters[setid - 1];
1315 }else if(!may_degrade){
1316 return NULL;
1317 }
1318 setid = NCBLIT_3x2;
1319 }
1320 // without bitmap support, NCBLIT_PIXEL decays to NCBLIT_3x2
1321 if(setid == NCBLIT_PIXEL){
1322 if(tcache->pixel_draw || tcache->pixel_draw_late){
1323 return &notcurses_blitters[setid - 1];
1324 }else if(!may_degrade){
1325 return NULL;
1326 }
1327 setid = NCBLIT_3x2;
1328 }
1329 // without eighths support, NCBLIT_8x1 decays to NCBLIT_4x1
1330 if(setid == NCBLIT_8x1){ // plotter only
1331 if(tcache->caps.quadrants){
1332 return &notcurses_blitters[setid - 1];
1333 }else if(!may_degrade){
1334 return NULL;
1335 }
1336 setid = NCBLIT_4x1;
1337 }
1338 // without quarters support, NCBLIT_4x1 decays to NCBLIT_2x1
1339 if(setid == NCBLIT_4x1){ // plotter only
1340 if(tcache->caps.quadrants){
1341 return &notcurses_blitters[setid - 1];
1342 }else if(!may_degrade){
1343 return NULL;
1344 }
1345 setid = NCBLIT_2x1;
1346 }
1347 // without sextant support, NCBLIT_3x2 decays to NCBLIT_2x2
1348 if(setid == NCBLIT_3x2){
1349 if(tcache->caps.sextants){
1350 return &notcurses_blitters[setid - 1];
1351 }else if(!may_degrade){
1352 return NULL;
1353 }
1354 setid = NCBLIT_2x2;
1355 }
1356 // without quadrant support, NCBLIT_2x2 decays to NCBLIT_2x1
1357 if(setid == NCBLIT_2x2){
1358 if(tcache->caps.quadrants){
1359 return &notcurses_blitters[setid - 1];
1360 }else if(!may_degrade){
1361 return NULL;
1362 }
1363 setid = NCBLIT_2x1;
1364 }
1365 // without halfblock support, NCBLIT_2x1 decays to NCBLIT_1x1
1366 if(setid == NCBLIT_2x1){
1367 if(tcache->caps.halfblocks){
1368 return &notcurses_blitters[setid - 1];
1369 }else if(!may_degrade){
1370 return NULL;
1371 }
1372 setid = NCBLIT_1x1;
1373 }
1374 assert(NCBLIT_1x1 == setid);
1375 return &notcurses_blitters[setid - 1];
1376}
assert(r >=0)
@ NCBLIT_PIXEL
Definition notcurses.h:73
@ NCBLIT_4x2
Definition notcurses.h:71
@ NCBLIT_DEFAULT
Definition notcurses.h:66
@ NCBLIT_4x1
Definition notcurses.h:75
@ NCBLIT_2x2
Definition notcurses.h:69
@ NCBLIT_3x2
Definition notcurses.h:70
@ NCBLIT_1x1
Definition notcurses.h:67
@ NCBLIT_BRAILLE
Definition notcurses.h:72
@ NCBLIT_2x1
Definition notcurses.h:68
@ NCBLIT_8x1
Definition notcurses.h:76
int(* pixel_draw_late)(const struct tinfo *, struct sprixel *s, int yoff, int xoff)
Definition termdesc.h:149
nccapabilities caps
Definition termdesc.h:111
int(* pixel_draw)(const struct tinfo *, const struct ncpile *p, struct sprixel *s, fbuf *f, int y, int x)
Definition termdesc.h:147
Here is the call graph for this function:

◆ mouse_setup()

int mouse_setup ( tinfo ti,
unsigned  eventmask 
)

Definition at line 3 of file mice.c.

3 {
4 if(ti->qterm == TERMINAL_LINUX){
5 if(eventmask == 0){
6 if(ti->gpmfd < 0){
7 return 0;
8 }
9 ti->gpmfd = -1;
10 return gpm_close(ti);
11 }
12 if(ti->gpmfd < 0){
13 // FIXME pass in eventmask
14 if((ti->gpmfd = gpm_connect(ti)) < 0){
15 return -1;
16 }
17 }
18 return 0;
19 }
20 if(ti->ttyfd < 0){
21 logerror("no tty, not emitting mouse control\n");
22 return -1;
23 }
24 // we'll need to fill in 'h' vs 'l' for both, and the event mode
25 char command = 'h';
26 // we have to choose one event mode, where all > drag > button > none.
27 // if user wants *only* move and not button, we'll need filter those FIXME.
28 if(eventmask & NCMICE_MOVE_EVENT){
29 ti->mouseproto = '3'; // SET_ALL_EVENT_MOUSE
30 }else if(eventmask & NCMICE_DRAG_EVENT){
31 ti->mouseproto = '2'; // SET_BTN_EVENT_MOUSE
32 }else if(eventmask & NCMICE_BUTTON_EVENT){
33 ti->mouseproto = '0'; // SET_X11_MOUSE_PROT
34 }else if(eventmask == 0){
35 if(ti->mouseproto == 0){
36 return 0;
37 }
38 command = 'l';
39 }
40// Sets the shift-escape option, allowing shift+mouse to override the standard
41// mouse protocol (mainly so copy-and-paste can still be performed).
42#define XTSHIFTESCAPE "\x1b[>1s"
43 char* mousecmd;
44 if(ti->pixelmice){
45 static char m[] = XTSHIFTESCAPE "\x1b[?100x;" SET_PIXEL_MOUSE_PROT "x";
46 mousecmd = m;
47 }else{
48 static char m[] = XTSHIFTESCAPE "\x1b[?100x;" SET_SGR_MOUSE_PROT "x";
49 mousecmd = m;
50 }
51 mousecmd[11] = ti->mouseproto;
52 mousecmd[17] = command;
53 if(command == 'l'){
54 ti->mouseproto = 0;
55 }
56 return tty_emit(mousecmd, ti->ttyfd);
57#undef XTSHIFTESCAPE
58}
int gpm_connect(tinfo *ti)
Definition gpm.c:79
int gpm_close(tinfo *ti)
Definition gpm.c:90
@ TERMINAL_LINUX
Definition in.h:35
#define SET_PIXEL_MOUSE_PROT
Definition internal.h:1188
#define SET_SGR_MOUSE_PROT
Definition internal.h:1183
#define logerror(fmt,...)
Definition logging.h:32
#define XTSHIFTESCAPE
#define NCMICE_BUTTON_EVENT
Definition notcurses.h:1342
#define NCMICE_DRAG_EVENT
Definition notcurses.h:1343
#define NCMICE_MOVE_EVENT
Definition notcurses.h:1341
queried_terminals_e qterm
Definition termdesc.h:178
char mouseproto
Definition termdesc.h:196
bool pixelmice
Definition termdesc.h:197
int gpmfd
Definition termdesc.h:195
int ttyfd
Definition termdesc.h:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_bg_rgb_f()

int ncdirect_set_bg_rgb_f ( ncdirect nc,
unsigned  rgb,
fbuf f 
)

Definition at line 1652 of file render.c.

1652 {
1653 if(rgb > 0xffffffu){
1654 return -1;
1655 }
1656 if(!ncdirect_bg_default_p(nc) && !ncdirect_bg_palindex_p(nc)
1657 && ncchannels_bg_rgb(nc->channels) == rgb){
1658 return 0;
1659 }
1660 if(term_bg_rgb8(&nc->tcache, f, (rgb & 0xff0000u) >> 16u, (rgb & 0xff00u) >> 8u, rgb & 0xffu)){
1661 return -1;
1662 }
1663 ncchannels_set_bg_rgb(&nc->channels, rgb);
1664 return 0;
1665}
uint64_t channels
Definition internal.h:254
tinfo tcache
Definition internal.h:253
Here is the caller graph for this function:

◆ ncdirect_set_fg_rgb_f()

int ncdirect_set_fg_rgb_f ( ncdirect nc,
unsigned  rgb,
fbuf f 
)

Definition at line 1682 of file render.c.

1682 {
1683 if(rgb > 0xffffffu){
1684 return -1;
1685 }
1686 if(!ncdirect_fg_default_p(nc) && !ncdirect_fg_palindex_p(nc)
1687 && ncchannels_fg_rgb(nc->channels) == rgb){
1688 return 0;
1689 }
1690 if(term_fg_rgb8(&nc->tcache, f, (rgb & 0xff0000u) >> 16u, (rgb & 0xff00u) >> 8u, rgb & 0xffu)){
1691 return -1;
1692 }
1693 ncchannels_set_fg_rgb(&nc->channels, rgb);
1694 return 0;
1695}
int term_fg_rgb8(const tinfo *ti, fbuf *f, unsigned r, unsigned g, unsigned b)
Definition render.c:743
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmetric_use_utf8()

void ncmetric_use_utf8 ( void  )

Definition at line 24 of file metric.c.

24 {
25 pthread_once(&utf8_verdict, ncmetric_use_utf8_internal);
26}
Here is the caller graph for this function:

◆ ncplane_new_internal()

ncplane * ncplane_new_internal ( notcurses nc,
ncplane n,
const ncplane_options nopts 
)

Definition at line 560 of file notcurses.c.

561 {
562 if(nopts->flags >= (NCPLANE_OPTION_FIXED << 1u)){
563 logwarn("provided unsupported flags %016" PRIx64, nopts->flags);
564 }
566 if(n == NULL){
567 logerror("alignment requires a parent plane");
568 return NULL;
569 }
570 }
572 if(nopts->rows != 0 || nopts->cols != 0){
573 logerror("geometry specified with margins (r=%u, c=%u)",
574 nopts->rows, nopts->cols);
575 return NULL;
576 }
577 }
578 ncplane* p = malloc(sizeof(*p));
579 if(p == NULL){
580 return NULL;
581 }
585 p->widget = NULL;
586 p->wdestruct = NULL;
588 p->margin_b = nopts->margin_b;
589 p->margin_r = nopts->margin_r;
590 if(n){ // use parent size
591 p->leny = ncplane_dim_y(n);
592 p->lenx = ncplane_dim_x(n);
593 }else{ // use pile size
594 notcurses_term_dim_yx(nc, &p->leny, &p->lenx);
595 }
596 if((p->leny -= p->margin_b) <= 0){
597 p->leny = 1;
598 }
599 if((p->lenx -= p->margin_r) <= 0){
600 p->lenx = 1;
601 }
602 }else{
603 p->leny = nopts->rows;
604 p->lenx = nopts->cols;
605 }
606
607 size_t fbsize = ncplane_sizeof_cellarray(p->leny, p->lenx);
608 if(!fbsize || (p->fb = calloc(fbsize, sizeof(struct nccell))) == NULL){
609 logerror("error allocating cellmatrix (r=%u, c=%u)",
610 p->leny, p->lenx);
611 free(p);
612 return NULL;
613 }
614 p->x = p->y = 0;
615 p->logrow = 0;
616 p->sprite = NULL;
617 p->blist = NULL;
618 p->name = strdup(nopts->name ? nopts->name : "");
621 p->tam = NULL;
622 if(!n){ // new root/standard plane
623 p->absy = nopts->y;
624 p->absx = nopts->x;
625 p->bnext = NULL;
626 p->bprev = NULL;
627 p->boundto = p;
628 }else{ // bound to preexisting pile
629 if(nopts->flags & NCPLANE_OPTION_HORALIGNED){
630 p->absx = ncplane_halign(n, nopts->x, nopts->cols);
631 p->halign = nopts->x;
632 }else{
633 p->absx = nopts->x;
634 }
635 p->absx += n->absx;
636 if(nopts->flags & NCPLANE_OPTION_VERALIGNED){
637 p->absy = ncplane_valign(n, nopts->y, nopts->rows);
638 p->valign = nopts->y;
639 }else{
640 p->absy = nopts->y;
641 }
642 p->absy += n->absy;
643 if( (p->bnext = n->blist) ){
644 n->blist->bprev = &p->bnext;
645 }
646 p->bprev = &n->blist;
647 *p->bprev = p;
648 p->boundto = n;
649 }
650 // FIXME handle top/left margins
651 p->resizecb = nopts->resizecb;
652 p->stylemask = 0;
653 p->channels = 0;
654 egcpool_init(&p->pool);
655 nccell_init(&p->basecell);
656 p->userptr = nopts->userptr;
657 if(nc == NULL){ // fake ncplane backing ncdirect object
658 p->above = NULL;
659 p->below = NULL;
660 p->pile = NULL;
661 }else{
662 pthread_mutex_lock(&nc->pilelock);
663 ncpile* pile = n ? ncplane_pile(n) : NULL;
664 if( (p->pile = pile) ){ // existing pile
665 p->above = NULL;
666 if( (p->below = pile->top) ){ // always happens save initial plane
667 pile->top->above = p;
668 }else{
669 pile->bottom = p;
670 }
671 pile->top = p;
672 }else{ // new pile
673 make_ncpile(nc, p);
674 }
675 pthread_mutex_lock(&nc->stats.lock);
676 nc->stats.s.fbbytes += fbsize;
677 ++nc->stats.s.planes;
678 pthread_mutex_unlock(&nc->stats.lock);
679 pthread_mutex_unlock(&nc->pilelock);
680 }
681 loginfo("created new %ux%u plane \"%s\" @ %dx%d",
682 p->leny, p->lenx, p->name ? p->name : "", p->absy, p->absx);
683 return p;
684}
#define NCPLANE_OPTION_HORALIGNED
Definition notcurses.h:1441
#define NCPLANE_OPTION_AUTOGROW
Definition notcurses.h:1458
#define NCPLANE_OPTION_MARGINALIZED
Definition notcurses.h:1450
#define NCPLANE_OPTION_VSCROLL
Definition notcurses.h:1462
@ NCALIGN_UNALIGNED
Definition notcurses.h:81
#define NCPLANE_OPTION_VERALIGNED
Definition notcurses.h:1443
vopts n
Definition notcurses.h:3506
#define NCPLANE_OPTION_FIXED
Definition notcurses.h:1454
ncplane * bottom
Definition internal.h:319
ncplane * top
Definition internal.h:318
unsigned margin_r
Definition notcurses.h:1473
const char * name
Definition notcurses.h:1470
int(* resizecb)(struct ncplane *)
Definition notcurses.h:1471
unsigned margin_b
Definition notcurses.h:1473
int logrow
Definition internal.h:78
ncalign_e valign
Definition internal.h:113
bool fixedbound
Definition internal.h:117
bool scrolling
Definition internal.h:116
nccell basecell
Definition internal.h:110
bool autogrow
Definition internal.h:118
struct ncpile * pile
Definition internal.h:92
struct ncplane * blist
Definition internal.h:102
uint64_t channels
Definition internal.h:88
ncalign_e halign
Definition internal.h:112
struct ncplane * boundto
Definition internal.h:103
struct ncplane * bnext
Definition internal.h:100
unsigned x
Definition internal.h:79
struct ncplane ** bprev
Definition internal.h:101
int absy
Definition internal.h:83
uint16_t stylemask
Definition internal.h:114
void * userptr
Definition internal.h:108
tament * tam
Definition internal.h:106
int(* resizecb)(struct ncplane *)
Definition internal.h:109
unsigned y
Definition internal.h:79
int absx
Definition internal.h:83
int margin_b
Definition internal.h:115
int margin_r
Definition internal.h:115
pthread_mutex_t pilelock
Definition internal.h:361
Here is the caller graph for this function:

◆ ncplane_resize_internal()

int ncplane_resize_internal ( ncplane n,
int  keepy,
int  keepx,
unsigned  keepleny,
unsigned  keeplenx,
int  yoff,
int  xoff,
unsigned  ylen,
unsigned  xlen 
)

Definition at line 857 of file notcurses.c.

860 {
861 unsigned rows, cols;
862 if(ncplane_resize_internal_check(n, keepy, keepx, keepleny, keeplenx,
863 yoff, xoff, ylen, xlen,
864 &rows, &cols)){
865 return -1;
866 }
867 if(n->absy == n->absy + keepy && n->absx == n->absx + keepx &&
868 rows == ylen && cols == xlen){
869 return 0;
870 }
872 if(n->sprite){
873 sprixel_hide(n->sprite);
874 }
875 // we're good to resize. we'll need alloc up a new framebuffer, and copy in
876 // those elements we're retaining, zeroing out the rest. alternatively, if
877 // we've shrunk, we will be filling the new structure.
878 int oldarea = rows * cols;
879 int keptarea = keepleny * keeplenx;
880 int newarea = ylen * xlen;
881 size_t fbsize = sizeof(nccell) * newarea;
882 nccell* fb;
883 // there are two cases worth optimizing:
884 //
885 // * nothing is kept. we malloc() a new cellmatrix, dump the EGCpool in
886 // toto, and zero out the matrix. no copies, one memset.
887 // * old and new x dimensions match, and we're keeping the full width.
888 // we release any cells we're about to lose, realloc() the cellmatrix,
889 // and zero out any new cells. so long as the realloc() doesn't move
890 // us, there are no copies, one memset, one iteration (since this is
891 // most often due to autogrowth by a single line, the likelihood that
892 // we remain where we are is pretty high).
893 // * otherwise, we malloc() a new cellmatrix, zero out any new cells,
894 // copy over any reused cells, and release any lost cells. one
895 // gigantic iteration.
896 // we might realloc instead of mallocing, in which case we NULL out
897 // |preserved|. it must otherwise be free()d at the end.
898 nccell* preserved = n->fb;
899 if(cols == xlen && cols == keeplenx && keepleny && !keepy){
900 // we need release the cells that we're losing, lest we leak EGCpool
901 // memory. unfortunately, this means we mutate the plane on the error case.
902 // any solution would involve copying them out first. we only do this if
903 // we're keeping some, as we otherwise drop the EGCpool in toto.
904 if(n->leny > keepleny){
905 for(unsigned y = keepleny ; y < n->leny ; ++y){
906 for(unsigned x = 0 ; x < n->lenx ; ++x){
907 nccell_release(n, ncplane_cell_ref_yx(n, y, x));
908 }
909 }
910 }
911 if((fb = realloc(n->fb, fbsize)) == NULL){
912 return -1;
913 }
914 preserved = NULL;
915 }else{
916 if((fb = malloc(fbsize)) == NULL){
917 return -1;
918 }
919 }
920 if(n->tam){
921 loginfo("tam realloc to %d entries", newarea);
922 // FIXME first, free any disposed auxiliary vectors!
923 tament* tmptam = realloc(n->tam, sizeof(*tmptam) * newarea);
924 if(tmptam == NULL){
925 if(preserved){
926 free(fb);
927 }
928 return -1;
929 }
930 n->tam = tmptam;
931 if(newarea > oldarea){
932 memset(n->tam + oldarea, 0, sizeof(*n->tam) * (newarea - oldarea));
933 }
934 }
935 // update the cursor, if it would otherwise be off-plane
936 if(n->y >= ylen){
937 n->y = ylen - 1;
938 }
939 if(n->x >= xlen){
940 n->x = xlen - 1;
941 }
942 pthread_mutex_lock(&nc->stats.lock);
943 ncplane_notcurses(n)->stats.s.fbbytes -= sizeof(*fb) * (rows * cols);
944 ncplane_notcurses(n)->stats.s.fbbytes += fbsize;
945 pthread_mutex_unlock(&nc->stats.lock);
946 const int oldabsy = n->absy;
947 // go ahead and move. we can no longer fail at this point. but don't yet
948 // resize, because n->len[xy] are used in fbcellidx() in the loop below. we
949 // don't use ncplane_move_yx(), because we want to planebinding-invariant.
950 n->absy += keepy + yoff;
951 n->absx += keepx + xoff;
952//fprintf(stderr, "absx: %d keepx: %d xoff: %d\n", n->absx, keepx, xoff);
953 if(keptarea == 0){ // keep nothing, resize/move only.
954 // if we're keeping nothing, dump the old egcspool. otherwise, we go ahead
955 // and keep it. perhaps we ought compact it?
956 memset(fb, 0, sizeof(*fb) * newarea);
957 egcpool_dump(&n->pool);
958 }else if(!preserved){
959 // the x dimensions are equal, and we're keeping across the width. only the
960 // y dimension changed. if we grew, we need zero out the new cells (if we
961 // shrunk, we already released the old cells prior to the realloc).
962 unsigned tozorch = (ylen - keepleny) * xlen * sizeof(*fb);
963 if(tozorch){
964 unsigned zorchoff = keepleny * xlen;
965 memset(fb + zorchoff, 0, tozorch);
966 }
967 }else{
968 // we currently have maxy rows of maxx cells each. we will be keeping rows
969 // keepy..keepy + keepleny - 1 and columns keepx..keepx + keeplenx - 1.
970 // anything else is zerod out. itery is the row we're writing *to*, and we
971 // must write to each (and every cell in each).
972 for(unsigned itery = 0 ; itery < ylen ; ++itery){
973 int truey = itery + n->absy;
974 int sourceoffy = truey - oldabsy;
975//fprintf(stderr, "sourceoffy: %d keepy: %d ylen: %d\n", sourceoffy, keepy, ylen);
976 // if we have nothing copied to this line, zero it out in one go
977 if(sourceoffy < keepy || sourceoffy >= keepy + (int)keepleny){
978//fprintf(stderr, "writing 0s to line %d of %d\n", itery, ylen);
979 memset(fb + (itery * xlen), 0, sizeof(*fb) * xlen);
980 }else{
981 int copyoff = itery * xlen; // our target at any given time
982 // we do have something to copy, and zero, one, or two regions to zero out
983 unsigned copied = 0;
984 if(xoff < 0){
985 memset(fb + copyoff, 0, sizeof(*fb) * -xoff);
986 copyoff += -xoff;
987 copied += -xoff;
988 }
989 const int sourceidx = nfbcellidx(n, sourceoffy, keepx);
990//fprintf(stderr, "copying line %d (%d) to %d (%d)\n", sourceoffy, sourceidx, copyoff / xlen, copyoff);
991 memcpy(fb + copyoff, preserved + sourceidx, sizeof(*fb) * keeplenx);
992 copyoff += keeplenx;
993 copied += keeplenx;
994 unsigned perline = xlen - copied;
995 for(unsigned x = copyoff ; x < n->lenx ; ++x){
996 nccell_release(n, ncplane_cell_ref_yx(n, sourceoffy, x));
997 }
998 memset(fb + copyoff, 0, sizeof(*fb) * perline);
999 }
1000 }
1001 }
1002 n->fb = fb;
1003 n->lenx = xlen;
1004 n->leny = ylen;
1005 free(preserved);
1007}
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned unsigned xlen
Definition direct.h:217
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned ylen
Definition direct.h:217
int resize_callbacks_children(ncplane *n)
Definition notcurses.c:804
void nccell_release(ncplane *n, nccell *c)
Definition render.c:128
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_vprintf_prep()

ALLOC char * ncplane_vprintf_prep ( const char *  format,
va_list  ap 
)

Definition at line 2093 of file notcurses.c.

2093 {
2094 const size_t size = BUFSIZ; // healthy estimate, can embiggen below
2095 char* buf = malloc(size);
2096 if(buf == NULL){
2097 return NULL;
2098 }
2099 va_list vacopy;
2100 va_copy(vacopy, ap);
2101 int ret = vsnprintf(buf, size, format, ap);
2102 if(ret < 0){
2103 free(buf);
2104 va_end(vacopy);
2105 return NULL;
2106 }
2107 if((size_t)ret >= size){
2108 char* tmp = realloc(buf, ret + 1);
2109 if(tmp == NULL){
2110 free(buf);
2111 va_end(vacopy);
2112 return NULL;
2113 }
2114 buf = tmp;
2115 vsprintf(buf, format, vacopy);
2116 }
2117 va_end(vacopy);
2118 return buf;
2119}
va_end(va)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_blit_internal()

int ncvisual_blit_internal ( const struct ncvisual ncv,
int  rows,
int  cols,
ncplane n,
const struct blitset bset,
const blitterargs bargs 
)

◆ ncvisual_bounding_box()

int ncvisual_bounding_box ( const struct ncvisual ncv,
int *  leny,
int *  lenx,
int *  offy,
int *  offx 
)

◆ ncvisual_geom_inner()

int ncvisual_geom_inner ( const tinfo ti,
const struct ncvisual n,
const struct ncvisual_options vopts,
ncvgeom geom,
const struct blitset **  bset,
unsigned *  disppxy,
unsigned *  disppxx,
unsigned *  outy,
unsigned *  outx,
int *  placey,
int *  placex 
)
Here is the caller graph for this function:

◆ ncvisual_init()

int ncvisual_init ( int  loglevel)

Definition at line 23 of file visual.c.

23 {
26 }
27 return 0;
28}
int(* visual_init)(int loglevel)
Definition internal.h:1792
ncvisual_implementation * visual_implementation
Definition visual.c:20
Here is the caller graph for this function:

◆ ncvisual_printbanner()

void ncvisual_printbanner ( fbuf f)

Definition at line 30 of file visual.c.

Here is the caller graph for this function:

◆ putenv_term()

int putenv_term ( const char *  termname)

Definition at line 1655 of file termdesc.c.

1655 {
1656 #define ENVVAR "TERM"
1657 const char* oldterm = getenv(ENVVAR);
1658 if(oldterm){
1659 logdebug("replacing %s value %s with %s", ENVVAR, oldterm, tname);
1660 }else{
1661 loginfo("provided %s value %s", ENVVAR, tname);
1662 }
1663 if(oldterm && strcmp(oldterm, tname) == 0){
1664 return 0;
1665 }
1666 char* buf = malloc(strlen(tname) + strlen(ENVVAR) + 1);
1667 if(buf == NULL){
1668 return -1;
1669 }
1670 int c = putenv(buf);
1671 if(c){
1672 logerror("couldn't export %s", buf);
1673 }
1674 free(buf);
1675 return c;
1676}
const nccell * c
Definition egcpool.h:207
#define ENVVAR
Here is the caller graph for this function:

◆ reset_stats()

void reset_stats ( ncstats stats)

Definition at line 74 of file stats.c.

74 {
75 uint64_t fbbytes = stats->fbbytes;
76 unsigned planes = stats->planes;
77 memset(stats, 0, sizeof(*stats));
78 stats->render_min_ns = 1ull << 62u;
79 stats->raster_min_bytes = 1ull << 62u;
80 stats->raster_min_ns = 1ull << 62u;
81 stats->writeout_min_ns = 1ull << 62u;
82 stats->fbbytes = fbbytes;
83 stats->planes = planes;
84}
int64_t render_min_ns
Definition notcurses.h:1792
int64_t writeout_min_ns
Definition notcurses.h:1798
int64_t raster_min_ns
Definition notcurses.h:1795
int64_t raster_min_bytes
Definition notcurses.h:1789
Here is the caller graph for this function:

◆ reset_term_attributes()

int reset_term_attributes ( const tinfo ti,
fbuf f 
)

Definition at line 60 of file notcurses.c.

60 {
61 int ret = 0;
62 const char* esc;
63 if((esc = get_escape(ti, ESCAPE_OP)) && fbuf_emit(f, esc)){
64 ret = -1;
65 }
66 if((esc = get_escape(ti, ESCAPE_SGR0)) && fbuf_emit(f, esc)){
67 ret = -1;
68 }
69 return ret;
70}
@ ESCAPE_OP
Definition termdesc.h:50
@ ESCAPE_SGR0
Definition termdesc.h:53
Here is the caller graph for this function:

◆ reset_term_palette()

int reset_term_palette ( const tinfo ti,
fbuf f,
unsigned  touchedpalette 
)

Definition at line 78 of file notcurses.c.

78 {
79 int ret = 0;
80 const char* esc;
81 if((esc = get_escape(ti, ESCAPE_RESTORECOLORS))){
82 loginfo("restoring palette via xtpopcolors");
83 if(fbuf_emit(f, esc)){
84 ret = -1;
85 }
86 return ret;
87 }
88 if(!touchedpalette){
89 return 0;
90 }
91 if(ti->caps.can_change_colors && ti->maxpaletteread > -1){
92 loginfo("restoring saved palette (%d)", ti->maxpaletteread + 1);
93 esc = get_escape(ti, ESCAPE_INITC);
94 for(int z = 0 ; z < ti->maxpaletteread ; ++z){
95 unsigned r, g, b;
96 ncchannel_rgb8(ti->originalpalette.chans[z], &r, &g, &b);
97 // Need convert RGB values [0..256) to [0..1000], ugh
98 r = r * 1000 / 255;
99 g = g * 1000 / 255;
100 b = b * 1000 / 255;
101 if(fbuf_emit(f, tiparm(esc, z, r, g, b)) < 0){
102 return -1;
103 }
104 }
105 }else if((esc = get_escape(ti, ESCAPE_OC))){
106 loginfo("resetting palette");
107 if(fbuf_emit(f, esc)){
108 ret = -1;
109 }
110 }else{
111 logwarn("no method known to restore palette");
112 }
113 return ret;
114}
int r
Definition fbuf.h:226
bool can_change_colors
Definition notcurses.h:1640
uint32_t chans[NCPALETTESIZE]
Definition notcurses.h:1585
int maxpaletteread
Definition termdesc.h:193
ncpalette originalpalette
Definition termdesc.h:192
@ ESCAPE_RESTORECOLORS
Definition termdesc.h:88
@ ESCAPE_OC
Definition termdesc.h:56
@ ESCAPE_INITC
Definition termdesc.h:81

◆ resize_callbacks_children()

int resize_callbacks_children ( ncplane n)

Definition at line 804 of file notcurses.c.

804 {
805 int ret = 0;
806 for(struct ncplane* child = n->blist ; child ; child = child->bnext){
807 if(child->resizecb){
808 ret |= child->resizecb(child);
809 }
810 }
811 return ret;
812}
Here is the caller graph for this function:

◆ rgb_loose_to_rgba()

ALLOC void * rgb_loose_to_rgba ( const void *  data,
int  rows,
int *  rowstride,
int  cols,
int  alpha 
)

Definition at line 461 of file visual.c.

461 {
462 if(*rowstride % 4){ // must be a multiple of 4 bytes
463 return NULL;
464 }
465 if(*rowstride < cols * 4){
466 return NULL;
467 }
468 uint32_t* ret = malloc(4 * cols * rows);
469 if(ret){
470 for(int y = 0 ; y < rows ; ++y){
471 for(int x = 0 ; x < cols ; ++x){
472 const uint32_t* src = (const uint32_t*)data + (*rowstride / 4) * y + x;
473 uint32_t* dst = ret + cols * y + x;
474 *dst = 0; // kill scan-build warning about using uninitialized value below
475 ncpixel_set_a(dst, alpha);
476 ncpixel_set_r(dst, ncpixel_r(*src));
477 ncpixel_set_g(dst, ncpixel_g(*src));
478 ncpixel_set_b(dst, ncpixel_b(*src));
479 }
480 }
481 }
482 *rowstride = cols * 4;
483 return ret;
484}
Here is the caller graph for this function:

◆ rgb_packed_to_rgba()

ALLOC void * rgb_packed_to_rgba ( const void *  data,
int  rows,
int *  rowstride,
int  cols,
int  alpha 
)

Definition at line 486 of file visual.c.

486 {
487 if(*rowstride < cols * 3){
488 return NULL;
489 }
490 uint32_t* ret = malloc(4 * cols * rows);
491 if(ret){
492 for(int y = 0 ; y < rows ; ++y){
493 for(int x = 0 ; x < cols ; ++x){
494 const unsigned char* src = (const unsigned char*)data + *rowstride * y + x;
495 uint32_t* dst = ret + cols * y + x;
496 *dst = 0; // kill scan-build warning about using uninitialized value below
497 ncpixel_set_a(dst, alpha);
498 ncpixel_set_r(dst, src[0]);
499 ncpixel_set_g(dst, src[1]);
500 ncpixel_set_b(dst, src[2]);
501 }
502 }
503 }
504 *rowstride = cols * 4;
505 return ret;
506}
Here is the caller graph for this function:

◆ scroll_down()

void scroll_down ( ncplane n)

Definition at line 1761 of file notcurses.c.

1761 {
1762//fprintf(stderr, "pre-scroll: %d/%d %d/%d log: %d scrolling: %u\n", n->y, n->x, n->leny, n->lenx, n->logrow, n->scrolling);
1763 n->x = 0;
1764 if(n->y == n->leny - 1){
1765 // we're on the last line of the plane
1766 if(n->autogrow){
1767 ncplane_resize_simple(n, n->leny + 1, n->lenx);
1768 ncplane_cursor_move_yx(n, n->leny - 1, 0);
1769 return;
1770 }
1771 // we'll actually be scrolling material up and out, and making a new line.
1772 // if this is the standard plane, that means a "physical" scroll event is
1773 // called for.
1775 ncplane_pile(n)->scrolls++;
1776 }
1777 n->logrow = (n->logrow + 1) % n->leny;
1778 nccell* row = n->fb + nfbcellidx(n, n->y, 0);
1779 for(unsigned clearx = 0 ; clearx < n->lenx ; ++clearx){
1780 nccell_release(n, &row[clearx]);
1781 }
1782 memset(row, 0, sizeof(*row) * n->lenx);
1783 for(struct ncplane* c = n->blist ; c ; c = c->bnext){
1784 if(!c->fixedbound){
1785 if(ncplanes_intersect_p(n, c)){
1786 ncplane_move_rel(c, -1, 0);
1787 }
1788 }
1789 }
1790 }else{
1791 ++n->y;
1792 }
1793}
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
Definition notcurses.c:723
ncplane * notcurses_stdplane(notcurses *nc)
Definition notcurses.c:702
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_fd_nonblocking()

int set_fd_nonblocking ( int  fd,
unsigned  state,
unsigned *  oldstate 
)
Here is the caller graph for this function:

◆ set_loglevel_from_env()

int set_loglevel_from_env ( ncloglevel_e loglevel)

Definition at line 19 of file util.c.

19 {
20 const char* ll = getenv("NOTCURSES_LOGLEVEL");
21 if(ll == NULL){
22 return 0;
23 }
24 char* endl;
25 long l = strtol(ll, &endl, 10);
26 if(l < NCLOGLEVEL_PANIC || l > NCLOGLEVEL_TRACE){
27 logpanic("illegal NOTCURSES_LOGLEVEL: %s", ll);
28 return -1;
29 }
30 *llptr = l;
31 loginfo("got loglevel from environment: %ld", l);
32 return 0;
33}
API int API int API int uint64_t uint64_t uint64_t ll
Definition direct.h:216
#define logpanic(fmt,...)
Definition logging.h:22
@ NCLOGLEVEL_TRACE
Definition notcurses.h:977
Here is the caller graph for this function:

◆ sigwinch_handler()

void sigwinch_handler ( int  signo)

Definition at line 31 of file in.c.

31 {
32 if(signo == SIGWINCH){
33 resize_seen = signo;
35 }else if(signo == SIGCONT){
36 cont_seen = signo;
38 }
39}
sig_atomic_t sigcont_seen_for_render
Definition render.c:7
Here is the caller graph for this function:

◆ sixelmap_free()

void sixelmap_free ( struct sixelmap s)

Definition at line 216 of file sixel.c.

216 {
217 if(s){
218 for(int i = 0 ; i < s->sixelbands ; ++i){
219 sixelband_free(&s->bands[i]);
220 }
221 free(s->bands);
222 free(s);
223 }
224}
int sixelbands
Definition sixel.c:83
sixelband * bands
Definition sixel.c:84
Here is the caller graph for this function:

◆ sprite_clear_all()

int sprite_clear_all ( const tinfo t,
fbuf f 
)

Definition at line 204 of file sprite.c.

204 {
205 if(t->pixel_clear_all == NULL){
206 return 0;
207 }
208 return t->pixel_clear_all(f);
209}
int(* pixel_clear_all)(fbuf *f)
Definition termdesc.h:153
Here is the caller graph for this function:

◆ sprite_wipe()

int sprite_wipe ( const notcurses nc,
sprixel s,
int  y,
int  x 
)

Definition at line 170 of file sprite.c.

170 {
171 assert(s->n);
172 int idx = s->dimx * ycell + xcell;
173 if(s->n->tam[idx].state == SPRIXCELL_TRANSPARENT){
174 // need to make a transparent auxvec, because a reload will force us to
175 // update said auxvec, but needn't actually change the glyph. auxvec will
176 // be entirely 0s coming from pixel_trans_auxvec().
177 if(s->n->tam[idx].auxvector == NULL){
179 s->n->tam[idx].auxvector = nc->tcache.pixel_trans_auxvec(ncplane_pile(s->n));
180 if(s->n->tam[idx].auxvector == NULL){
181 return -1;
182 }
183 }
184 }
185 // no need to update to INVALIDATED; no redraw is necessary
187 return 1;
188 }
191//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
192 return 0;
193 }
194 logdebug("wiping %p %d %d/%d", s->n->tam, idx, ycell, xcell);
195 int r = nc->tcache.pixel_wipe(s, ycell, xcell);
196//fprintf(stderr, "WIPED %d %d/%d ret=%d\n", s->id, ycell, xcell, r);
197 // mark the cell as annihilated whether we actually scrubbed it or not,
198 // so that we use this fact should we move to another frame
200 assert(s->n->tam[idx].auxvector);
201 return r;
202}
uint32_t idx
Definition egcpool.h:209
@ SPRIXCELL_ANNIHILATED
Definition sprite.h:120
@ SPRIXCELL_TRANSPARENT
Definition sprite.h:115
@ SPRIXCELL_ANNIHILATED_TRANS
Definition sprite.h:121
tinfo tcache
Definition internal.h:360
unsigned dimx
Definition sprite.h:146
struct ncplane * n
Definition sprite.h:142
void * auxvector
Definition sprite.h:128
sprixcell_e state
Definition sprite.h:127
int(* pixel_wipe)(struct sprixel *s, int y, int x)
Definition termdesc.h:138
uint8_t *(* pixel_trans_auxvec)(const struct ncpile *p)
Definition termdesc.h:159
Here is the call graph for this function:

◆ sprixel_alloc()

sprixel * sprixel_alloc ( ncplane n,
int  dimy,
int  dimx 
)

Definition at line 117 of file sprite.c.

117 {
118 sprixel* ret = malloc(sizeof(sprixel));
119 if(ret == NULL){
120 return NULL;
121 }
122 memset(ret, 0, sizeof(*ret));
123 if(fbuf_init(&ret->glyph)){
124 free(ret);
125 return NULL;
126 }
127 ret->n = n;
128 ret->dimy = dimy;
129 ret->dimx = dimx;
130 ret->id = ++sprixelid_nonce;
131 ret->needs_refresh = NULL;
132 if(ret->id >= 0x1000000){
133 ret->id = 1;
134 sprixelid_nonce = 1;
135 }
136//fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n);
137 if(ncplane_pile(ret->n)){ // rendered mode
138 ncpile* np = ncplane_pile(ret->n);
139 if( (ret->next = np->sprixelcache) ){
140 ret->next->prev = ret;
141 }
142 np->sprixelcache = ret;
143 ret->prev = NULL;
144//fprintf(stderr, "%p %p %p\n", nc->sprixelcache, ret, nc->sprixelcache->next);
145 }else{ // ncdirect case
146 ret->next = ret->prev = NULL;
147 }
148 return ret;
149}
sprixel * sprixelcache
Definition internal.h:328
struct sprixel * prev
Definition sprite.h:145
unsigned dimy
Definition sprite.h:146
fbuf glyph
Definition sprite.h:138
struct sprixel * next
Definition sprite.h:144
unsigned char * needs_refresh
Definition sprite.h:156
uint32_t id
Definition sprite.h:139
Here is the caller graph for this function:

◆ sprixel_debug()

void sprixel_debug ( const sprixel s,
FILE *  out 
)

Definition at line 7 of file sprite.c.

7 {
8 fprintf(out, "sprixel %d (%p) %" PRIu64 "B %dx%d (%dx%d) @%d/%d state: %d\n",
9 s->id, s, s->glyph.used, s->dimy, s->dimx, s->pixy, s->pixx,
10 s->n ? s->n->absy : 0, s->n ? s->n->absx : 0,
11 s->invalidated);
12 if(s->n){
13 int idx = 0;
14 for(unsigned y = 0 ; y < s->dimy ; ++y){
15 for(unsigned x = 0 ; x < s->dimx ; ++x){
16 fprintf(out, "%d", s->n->tam[idx].state);
17 ++idx;
18 }
19 fprintf(out, "\n");
20 }
21 idx = 0;
22 for(unsigned y = 0 ; y < s->dimy ; ++y){
23 for(unsigned x = 0 ; x < s->dimx ; ++x){
25 if(s->n->tam[idx].auxvector){
26 fprintf(out, "%03d] %p\n", idx, s->n->tam[idx].auxvector);
27 }else{
28 fprintf(out, "%03d] missing!\n", idx);
29 }
30 }
31 ++idx;
32 }
33 }
34 }
35}
uint64_t used
Definition fbuf.h:27
int pixx
Definition sprite.h:147
int pixy
Definition sprite.h:147

◆ sprixel_free()

void sprixel_free ( sprixel s)

Definition at line 38 of file sprite.c.

38 {
39 if(s){
40 loginfo("destroying sprixel %u", s->id);
41 if(s->n){
42 s->n->sprite = NULL;
43 }
45 free(s->needs_refresh);
46 fbuf_free(&s->glyph);
47 free(s);
48 }
49}
void sixelmap_free(struct sixelmap *s)
Definition sixel.c:216
struct sixelmap * smap
Definition sprite.h:157
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sprixel_hide()

void sprixel_hide ( sprixel s)

Definition at line 83 of file sprite.c.

83 {
84 if(ncplane_pile(s->n) == NULL){ // ncdirect case; destroy now
85 sprixel_free(s);
86 return;
87 }
88 // otherwise, it'll be killed in the next rendering cycle.
89 if(s->invalidated != SPRIXEL_HIDE){
90 loginfo("marking sprixel %u hidden", s->id);
92 s->movedfromy = ncplane_abs_y(s->n);
93 s->movedfromx = ncplane_abs_x(s->n);
94 // guard; might have already been replaced
95 if(s->n){
96 s->n->sprite = NULL;
97 s->n = NULL;
98 }
99 }
100}
int ncplane_abs_x(const ncplane *n)
Definition notcurses.c:2643
int ncplane_abs_y(const ncplane *n)
Definition notcurses.c:2639
void sprixel_free(sprixel *s)
Definition sprite.c:38
@ SPRIXEL_HIDE
Definition sprite.h:25
int movedfromx
Definition sprite.h:151
int movedfromy
Definition sprite.h:150
sprixel_e invalidated
Definition sprite.h:143
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sprixel_invalidate()

void sprixel_invalidate ( sprixel s,
int  y,
int  x 
)

Definition at line 103 of file sprite.c.

103 {
104//fprintf(stderr, "INVALIDATING AT %d/%d\n", y, x);
105 if(s->invalidated == SPRIXEL_QUIESCENT && s->n){
106 int localy = y - s->n->absy;
107 int localx = x - s->n->absx;
108//fprintf(stderr, "INVALIDATING AT %d/%d (%d/%d) TAM: %d\n", y, x, localy, localx, s->n->tam[localy * s->dimx + localx].state);
109 if(s->n->tam[localy * s->dimx + localx].state != SPRIXCELL_TRANSPARENT &&
110 s->n->tam[localy * s->dimx + localx].state != SPRIXCELL_ANNIHILATED &&
111 s->n->tam[localy * s->dimx + localx].state != SPRIXCELL_ANNIHILATED_TRANS){
113 }
114 }
115}
@ SPRIXEL_QUIESCENT
Definition sprite.h:21
@ SPRIXEL_INVALIDATED
Definition sprite.h:24
Here is the caller graph for this function:

◆ sprixel_movefrom()

void sprixel_movefrom ( sprixel s,
int  y,
int  x 
)

Definition at line 68 of file sprite.c.

68 {
70 if(s->invalidated != SPRIXEL_MOVED){
71 // FIXME if we're Sixel, we need to effect any wipes that were run
72 // (we normally don't because redisplaying sixel doesn't change
73 // what's there--you can't "write transparency"). this is probably
74 // best done by conditionally reblitting the sixel(?).
75//fprintf(stderr, "SETTING TO MOVE: %d/%d was: %d\n", y, x, s->invalidated);
77 s->movedfromy = y;
78 s->movedfromx = x;
79 }
80 }
81}
@ SPRIXEL_UNSEEN
Definition sprite.h:22
@ SPRIXEL_MOVED
Definition sprite.h:26
Here is the caller graph for this function:

◆ sprixel_recycle()

sprixel * sprixel_recycle ( ncplane n)

Definition at line 51 of file sprite.c.

51 {
52 assert(n->sprite);
55 sprixel* hides = n->sprite;
56 int dimy = hides->dimy;
57 int dimx = hides->dimx;
58 sprixel_hide(hides);
59 return sprixel_alloc(n, dimy, dimx);
60 }
61 sixelmap_free(n->sprite->smap);
62 n->sprite->smap = NULL;
63 return n->sprite;
64}
const notcurses * ncplane_notcurses_const(const ncplane *n)
Definition notcurses.c:2635
@ NCPIXEL_KITTY_STATIC
Definition notcurses.h:1680
void sprixel_hide(sprixel *s)
Definition sprite.c:83
sprixel * sprixel_alloc(ncplane *n, int dimy, int dimx)
Definition sprite.c:117
ncpixelimpl_e pixel_implementation
Definition termdesc.h:134
Here is the call graph for this function:
Here is the caller graph for this function:

◆ summarize_stats()

void summarize_stats ( notcurses nc)

Definition at line 166 of file stats.c.

166 {
167 const ncstats *stats = &nc->stashed_stats;
168 char totalbuf[NCBPREFIXSTRLEN + 1];
169 char minbuf[NCBPREFIXSTRLEN + 1];
170 char maxbuf[NCBPREFIXSTRLEN + 1];
171 char avgbuf[NCBPREFIXSTRLEN + 1];
172 if(stats->renders){
173 ncqprefix(stats->render_ns, NANOSECS_IN_SEC, totalbuf, 0);
174 ncqprefix(stats->render_min_ns, NANOSECS_IN_SEC, minbuf, 0);
175 ncqprefix(stats->render_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
176 ncqprefix(stats->render_ns / stats->renders, NANOSECS_IN_SEC, avgbuf, 0);
177 fprintf(stderr, "%"PRIu64" render%s, %ss (%ss min, %ss avg, %ss max)" NL,
178 stats->renders, stats->renders == 1 ? "" : "s",
179 totalbuf, minbuf, avgbuf, maxbuf);
180 }
181 if(stats->writeouts || stats->failed_writeouts){
182 ncqprefix(stats->raster_ns, NANOSECS_IN_SEC, totalbuf, 0);
183 ncqprefix(stats->raster_min_ns, NANOSECS_IN_SEC, minbuf, 0);
184 ncqprefix(stats->raster_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
185 ncqprefix(stats->raster_ns / (stats->writeouts + stats->failed_writeouts),
186 NANOSECS_IN_SEC, avgbuf, 0);
187 fprintf(stderr, "%"PRIu64" raster%s, %ss (%ss min, %ss avg, %ss max)" NL,
188 stats->writeouts, stats->writeouts == 1 ? "" : "s",
189 totalbuf, minbuf, avgbuf, maxbuf);
190 ncqprefix(stats->writeout_ns, NANOSECS_IN_SEC, totalbuf, 0);
191 ncqprefix(stats->writeout_ns ? stats->writeout_min_ns : 0,
192 NANOSECS_IN_SEC, minbuf, 0);
193 ncqprefix(stats->writeout_max_ns, NANOSECS_IN_SEC, maxbuf, 0);
194 ncqprefix(stats->writeouts ? stats->writeout_ns / stats->writeouts : 0,
195 NANOSECS_IN_SEC, avgbuf, 0);
196 fprintf(stderr, "%"PRIu64" write%s, %ss (%ss min, %ss avg, %ss max)" NL,
197 stats->writeouts, stats->writeouts == 1 ? "" : "s",
198 totalbuf, minbuf, avgbuf, maxbuf);
199 }
200 if(stats->renders || stats->input_events){
201 ncbprefix(stats->raster_bytes, 1, totalbuf, 1),
202 ncbprefix(stats->raster_bytes ? stats->raster_min_bytes : 0,
203 1, minbuf, 1),
204 ncbprefix(stats->renders ? stats->raster_bytes / stats->renders : 0, 1, avgbuf, 1);
205 ncbprefix(stats->raster_max_bytes, 1, maxbuf, 1),
206 fprintf(stderr, "%sB (%sB min, %sB avg, %sB max) %"PRIu64" input%s Ghpa: %"PRIu64 NL,
207 totalbuf, minbuf, avgbuf, maxbuf,
208 stats->input_events,
209 stats->input_events == 1 ? "" : "s",
210 stats->hpa_gratuitous);
211 }
212 fprintf(stderr, "%"PRIu64" failed render%s, %"PRIu64" failed raster%s, %"
213 PRIu64" refresh%s, %"PRIu64" input error%s" NL,
214 stats->failed_renders, stats->failed_renders == 1 ? "" : "s",
215 stats->failed_writeouts, stats->failed_writeouts == 1 ? "" : "s",
216 stats->refreshes, stats->refreshes == 1 ? "" : "es",
217 stats->input_errors, stats->input_errors == 1 ? "" : "s");
218 fprintf(stderr, "RGB emits:elides: def %"PRIu64":%"PRIu64" fg %"PRIu64":%"
219 PRIu64" bg %"PRIu64":%"PRIu64 NL,
220 stats->defaultemissions,
221 stats->defaultelisions,
222 stats->fgemissions,
223 stats->fgelisions,
224 stats->bgemissions,
225 stats->bgelisions);
226 fprintf(stderr, "Cell emits:elides: %"PRIu64":%"PRIu64" (%.2f%%) %.2f%% %.2f%% %.2f%%" NL,
227 stats->cellemissions, stats->cellelisions,
228 (stats->cellemissions + stats->cellelisions) == 0 ? 0 :
229 (stats->cellelisions * 100.0) / (stats->cellemissions + stats->cellelisions),
230 (stats->defaultemissions + stats->defaultelisions) == 0 ? 0 :
231 (stats->defaultelisions * 100.0) / (stats->defaultemissions + stats->defaultelisions),
232 (stats->fgemissions + stats->fgelisions) == 0 ? 0 :
233 (stats->fgelisions * 100.0) / (stats->fgemissions + stats->fgelisions),
234 (stats->bgemissions + stats->bgelisions) == 0 ? 0 :
235 (stats->bgelisions * 100.0) / (stats->bgemissions + stats->bgelisions));
236 ncbprefix(stats->sprixelbytes, 1, totalbuf, 1);
237 fprintf(stderr, "Bmap emits:elides: %"PRIu64":%"PRIu64" (%.2f%%) %sB (%.2f%%) SuM: %"PRIu64" (%.2f%%)" NL,
238 stats->sprixelemissions, stats->sprixelelisions,
239 (stats->sprixelemissions + stats->sprixelelisions) == 0 ? 0 :
240 (stats->sprixelelisions * 100.0) / (stats->sprixelemissions + stats->sprixelelisions),
241 totalbuf,
242 stats->raster_bytes ? (stats->sprixelbytes * 100.0) / stats->raster_bytes : 0,
243 stats->appsync_updates,
244 stats->writeouts ? stats->appsync_updates * 100.0 / stats->writeouts : 0);
245 if(stats->cell_geo_changes || stats->pixel_geo_changes){
246 fprintf(stderr,"Screen/cell geometry changes: %"PRIu64"/%"PRIu64 NL,
247 stats->cell_geo_changes, stats->pixel_geo_changes);
248 }
249}
#define NCBPREFIXSTRLEN
Definition notcurses.h:3834
uint64_t failed_writeouts
Definition notcurses.h:1786
uint64_t raster_ns
Definition notcurses.h:1793
uint64_t cellemissions
Definition notcurses.h:1800
uint64_t failed_renders
Definition notcurses.h:1785
uint64_t defaultelisions
Definition notcurses.h:1805
uint64_t cell_geo_changes
Definition notcurses.h:1815
uint64_t cellelisions
Definition notcurses.h:1799
uint64_t bgemissions
Definition notcurses.h:1804
uint64_t fgemissions
Definition notcurses.h:1802
uint64_t defaultemissions
Definition notcurses.h:1806
uint64_t sprixelemissions
Definition notcurses.h:1808
uint64_t writeout_ns
Definition notcurses.h:1796
uint64_t sprixelelisions
Definition notcurses.h:1809
uint64_t render_ns
Definition notcurses.h:1790
uint64_t renders
Definition notcurses.h:1783
uint64_t raster_bytes
Definition notcurses.h:1787
uint64_t pixel_geo_changes
Definition notcurses.h:1816
int64_t raster_max_bytes
Definition notcurses.h:1788
uint64_t fgelisions
Definition notcurses.h:1801
int64_t render_max_ns
Definition notcurses.h:1791
uint64_t input_events
Definition notcurses.h:1813
uint64_t bgelisions
Definition notcurses.h:1803
uint64_t sprixelbytes
Definition notcurses.h:1810
int64_t writeout_max_ns
Definition notcurses.h:1797
uint64_t writeouts
Definition notcurses.h:1784
int64_t raster_max_ns
Definition notcurses.h:1794
ncstats stashed_stats
Definition internal.h:357
Here is the caller graph for this function:

◆ term_fg_rgb8()

int term_fg_rgb8 ( const tinfo ti,
fbuf f,
unsigned  r,
unsigned  g,
unsigned  b 
)

Definition at line 743 of file render.c.

743 {
744 // We typically want to use tputs() and tiperm() to acquire and write the
745 // escapes, as these take into account terminal-specific delays, padding,
746 // etc. For the case of DirectColor, there is no suitable terminfo entry, but
747 // we're also in that case working with hopefully more robust terminals.
748 // If it doesn't work, eh, it doesn't work. Fuck the world; save yourself.
749 if(ti->caps.rgb){
750 return term_esc_rgb(f, true, r, g, b);
751 }else{
752 const char* setaf = get_escape(ti, ESCAPE_SETAF);
753 if(setaf){
754 // For 256-color indexed mode, start constructing a palette based off
755 // the inputs *if we can change the palette*. If more than 256 are used on
756 // a single screen, start... combining close ones? For 8-color mode, simple
757 // interpolation. I have no idea what to do for 88 colors. FIXME
758 if(ti->caps.colors >= 256){
759 return fbuf_emit(f, tiparm(setaf, rgb_quantize_256(r, g, b)));
760 }else if(ti->caps.colors >= 8){
761 return fbuf_emit(f, tiparm(setaf, rgb_quantize_8(r, g, b)));
762 }
763 }
764 }
765 return 0;
766}
unsigned colors
Definition notcurses.h:1637
@ ESCAPE_SETAF
Definition termdesc.h:48
Here is the caller graph for this function:

◆ update_raster_bytes()

void update_raster_bytes ( ncstats stats,
int  bytes 
)

Definition at line 27 of file stats.c.

27 {
28 if(bytes >= 0){
29 stats->raster_bytes += bytes;
30 if(bytes > stats->raster_max_bytes){
31 stats->raster_max_bytes = bytes;
32 }
33 if(bytes < stats->raster_min_bytes){
34 stats->raster_min_bytes = bytes;
35 }
36 }
37}
Here is the caller graph for this function:

◆ update_raster_stats()

void update_raster_stats ( const struct timespec *  time1,
const struct timespec *  time0,
ncstats stats 
)

Definition at line 58 of file stats.c.

59 {
60 const int64_t elapsed = timespec_to_ns(time1) - timespec_to_ns(time0);
61 //fprintf(stderr, "Rasterizing took %ld.%03lds\n", elapsed / NANOSECS_IN_SEC,
62 // (elapsed % NANOSECS_IN_SEC) / 1000000);
63 if(elapsed > 0){ // don't count clearly incorrect information, egads
64 stats->raster_ns += elapsed;
65 if(elapsed > stats->raster_max_ns){
66 stats->raster_max_ns = elapsed;
67 }
68 if(elapsed < stats->raster_min_ns){
69 stats->raster_min_ns = elapsed;
70 }
71 }
72}
Here is the caller graph for this function:

◆ update_render_stats()

void update_render_stats ( const struct timespec *  time1,
const struct timespec *  time0,
ncstats stats 
)

Definition at line 40 of file stats.c.

41 {
42 const int64_t elapsed = timespec_to_ns(time1) - timespec_to_ns(time0);
43 //fprintf(stderr, "Rendering took %ld.%03lds\n", elapsed / NANOSECS_IN_SEC,
44 // (elapsed % NANOSECS_IN_SEC) / 1000000);
45 if(elapsed > 0){ // don't count clearly incorrect information, egads
46 ++stats->renders;
47 stats->render_ns += elapsed;
48 if(elapsed > stats->render_max_ns){
49 stats->render_max_ns = elapsed;
50 }
51 if(elapsed < stats->render_min_ns){
52 stats->render_min_ns = elapsed;
53 }
54 }
55}
Here is the caller graph for this function:

◆ update_term_dimensions()

int update_term_dimensions ( unsigned *  rows,
unsigned *  cols,
tinfo tcache,
int  margin_b,
unsigned *  cgeo_changed,
unsigned *  pgeo_changed 
)
Here is the caller graph for this function:

◆ update_write_stats()

void update_write_stats ( const struct timespec *  time1,
const struct timespec *  time0,
ncstats stats,
int  bytes 
)

Definition at line 5 of file stats.c.

6 {
7 if(bytes >= 0){
8 const int64_t elapsed = timespec_to_ns(time1) - timespec_to_ns(time0);
9 if(elapsed > 0){ // don't count clearly incorrect information, egads
10 ++stats->writeouts;
11 stats->writeout_ns += elapsed;
12 if(elapsed > stats->writeout_max_ns){
13 stats->writeout_max_ns = elapsed;
14 }
15 if(elapsed < stats->writeout_min_ns){
16 stats->writeout_min_ns = elapsed;
17 }
18 }
19 }else{
20 ++stats->failed_writeouts;
21 }
22}
Here is the caller graph for this function:

◆ warn_terminfo()

void warn_terminfo ( const notcurses nc,
const tinfo ti 
)

Variable Documentation

◆ visual_implementation

API ncvisual_implementation* visual_implementation
extern

Definition at line 20 of file visual.c.