17#include "compat/compat.h"
25 *major = NOTCURSES_VERNUM_MAJOR;
26 *minor = NOTCURSES_VERNUM_MINOR;
27 *patch = NOTCURSES_VERNUM_PATCH;
28 *tweak = atoi(NOTCURSES_VERSION_TWEAK);
63 if((esc = get_escape(ti,
ESCAPE_OP)) && fbuf_emit(f, esc)){
66 if((esc = get_escape(ti,
ESCAPE_SGR0)) && fbuf_emit(f, esc)){
82 loginfo(
"restoring palette via xtpopcolors");
83 if(fbuf_emit(f, esc)){
101 if(fbuf_emit(f, tiparm(esc, z,
r, g, b)) < 0){
105 }
else if((esc = get_escape(ti,
ESCAPE_OC))){
107 if(fbuf_emit(f, esc)){
111 logwarn(
"no method known to restore palette");
121notcurses_stop_minimal(
void* vnc,
void** altstack){
138 if(cnorm && fbuf_emit(f, cnorm)){
141 if(fbuf_flush(f, nc->
ttyfp)){
145 ret |= notcurses_mice_disable(nc);
173 logdebug(
"restored terminal, returning %d", ret);
177static const char NOTCURSES_VERSION[] =
178 NOTCURSES_VERSION_MAJOR
"."
179 NOTCURSES_VERSION_MINOR
"."
180 NOTCURSES_VERSION_PATCH;
183 return NOTCURSES_VERSION;
187 void* ret =
n->userptr;
204 if(
n->y >=
n->leny ||
n->x >=
n->lenx){
229 if((
unsigned)
y >=
n->leny || (
unsigned)
x >=
n->lenx){
240 return strdup(
n->sprite->glyph.buf);
242 const nccell* yx = &
n->fb[nfbcellidx(
n,
y,
x)];
244 if(nccell_wide_right_p(yx)){
247 char* ret = nccell_extract(
n, yx, stylemask, channels);
252 if(strcmp(ret,
"") == 0){
254 ret = nccell_strdup(
n, &
n->basecell);
259 *stylemask =
n->basecell.stylemask;
272 logerror(
"invoked on a sprixel plane");
289 if((
unsigned)
y >=
n->leny || (
unsigned)
x >=
n->lenx){
293 nccell* targ = ncplane_cell_ref_yx(
n,
y,
x);
317 int margin_b,
unsigned* cgeo_changed,
unsigned* pgeo_changed){
321 if(tcache->
ttyfd < 0){
332 unsigned rowsafe, colsafe;
335 rowsafe = tcache->
dimy;
339 colsafe = tcache->
dimx;
351 if(tcache->linux_fb_fd >= 0){
353 cpixy = tcache->
pixy / *rows;
354 cpixx = tcache->
pixx / *cols;
363 tcache->
pixy = ws.ws_ypixel;
364 tcache->
pixx = ws.ws_xpixel;
368 cpixy = ws.ws_row ? tcache->
pixy / ws.ws_row : 0;
369 cpixx = ws.ws_col ? tcache->
pixx / ws.ws_col : 0;
383 CONSOLE_SCREEN_BUFFER_INFO csbi;
411 if(GetConsoleScreenBufferInfo(tcache->outhandle, &csbi)){
412 *cols = csbi.dwSize.X;
413 *rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
419 if(tcache->
dimy != *rows){
420 tcache->
dimy = *rows;
423 if(tcache->
dimx != *cols){
424 tcache->
dimx = *cols;
428 int sixelrows = *rows - 1;
445 while(
n->sprixelcache){
448 n->sprixelcache = tmp;
454ncpile_destroy(
ncpile* pile){
475 ncpile_destroy(ncplane_pile(p));
476 pthread_mutex_unlock(&nc->
pilelock);
484 logdebug(
"calling widget destructor %p(%p)", wdestruct, w);
492 egcpool_dump(&p->
pool);
504 ncpile* ret = malloc(
sizeof(*ret));
515 ncplane_pile(nc->
stdplane)->prev = ret;
536static inline size_t ncplane_sizeof_cellarray(
size_t rows,
size_t cols)
540 if( ! rows || (cols > SIZE_MAX / rows))
560 logwarn(
"provided unsupported flags %016" PRIx64, nopts->
flags);
564 logerror(
"alignment requires a parent plane");
569 if(nopts->
rows != 0 || nopts->
cols != 0){
570 logerror(
"geometry specified with margins (r=%u, c=%u)",
575 ncplane* p = malloc(
sizeof(*p));
588 p->
leny = ncplane_dim_y(
n);
589 p->
lenx = ncplane_dim_x(
n);
591 notcurses_term_dim_yx(nc, &p->
leny, &p->
lenx);
604 size_t fbsize = ncplane_sizeof_cellarray(p->
leny, p->
lenx);
605 if(!fbsize || (p->
fb = calloc(fbsize,
sizeof(
struct nccell))) ==
NULL){
606 logerror(
"error allocating cellmatrix (r=%u, c=%u)",
627 p->
absx = ncplane_halign(
n, nopts->
x, nopts->
cols);
634 p->
absy = ncplane_valign(
n, nopts->
y, nopts->
rows);
641 n->blist->bprev = &p->
bnext;
651 egcpool_init(&p->
pool);
661 if( (p->
pile = pile) ){
676 pthread_mutex_unlock(&nc->
pilelock);
678 loginfo(
"created new %ux%u plane \"%s\" @ %dx%d",
686create_initial_ncplane(
notcurses* nc,
int dimy,
int dimx){
726 }
else if((
unsigned)
x >=
n->lenx){
727 logerror(
"target x %d >= width %u",
x,
n->lenx);
737 }
else if((
unsigned)
y >=
n->leny){
738 logerror(
"target y %d >= height %u",
y,
n->leny);
743 if(cursor_invalid_p(
n)){
744 logerror(
"invalid cursor following move (%d/%d)",
n->y,
n->x);
751 if((
int)
n->y +
y == -1){
754 }
else if((
int)
n->x +
x == -1){
763 const int placey =
n->absy;
764 const int placex =
n->absx;
780 size_t fbsize =
sizeof(*
n->fb) * dimx * dimy;
781 if(egcpool_dup(&
newn->pool, &
n->pool)){
785 memmove(
newn->fb,
n->fb, fbsize);
790 newn->halign =
n->halign;
794 newn->basecell =
n->basecell;
803 for(
struct ncplane* child =
n->
blist ; child ; child = child->bnext){
805 ret |= child->resizecb(child);
813ncplane_resize_internal_check(
const ncplane*
n,
int keepy,
int keepx,
814 unsigned keepleny,
unsigned keeplenx,
815 int yoff,
int xoff,
unsigned ylen,
unsigned xlen,
817 if(keepy < 0 || keepx < 0){
818 logerror(
"can't retain negative offset %dx%d", keepy, keepx);
821 if((!keepleny && keeplenx) || (keepleny && !keeplenx)){
822 logerror(
"can't retain null dimension %ux%u", keepleny, keeplenx);
827 logerror(
"can't map in y dimension: %u < %u",
ylen, keepleny);
831 logerror(
"can't map in x dimension: %u < %u",
xlen, keeplenx);
839 if(keepleny + keepy > *
rows){
840 logerror(
"can't keep %u@%d rows from %u", keepleny, keepy, *
rows);
843 if(keeplenx + keepx > *
cols){
844 logerror(
"can't keep %u@%d cols from %u", keeplenx, keepx, *
cols);
847 loginfo(
"%ux%u @ %d/%d → %u/%u @ %d/%d (want %ux%u@%d/%d)", *
rows, *
cols,
848 n->absy,
n->absx,
ylen,
xlen,
n->absy + keepy + yoff,
n->absx + keepx + xoff,
849 keepleny, keeplenx, keepy, keepx);
855 unsigned keepleny,
unsigned keeplenx,
859 if(ncplane_resize_internal_check(
n, keepy, keepx, keepleny, keeplenx,
864 if(
n->absy ==
n->absy + keepy &&
n->absx ==
n->absx + keepx &&
876 int keptarea = keepleny * keeplenx;
878 size_t fbsize =
sizeof(
nccell) * newarea;
896 if(
cols ==
xlen &&
cols == keeplenx && keepleny && !keepy){
901 if(
n->leny > keepleny){
902 for(
unsigned y = keepleny ;
y <
n->leny ; ++
y){
903 for(
unsigned x = 0 ;
x <
n->lenx ; ++
x){
908 if((fb = realloc(
n->fb, fbsize)) ==
NULL){
913 if((fb = malloc(fbsize)) ==
NULL){
918 loginfo(
"tam realloc to %d entries", newarea);
920 tament* tmptam = realloc(
n->tam,
sizeof(*tmptam) * newarea);
928 if(newarea > oldarea){
929 memset(
n->tam + oldarea, 0,
sizeof(*
n->tam) * (newarea - oldarea));
943 const int oldabsy =
n->absy;
947 n->absy += keepy + yoff;
948 n->absx += keepx + xoff;
953 memset(fb, 0,
sizeof(*fb) * newarea);
954 egcpool_dump(&
n->pool);
955 }
else if(!preserved){
959 unsigned tozorch = (
ylen - keepleny) *
xlen *
sizeof(*fb);
961 unsigned zorchoff = keepleny *
xlen;
962 memset(fb + zorchoff, 0, tozorch);
969 for(
unsigned itery = 0 ; itery <
ylen ; ++itery){
970 int truey = itery +
n->absy;
971 int sourceoffy = truey - oldabsy;
974 if(sourceoffy < keepy || sourceoffy >= keepy + (
int)keepleny){
976 memset(fb + (itery *
xlen), 0,
sizeof(*fb) *
xlen);
978 int copyoff = itery *
xlen;
982 memset(fb + copyoff, 0,
sizeof(*fb) * -xoff);
986 const int sourceidx = nfbcellidx(
n, sourceoffy, keepx);
988 memcpy(fb + copyoff, preserved + sourceidx,
sizeof(*fb) * keeplenx);
991 unsigned perline =
xlen - copied;
992 for(
unsigned x = copyoff ;
x <
n->lenx ; ++
x){
995 memset(fb + copyoff, 0,
sizeof(*fb) * perline);
1007 unsigned keepleny,
unsigned keeplenx,
1023 logerror(
"won't destroy standard plane");
1027 loginfo(
"destroying %dx%d plane \"%s\" @ %dx%d",
1036 }
else if(ncp->
bnext){
1057 ncplane_pile(ncp)->top = ncp->
below;
1062 ncplane_pile(ncp)->bottom = ncp->
above;
1073 logerror(
"won't destroy standard plane");
1096 if(setlocale(LC_ALL,
".UTF8") ==
NULL){
1097 logwarn(
"couldn't set LC_ALL to utf8");
1100 const char* encoding = nl_langinfo(CODESET);
1101 if(encoding && encoding_is_utf8(encoding)){
1104 const char* lang = getenv(
"LANG");
1106 if(lang && (!strcmp(lang,
"C") || !strcmp(lang,
"POSIX"))){
1107 loginfo(
"LANG was explicitly set to %s, not changing locale", lang);
1111 if(setlocale(LC_ALL,
"") ==
NULL){
1112 logwarn(
"setting locale based on LANG failed");
1115 encoding = nl_langinfo(CODESET);
1116 if(encoding && encoding_is_utf8(encoding)){
1117 loginfo(
"set locale from LANG; client should call setlocale(2)!");
1120 setlocale(LC_CTYPE,
"C.UTF-8");
1121 encoding = nl_langinfo(CODESET);
1122 if(encoding && encoding_is_utf8(encoding)){
1123 loginfo(
"forced UTF-8 encoding; client should call setlocale(2)!");
1130recursive_lock_init(pthread_mutex_t *lock){
1132#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
1134 pthread_mutexattr_t attr;
1135 if(pthread_mutexattr_init(&attr)){
1139 pthread_mutexattr_destroy(&attr);
1142 if(pthread_mutex_init(lock, &attr)){
1143 pthread_mutexattr_destroy(&attr);
1146 pthread_mutexattr_destroy(&attr);
1149#undef PTHREAD_MUTEX_RECURSIVE_NP
1171 if(fwide(fp, 0) > 0){
1172 fprintf(stderr,
"error: output stream is wide-oriented");
1179 memset(ret, 0,
sizeof(*ret));
1182 fprintf(stderr,
"warning: unknown Notcurses options %016" PRIu64,
opts->
flags);
1202 const char* encoding = nl_langinfo(CODESET);
1203 if(encoding && encoding_is_utf8(encoding)){
1207 if(encoding && (strcmp(encoding,
"ANSI_X3.4-1968") &&
1208 strcmp(encoding,
"US-ASCII") &&
1209 strcmp(encoding,
"ASCII"))){
1210 fprintf(stderr,
"encoding (\"%s\") was neither ANSI_X3.4-1968 nor UTF-8, refusing to start\n did you call setlocale()?\n",
1211 encoding ? encoding :
"none found");
1220 egcpool_init(&ret->
pool);
1222 fprintf(stderr,
"invalid loglevel %d", ret->
loglevel);
1226 if(recursive_lock_init(&ret->
pilelock)){
1227 fprintf(stderr,
"couldn't initialize pile mutex");
1232 pthread_mutex_destroy(&ret->
pilelock);
1254 if(fbuf_init(&ret->
rstate.
f)){
1255 pthread_mutex_destroy(&ret->
pilelock);
1256 pthread_mutex_destroy(&ret->
stats.
lock);
1262 notcurses_stop_minimal)){
1264 pthread_mutex_destroy(&ret->
pilelock);
1265 pthread_mutex_destroy(&ret->
stats.
lock);
1284 cursory, cursorx, &ret->
stats,
1290 pthread_mutex_destroy(&ret->
pilelock);
1291 pthread_mutex_destroy(&ret->
stats.
lock);
1306 if(*cursory < 0 || *cursorx < 0){
1309 logwarn(
"couldn't preserve cursor");
1315 if(*cursory >= 0 && *cursorx >= 0){
1316 if(goto_location(ret, &ret->
rstate.
f, *cursory, *cursorx,
NULL)){
1321 unsigned dimy, dimx, cgeo, pgeo;
1329 if((ret->
stdplane = create_initial_ncplane(ret, dimy, dimx)) ==
NULL){
1330 logpanic(
"couldn't create the initial plane (bad margins?)");
1338 if(cinvis && fbuf_emit(&ret->
rstate.
f, cinvis) < 0){
1343 if(pushcolors && fbuf_emit(&ret->
rstate.
f, pushcolors)){
1354 unsigned uendy, uendx;
1392 logpanic(
"alas, you will not be going to space today.");
1393 notcurses_stop_minimal(ret, &altstack);
1399 del_curterm(cur_term);
1400 pthread_mutex_destroy(&ret->
stats.
lock);
1401 pthread_mutex_destroy(&ret->
pilelock);
1411 bool sawstdplane =
false;
1416 logdebug(
"killing plane %p, next is %p", p, tmp);
1440 ncpile_drop(nc, &p);
1442 pthread_mutex_unlock(&nc->
pilelock);
1452 ret |= notcurses_stop_minimal(nc, &altstack);
1460 fbuf_finalize(&nc->
rstate.
f, stdout);
1469 egcpool_dump(&nc->
pool);
1479 del_curterm(cur_term);
1481 ret |= pthread_mutex_destroy(&nc->
stats.
lock);
1482 ret |= pthread_mutex_destroy(&nc->
pilelock);
1491 return ncchannels_channels(
n->channels);
1495 ncchannels_set_channels(&
n->channels,
channels);
1499 return n->stylemask;
1503 ncchannels_set_fg_default(&
n->channels);
1507 ncchannels_set_bg_default(&
n->channels);
1511 ncchannels_set_bg_rgb8_clipped(&
n->channels,
r, g, b);
1515 return ncchannels_set_bg_rgb8(&
n->channels,
r, g, b);
1519 ncchannels_set_fg_rgb8_clipped(&
n->channels,
r, g, b);
1523 return ncchannels_set_fg_rgb8(&
n->channels,
r, g, b);
1527 return ncchannels_set_fg_rgb(&
n->channels, channel);
1531 return ncchannels_set_bchannel(&
n->channels, channel);
1535 return ncchannels_set_fchannel(&
n->channels, channel);
1539 return ncchannels_set_bg_rgb(&
n->channels, channel);
1543 return ncchannels_set_fg_alpha(&
n->channels, alpha);
1547 return ncchannels_set_bg_alpha(&
n->channels, alpha);
1551 return ncchannels_set_fg_palindex(&
n->channels,
idx);
1555 return ncchannels_set_bg_palindex(&
n->channels,
idx);
1559 if(nccell_wide_right_p(
c)){
1574 if(cell_simple_p(
c)){
1577 return egcpool_extended_gcluster(&
n->pool,
c);
1588 if( (
n->below->above =
n->above) ){
1589 n->above->below =
n->below;
1602 if(p != ncplane_pile(
above)){
1635 if( (
n->above->below =
n->below) ){
1636 n->below->above =
n->above;
1641 if( (
n->below = p->
top) ){
1649 if(p != ncplane_pile(
below)){
1686 if(ncplane_descendant_p(
above,
n)){
1694 const ncplane* topmost = targ;
1698 if(ncplane_descendant_p(
below,
n)){
1720 if(ncplane_descendant_p(
below,
n)){
1728 const ncplane* bottommost = targ;
1732 if(ncplane_descendant_p(
above,
n)){
1761 if(
n->y ==
n->leny - 1){
1764 ncplane_resize_simple(
n,
n->leny + 1,
n->lenx);
1772 ncplane_pile(
n)->scrolls++;
1774 n->logrow = (
n->logrow + 1) %
n->leny;
1775 nccell* row =
n->fb + nfbcellidx(
n,
n->y, 0);
1776 for(
unsigned clearx = 0 ; clearx <
n->lenx ; ++clearx){
1779 memset(row, 0,
sizeof(*row) *
n->lenx);
1782 if(ncplanes_intersect_p(
n,
c)){
1783 ncplane_move_rel(
c, -1, 0);
1794 logerror(
"can't scroll %d on non-scrolling plane",
r);
1814 if(!ncplane_descendant_p(child,
n)){
1815 logerror(
"not a descendant of specified plane");
1823 int chend =
ncplane_abs_y(child) + ncplane_dim_y(child) - 1;
1824 if(chend <= parend){
1827 int r = chend - parend;
1835 int bytes = utf8_egc_len(gcluster, &cols);
1836 return pool_load_direct(&
n->pool,
c, gcluster, bytes, cols);
1845ncplane_put(
ncplane*
n,
int y,
int x,
const char*
egc,
int cols,
1848 logerror(
"can't write [%s] to sprixelated plane",
egc);
1853 if(is_control_egc((
const unsigned char*)
egc, bytes)){
1858 logerror(
"rejecting newline on non-scrolling plane");
1861 }
else if(*
egc !=
'\t'){
1862 logerror(
"rejecting %dB control character", bytes);
1870 bool linesend =
false;
1875 if(
n->x + cols - 1 >=
n->lenx){
1880 if((
unsigned)
x + cols - 1 >=
n->lenx){
1884 bool scrolled =
false;
1889 }
else if(
n->autogrow){
1890 ncplane_resize_simple(
n,
n->leny,
n->lenx + cols);
1892 logerror(
"target x %d [%.*s] > length %d",
n->x, bytes,
egc,
n->lenx);
1908 nccell* targ = ncplane_cell_ref_yx(
n,
n->y,
n->x);
1914 while(nccell_wide_right_p(lmc)){
1915 nccell_obliterate(
n, &
n->fb[nfbcellidx(
n,
n->y,
idx)]);
1916 lmc = ncplane_cell_ref_yx(
n,
n->y, --
idx);
1919 int twidth = nccell_cols(lmc);
1921 twidth -=
n->x -
idx;
1922 while(--twidth > 0){
1923 nccell_obliterate(
n, &
n->fb[nfbcellidx(
n,
n->y,
n->x + twidth)]);
1934 if(
n->x + 1 >=
n->lenx){
1935 if(!
n->scrolling &&
n->autogrow){
1936 ncplane_resize_simple(
n,
n->leny,
n->lenx + (cols ? cols - 1 :
TABSTOP - 1));
1938 targ = ncplane_cell_ref_yx(
n,
n->y,
n->x);
1941 if(cell_load_direct(
n, targ,
" ", bytes, 1) < 0){
1945 if(cell_load_direct(
n, targ,
egc, bytes, cols) < 0){
1953 for(
int i = 1 ; i < cols ; ++i){
1954 nccell* candidate = &
n->fb[nfbcellidx(
n,
n->y,
n->x)];
1955 int off = nccell_cols(candidate);
1958 nccell_obliterate(
n, &
n->fb[nfbcellidx(
n,
n->y,
n->x + off)]);
1965 if(cell_load_direct(
n, candidate,
" ", bytes, 1) < 0){
1981 const int cols = nccell_cols(
c);
1985 char*
egc = nccell_strdup(
n,
c);
1987 logerror(
"couldn't duplicate cell");
1997 int bytes = utf8_egc_len(gclust, &cols);
2005 return ncplane_put(
n,
y,
x, gclust, cols,
n->stylemask,
n->channels, bytes);
2011 const nccell* targ = &
n->fb[nfbcellidx(
n,
n->y,
n->x)];
2014 int ret = ncplane_putchar(
n,
c);
2023 const nccell* targ = &
n->fb[nfbcellidx(
n,
n->y,
n->x)];
2026 int ret = ncplane_putwegc(
n, gclust, sbytes);
2035 const nccell* targ = &
n->fb[nfbcellidx(
n,
n->y,
n->x)];
2038 int ret = ncplane_putegc(
n, gclust, sbytes);
2045 if(
n->y >=
n->leny ||
n->x >=
n->lenx){
2048 const nccell* src = &
n->fb[nfbcellidx(
n,
n->y,
n->x)];
2049 memcpy(
c, src,
sizeof(*src));
2050 if(cell_simple_p(
c)){
2059 return term_supported_styles(&nc->
tcache);
2088 const size_t size = BUFSIZ;
2089 char* buf = malloc(size);
2094 va_copy(vacopy, ap);
2095 int ret = vsnprintf(buf, size, format, ap);
2101 if((
size_t)ret >= size){
2102 char* tmp = realloc(buf, ret + 1);
2109 vsprintf(buf, format, vacopy);
2120 int ret = ncplane_putstr_yx(
n,
y,
x,
r);
2126 const char* format, va_list ap){
2131 int ret = ncplane_putstr_aligned(
n,
y, align,
r);
2141 int ret = ncplane_putstr_stained(
n,
r);
2147 char* chopped = strndup(str, s);
2148 int ret = ncplane_putstr_aligned(
n,
y, align, chopped);
2154 uint64_t c1, uint64_t c2){
2159 unsigned ur, ug, ub;
2160 int r1, g1, b1, r2, g2, b2;
2161 int br1, bg1, bb1, br2, bg2, bb2;
2162 ncchannels_fg_rgb8(c1, &
ur, &ug, &ub);
2163 r1 =
ur; g1 = ug; b1 = ub;
2164 ncchannels_fg_rgb8(c2, &
ur, &ug, &ub);
2165 r2 =
ur; g2 = ug; b2 = ub;
2166 ncchannels_bg_rgb8(c1, &
ur, &ug, &ub);
2167 br1 =
ur; bg1 = ug; bb1 = ub;
2168 ncchannels_bg_rgb8(c2, &
ur, &ug, &ub);
2169 br2 =
ur; bg2 = ug; bb2 = ub;
2170 int deltr = r2 - r1;
2171 int deltg = g2 - g1;
2172 int deltb = b2 - b1;
2173 int deltbr = br2 - br1;
2174 int deltbg = bg2 - bg1;
2175 int deltbb = bb2 - bb1;
2181 bool fgdef =
false, bgdef =
false;
2182 if(ncchannels_fg_default_p(c1) && ncchannels_fg_default_p(c2)){
2185 if(ncchannels_bg_default_p(c1) && ncchannels_bg_default_p(c2)){
2188 for(ret = 0 ; ret <
len ; ++ret){
2189 int r = (deltr * (int)ret) / (int)
len + r1;
2190 int g = (deltg * (int)ret) / (int)
len + g1;
2191 int b = (deltb * (int)ret) / (int)
len + b1;
2192 int br = (deltbr * (int)ret) / (int)
len + br1;
2193 int bg = (deltbg * (int)ret) / (int)
len + bg1;
2194 int bb = (deltbb * (int)ret) / (int)
len + bb1;
2196 nccell_set_fg_rgb8(&dupc,
r, g, b);
2199 nccell_set_bg_rgb8(&dupc, br, bg, bb);
2201 if(ncplane_putc(
n, &dupc) <= 0){
2210 uint64_t c1, uint64_t c2){
2215 unsigned ur, ug, ub;
2216 int r1, g1, b1, r2, g2, b2;
2217 int br1, bg1, bb1, br2, bg2, bb2;
2218 ncchannels_fg_rgb8(c1, &
ur, &ug, &ub);
2219 r1 =
ur; g1 = ug; b1 = ub;
2220 ncchannels_fg_rgb8(c2, &
ur, &ug, &ub);
2221 r2 =
ur; g2 = ug; b2 = ub;
2222 ncchannels_bg_rgb8(c1, &
ur, &ug, &ub);
2223 br1 =
ur; bg1 = ug; bb1 = ub;
2224 ncchannels_bg_rgb8(c2, &
ur, &ug, &ub);
2225 br2 =
ur; bg2 = ug; bb2 = ub;
2226 int deltr = (r2 - r1) / ((
int)
len + 1);
2227 int deltg = (g2 - g1) / ((
int)
len + 1);
2228 int deltb = (b2 - b1) / ((
int)
len + 1);
2229 int deltbr = (br2 - br1) / ((
int)
len + 1);
2230 int deltbg = (bg2 - bg1) / ((
int)
len + 1);
2231 int deltbb = (bb2 - bb1) / ((
int)
len + 1);
2232 unsigned ypos, xpos;
2239 bool fgdef =
false, bgdef =
false;
2240 if(ncchannels_fg_default_p(c1) && ncchannels_fg_default_p(c2)){
2243 if(ncchannels_bg_default_p(c1) && ncchannels_bg_default_p(c2)){
2246 for(ret = 0 ; ret <
len ; ++ret){
2257 nccell_set_fg_rgb8(&dupc, r1, g1, b1);
2260 nccell_set_bg_rgb8(&dupc, br1, bg1, bb1);
2262 if(ncplane_putc(
n, &dupc) <= 0){
2273 const nccell* vl,
unsigned ystop,
unsigned xstop,
2275 unsigned yoff, xoff;
2278 if(ystop < yoff + 1){
2279 logerror(
"ystop (%u) insufficient for yoff (%d)", ystop, yoff);
2282 if(xstop < xoff + 1){
2283 logerror(
"xstop (%u) insufficient for xoff (%d)", xstop, xoff);
2286 unsigned ymax, xmax;
2289 if(xstop >= xmax || ystop >= ymax){
2290 logerror(
"boundary (%ux%u) beyond plane (%dx%d)", ystop, xstop, ymax, xmax);
2295 if(edges >= box_corner_needs(
ctlword)){
2296 if(ncplane_putc(
n,
ul) < 0){
2301 if(xstop - xoff >= 2){
2306 if(ncplane_hline(
n, hl, xstop - xoff - 1) < 0){
2317 if(edges >= box_corner_needs(
ctlword)){
2321 if(ncplane_putc(
n,
ur) < 0){
2337 if(ncplane_vline(
n, vl, ystop - yoff) < 0){
2351 if(ncplane_vline(
n, vl, ystop - yoff) < 0){
2360 if(edges >= box_corner_needs(
ctlword)){
2364 if(ncplane_putc(
n,
ll) < 0){
2369 if(xstop - xoff >= 2){
2374 if(ncplane_hline(
n, hl, xstop - xoff - 1) < 0){
2385 if(edges >= box_corner_needs(
ctlword)){
2389 if(ncplane_putc(
n,
lr) < 0){
2399move_bound_planes(
ncplane*
n,
int dy,
int dx){
2406 move_bound_planes(
n->blist, dy, dx);
2416 if(
n->boundto ==
n){
2420 dy = (
n->boundto->absy +
y) -
n->absy;
2421 dx = (
n->boundto->absx +
x) -
n->absx;
2429 move_bound_planes(
n->blist, dy, dx);
2435 if(
n->boundto ==
n){
2438 return n->absy -
n->boundto->absy;
2442 if(
n->boundto ==
n){
2445 return n->absx -
n->boundto->absx;
2459 loginfo(
"erasing %dx%d plane",
n->leny,
n->lenx);
2467 char*
egc = nccell_strdup(
n, &
n->basecell);
2468 memset(
n->fb, 0,
sizeof(*
n->fb) *
n->leny *
n->lenx);
2469 egcpool_dump(&
n->pool);
2470 egcpool_init(&
n->pool);
2473 n->basecell.gcluster = 0;
2486 if(ystart < 0 || xstart < 0){
2487 logerror(
"illegal start of erase (%d, %d)", ystart, xstart);
2490 if(ystart >= (
int)ncplane_dim_y(
n) || xstart >= (
int)ncplane_dim_x(
n)){
2491 logerror(
"illegal start of erase (%d, %d)", ystart, xstart);
2495 if(
xlen + 1 < -xstart){
2498 xstart = xstart +
xlen + 1;
2500 }
else if(
xlen == 0){
2502 xlen = ncplane_dim_x(
n);
2504 if(
xlen > (
int)ncplane_dim_x(
n) || xstart +
xlen > (
int)ncplane_dim_x(
n)){
2505 xlen = ncplane_dim_x(
n) - xstart;
2508 if(
ylen + 1 < -ystart){
2511 ystart = ystart +
ylen + 1;
2513 }
else if(
ylen == 0){
2515 ylen = ncplane_dim_y(
n);
2517 if(
ylen > (
int)ncplane_dim_y(
n) || ystart +
ylen > (
int)ncplane_dim_y(
n)){
2518 ylen = ncplane_dim_y(
n) - ystart;
2521 if(ystart == 0 && xstart == 0 &&
2522 ylen == (
int)ncplane_dim_y(
n) &&
xlen == (
int)ncplane_dim_x(
n)){
2530 loginfo(
"erasing %d/%d - %d/%d", ystart, xstart, ystart +
ylen, xstart +
xlen);
2531 for(
int y = ystart ;
y < ystart +
ylen ; ++
y){
2532 for(
int x = xstart ;
x < xstart +
xlen ; ++
x){
2534 nccell_init(&
n->fb[nfbcellidx(
n,
y,
x)]);
2541 return ncplane_pile(
n)->top;
2545 return ncplane_pile(
n)->bottom;
2566 memcpy(p, &nc->
palette,
sizeof(*p));
2573 if(!notcurses_canchangecolor(nc)){
2576 for(
size_t z = 0 ; z <
sizeof(p->
chans) /
sizeof(*p->
chans) ; ++z){
2597 if(yval >=
n->leny){
2606 if(xval >=
n->lenx){
2614 int* restrict
y,
int* restrict
x){
2616 dst = ncplane_stdplane_const(src);
2627 return ncplane_pile(
n)->nc;
2631 return ncplane_pile_const(
n)->nc;
2670 return n->name ? strdup(
n->name) :
NULL;
2682 if(
n->boundto ==
n){
2688 if(
absy + ncplane_dim_y(
n) > ncplane_dim_y(
n->boundto)){
2689 const int dy = (
absy + ncplane_dim_y(
n)) - ncplane_dim_y(
n->boundto);
2691 if(ncplane_move_rel(
n, -dy, 0)){
2696 if(
absx + ncplane_dim_x(
n) > ncplane_dim_x(
n->boundto)){
2697 const int dx = ncplane_dim_x(
n->boundto) - (
absx + ncplane_dim_x(
n));
2699 if(ncplane_move_rel(
n, 0, dx)){
2709 if(ncplane_move_rel(
n, -
absy, 0)){
2716 if(ncplane_move_rel(
n, 0, -
absx)){
2726 unsigned maxy, maxx;
2734 if((maxy -= (
n->margin_b + (
n->absy -
n->boundto->absy))) < 1){
2737 if((maxx -= (
n->margin_r + (
n->absx -
n->boundto->absx))) < 1){
2740 unsigned oldy, oldx;
2742 unsigned keepleny = oldy > maxy ? maxy : oldy;
2743 unsigned keeplenx = oldx > maxx ? maxx : oldx;
2747 int targy = maxy -
n->margin_b;
2748 int targx = maxx -
n->margin_b;
2749 loginfo(
"marg %d/%d, pdim %d/%d, move %d/%d",
n->margin_b,
n->margin_r, maxy, maxx, targy, targx);
2757 unsigned oldy, oldx;
2759 unsigned keepleny = oldy > rows ? rows : oldy;
2760 unsigned keeplenx = oldx > cols ? cols : oldx;
2767 logerror(
"can't realign a root plane");
2771 logerror(
"passed a non-aligned plane");
2776 xpos = ncplane_halign(parent,
n->
halign, ncplane_dim_x(
n));
2780 ypos = ncplane_valign(parent,
n->
valign, ncplane_dim_y(
n));
2794 logerror(
"won't reparent standard plane");
2797 if(
n->boundto == newparent){
2798 loginfo(
"won't reparent plane to itself");
2803 if(
n->boundto ==
n){
2809 child = child->
bnext;
2811 if( (lastlink->
bnext = ncplane_pile(
n)->roots) ){
2815 ncplane_pile(
n)->roots =
n->
blist;
2822 child = child->
bnext;
2839unsplice_zaxis_recursive(
ncplane*
n){
2841 if(ncplane_pile(
n)->top ==
n){
2842 ncplane_pile(
n)->top =
n->below;
2844 n->above->below =
n->below;
2846 if(ncplane_pile(
n)->bottom ==
n){
2847 ncplane_pile(
n)->bottom =
n->above;
2849 n->below->above =
n->above;
2851 for(
ncplane* child =
n->
blist ; child ; child = child->bnext){
2852 unsplice_zaxis_recursive(child);
2854 n->below =
n->above =
NULL;
2867 ncplane_pile(
n)->sprixelcache = s->
next;
2872 if( (s->
prev = prev) ){
2878 for(
ncplane* child =
n->
blist ; child ; child = child->bnext){
2879 unsplice_sprixels_recursive(child, prev);
2880 while(prev && prev->
next){
2890splice_zaxis_recursive(
ncplane*
n,
ncpile* p,
unsigned ocellpxy,
unsigned ocellpxx,
2891 unsigned ncellpxy,
unsigned ncellpxx){
2893 if(
n !=
n->boundto){
2894 if((
n->above =
n->boundto->above) ==
NULL){
2903 if(ocellpxy != ncellpxy || ocellpxx != ncellpxx){
2908 for(
ncplane* child =
n->
blist ; child ; child = child->bnext){
2909 splice_zaxis_recursive(child, p, ocellpxy, ocellpxx, ncellpxy, ncellpxx);
2920 if(
n->boundto == newparent){
2923 if(ncplane_descendant_p(newparent,
n)){
2928 if( (*
n->bprev =
n->bnext) ){
2929 n->bnext->bprev =
n->bprev;
2932 n->bnext->bprev =
NULL;
2938 if(
n == newparent || ncplane_pile(
n) != ncplane_pile(newparent)){
2939 unsplice_zaxis_recursive(
n);
2940 s = unsplice_sprixels_recursive(
n,
NULL);
2942 const unsigned ocellpxy = ncplane_pile(
n)->cellpxy;
2943 const unsigned ocellpxx = ncplane_pile(
n)->cellpxx;
2944 n->boundto = newparent;
2945 if(
n ==
n->boundto){
2946 logdebug(
"reparenting new root plane %p",
n);
2947 unsplice_zaxis_recursive(
n);
2951 if(ncplane_pile(
n)->top ==
NULL){
2952 ncpile_destroy(ncplane_pile(
n));
2955 unsigned ncellpxy = ncplane_pile(
n)->cellpxy;
2956 unsigned ncellpxx = ncplane_pile(
n)->cellpxx;
2957 pthread_mutex_unlock(&nc->
pilelock);
2958 if(ncplane_pile(
n)){
2959 splice_zaxis_recursive(
n, ncplane_pile(
n), ocellpxy, ocellpxx, ncellpxy, ncellpxx);
2962 if( (
n->bnext = newparent->
blist) ){
2963 n->bnext->bprev = &
n->bnext;
2965 n->bprev = &newparent->
blist;
2968 if(ncplane_pile(
n) != ncplane_pile(
n->boundto)){
2969 unsigned ncellpxy = ncplane_pile(
n->boundto)->cellpxy;
2970 unsigned ncellpxx = ncplane_pile(
n->boundto)->cellpxx;
2972 if(ncplane_pile(
n)->top ==
NULL){
2973 ncpile_destroy(ncplane_pile(
n));
2975 n->pile = ncplane_pile(
n->boundto);
2976 pthread_mutex_unlock(&nc->
pilelock);
2977 splice_zaxis_recursive(
n, ncplane_pile(
n), ocellpxy, ocellpxx, ncellpxy, ncellpxx);
2985 if( (lame->
next =
n->pile->sprixelcache) ){
2986 n->pile->sprixelcache->
prev = lame;
2988 n->pile->sprixelcache = s;
2994 bool old =
n->scrolling;
2995 n->scrolling = scrollp;
3000 return n->scrolling;
3005 logerror(
"can't set the standard plane autogrow");
3008 bool old =
n->autogrow;
3009 n->autogrow = growp;
3020lex_ulong(
const char* op,
unsigned* i,
char** endptr){
3022 long l = strtol(op, endptr, 10);
3023 if(l < 0 || (l == LONG_MAX && errno == ERANGE) || (l > INT_MAX)){
3024 fprintf(stderr,
"invalid margin: %s", op);
3027 if((**endptr !=
',' && **endptr) || *endptr == op){
3028 fprintf(stderr,
"invalid margin: %s", op);
3036 if(strcasecmp(op,
"stretch") == 0){
3038 }
else if(strcasecmp(op,
"scalehi") == 0){
3040 }
else if(strcasecmp(op,
"hires") == 0){
3042 }
else if(strcasecmp(op,
"scale") == 0){
3044 }
else if(strcasecmp(op,
"none") == 0){
3069 if(lex_ulong(op, &
opts->margin_t, &eptr)){
3085 if(lex_ulong(op, &
opts->margin_l, &eptr) || *eptr){
3102get_blitter_egc_idx(
const struct blitset* bset,
const char*
egc){
3104 mbstate_t mbs = {0};
3105 size_t sret = mbrtowc(&wc,
egc, strlen(
egc), &mbs);
3106 if(sret == (
size_t)-1 || sret == (
size_t)-2){
3109 wchar_t* wptr = wcsrchr(bset->
egcs, wc);
3115 return wptr - bset->
egcs;
3119is_bg_p(
int idx,
int py,
int px,
int width){
3121 const int bpos = py * width + px;
3122 const unsigned mask = 1u << bpos;
3129static inline uint32_t*
3131 int begy,
int begx,
unsigned leny,
unsigned lenx,
3132 unsigned* pxdimy,
unsigned* pxdimx){
3134 unsigned ystart, xstart;
3135 if(check_geometry_args(nc, begy, begx, &
leny, &
lenx, &ystart, &xstart)){
3139 logerror(
"pixel blitter %d not yet supported", blit);
3143 logerror(
"must specify exact blitter, not NCBLIT_DEFAULT");
3148 logerror(
"blitter %d invalid in current environment",
blit);
3153 *pxdimy = leny * bset->
height;
3156 *pxdimx = lenx * bset->
width;
3158 uint32_t* ret = malloc(
sizeof(*ret) * lenx * bset->
width * leny * bset->
height);
3161 for(
unsigned y = ystart, targy = 0 ;
y < ystart + leny ; ++
y, targy += bset->
height){
3162 for(
unsigned x = xstart, targx = 0 ;
x < xstart + lenx ; ++
x, targx += bset->
width){
3170 int idx = get_blitter_egc_idx(bset,
c);
3176 unsigned fr, fg, fb, br, bg, bb, fa, ba;
3177 ncchannels_fg_rgb8(channels, &fr, &fb, &fg);
3178 fa = ncchannels_fg_alpha(channels);
3179 ncchannels_bg_rgb8(channels, &br, &bb, &bg);
3180 ba = ncchannels_bg_alpha(channels);
3182 for(
unsigned py = 0 ; py < bset->
height ; ++py){
3183 for(
unsigned px = 0 ; px < bset->
width ; ++px){
3184 uint32_t* p = &ret[(targy + py) * (lenx * bset->
width) + (targx + px)];
3185 bool background = is_bg_p(
idx, py, px, bset->
width);
3190 ncpixel_set_a(p, 0xff);
3191 ncpixel_set_r(p, br);
3192 ncpixel_set_g(p, bb);
3193 ncpixel_set_b(p, bg);
3199 ncpixel_set_a(p, 0xff);
3200 ncpixel_set_r(p, fr);
3201 ncpixel_set_g(p, fb);
3202 ncpixel_set_b(p, fg);
3215 int begy,
int begx,
unsigned leny,
3216 unsigned lenx,
unsigned* pxdimy,
unsigned* pxdimx){
3224 return ncplane_as_rgba_internal(nc,
blit, begy, begx, leny, lenx, pxdimy, pxdimx);
3229 unsigned ystart, xstart;
3230 if(check_geometry_args(nc, begy, begx, &leny, &lenx, &ystart, &xstart)){
3234 char* ret = malloc(retlen);
3236 for(
unsigned y = ystart, targy = 0 ;
y < ystart + leny ; ++
y, targy += 2){
3237 for(
unsigned x = xstart, targx = 0 ;
x < xstart + lenx ; ++
x, ++targx){
3248 char* tmp = realloc(ret, retlen + clen);
3254 memcpy(ret + retlen - 1,
c, clen);
3259 ret[retlen - 1] =
'\0';
3269 ncplane_center(
n,
y,
x);
3280 const wchar_t** wset = &gclustarr;
3281 size_t mbytes = wcsrtombs(
NULL, wset, 0, &ps);
3282 if(mbytes == (
size_t)-1){
3283 logerror(
"error converting wide string");
3287 char* mbstr = malloc(mbytes);
3291 size_t s = wcsrtombs(mbstr, wset, mbytes, &ps);
3292 if(s == (
size_t)-1){
3296 int r = ncplane_putstr_stained(
n, mbstr);
3302 unsigned char* resultbuf,
size_t buflen){
3303 if(u32_to_u8(ucs32, ucs32count, resultbuf, &buflen) ==
NULL){
3311 if(validwidth ==
NULL){
3316 if(validbytes ==
NULL){
3317 validbytes = &bytes;
3321 int thesecols, thesebytes;
3322 thesebytes = utf8_egc_len(
egcs, &thesecols);
3327 *validbytes += thesebytes;
3328 *validwidth += thesecols;
3338 const ncpile* p = ncplane_pile_const(
n);
3346 *pxy = p->
cellpxy * ncplane_dim_y(
n);
3349 *pxx = p->
cellpxx * ncplane_dim_x(
n);
3353 *maxbmapy = p->
cellpxy * ncplane_dim_y(
n);
3359 *maxbmapx = p->
cellpxx * ncplane_dim_x(
n);
3375 return &
n->tcache.caps;
int init_banner(const notcurses *nc, fbuf *f)
const struct blitset * lookup_blitset(const tinfo *tcache, ncblitter_e setid, bool may_degrade)
API int API int API int uint64_t uint64_t uint64_t uint64_t lr
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned unsigned unsigned ctlword
API int API int API int uint64_t uint64_t uint64_t ll
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned unsigned xlen
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned ylen
API int API int API int uint64_t ul
API int API int API int uint64_t uint64_t ur
int inputready_fd(const inputctx *ictx)
int putenv_term(const char *termname) __attribute__((nonnull(1)))
void sprixel_movefrom(sprixel *s, int y, int x)
void sprixel_hide(sprixel *s)
int mouse_setup(tinfo *ti, unsigned eventmask)
void reset_stats(ncstats *stats)
int ncvisual_init(int loglevel)
int set_loglevel_from_env(ncloglevel_e *loglevel) __attribute__((nonnull(1)))
void summarize_stats(notcurses *nc)
void sprixel_free(sprixel *s)
void ncmetric_use_utf8(void)
int sprite_clear_all(const tinfo *t, fbuf *f)
int clear_and_home(notcurses *nc, tinfo *ti, fbuf *f)
int get_linux_fb_pixelgeom(tinfo *ti, unsigned *ypix, unsigned *xpix)
#define logerror(fmt,...)
#define logdebug(fmt,...)
#define logpanic(fmt,...)
ncplane * ncpile_top(ncplane *n)
int ncplane_abs_x(const ncplane *n)
int ncplane_putwstr_stained(ncplane *n, const wchar_t *gclustarr)
void ncplane_on_styles(ncplane *n, unsigned stylebits)
void ncplane_set_fg_default(ncplane *n)
void ncpalette_free(ncpalette *p)
const char * notcurses_version(void)
ncplane * ncplane_new_internal(notcurses *nc, ncplane *n, const ncplane_options *nopts)
int ncplane_set_fg_rgb(ncplane *n, unsigned channel)
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
void ncplane_set_fg_rgb8_clipped(ncplane *n, int r, int g, int b)
void ncplane_home(ncplane *n)
int ncplane_x(const ncplane *n)
int ncplane_cursor_move_rel(ncplane *n, int y, int x)
void * ncplane_userptr(ncplane *n)
int ncplane_y(const ncplane *n)
char * ncplane_contents(ncplane *nc, int begy, int begx, unsigned leny, unsigned lenx)
void ncplane_cursor_yx(const ncplane *n, unsigned *y, unsigned *x)
ncplane * notcurses_stdplane(notcurses *nc)
#define PTHREAD_MUTEX_RECURSIVE_NP
int ncplane_erase_region(ncplane *n, int ystart, int xstart, int ylen, int xlen)
ncplane * ncpile_create(notcurses *nc, const struct ncplane_options *nopts)
char * notcurses_detected_terminal(const notcurses *nc)
bool ncplane_autogrow_p(const ncplane *n)
int update_term_dimensions(unsigned *rows, unsigned *cols, tinfo *tcache, int margin_b, unsigned *cgeo_changed, unsigned *pgeo_changed)
int ncplane_scrollup(ncplane *n, int r)
void ncplane_set_channels(ncplane *n, uint64_t channels)
int notcurses_ucs32_to_utf8(const uint32_t *ucs32, unsigned ucs32count, unsigned char *resultbuf, size_t buflen)
void ncplane_abs_yx(const ncplane *n, int *RESTRICT y, int *RESTRICT x)
ncplane * ncplane_dup(const ncplane *n, void *opaque)
void ncplane_set_bg_rgb8_clipped(ncplane *n, int r, int g, int b)
int ncplane_putchar_stained(ncplane *n, char c)
int ncplane_putnstr_aligned(struct ncplane *n, int y, ncalign_e align, size_t s, const char *str)
int ncplane_vprintf_aligned(ncplane *n, int y, ncalign_e align, const char *format, va_list ap)
int ncplane_set_bg_alpha(ncplane *n, int alpha)
void ncplane_set_styles(ncplane *n, unsigned stylebits)
const char * notcurses_str_scalemode(ncscale_e scalemode)
int ncplane_destroy(ncplane *ncp)
int ncplane_resize_marginalized(ncplane *n)
int ncplane_scrollup_child(ncplane *n, const ncplane *child)
void ncplane_pixel_geom(const ncplane *n, unsigned *RESTRICT pxy, unsigned *RESTRICT pxx, unsigned *RESTRICT celldimy, unsigned *RESTRICT celldimx, unsigned *RESTRICT maxbmapy, unsigned *RESTRICT maxbmapx)
void notcurses_version_components(int *major, int *minor, int *patch, int *tweak)
const char * nccell_extended_gcluster(const ncplane *n, const nccell *c)
void ncplane_off_styles(ncplane *n, unsigned stylebits)
void * ncplane_set_userptr(ncplane *n, void *opaque)
char * ncplane_at_yx(const ncplane *n, int y, int x, uint16_t *stylemask, uint64_t *channels)
int ncplane_set_fg_palindex(ncplane *n, unsigned idx)
int ncplane_putegc_stained(ncplane *n, const char *gclust, size_t *sbytes)
int ncplane_abs_y(const ncplane *n)
int ncplane_resize_placewithin(ncplane *n)
uint16_t ncplane_styles(const ncplane *n)
int ncplane_move_family_above(ncplane *restrict n, ncplane *restrict bpoint)
int ncplane_set_fg_alpha(ncplane *n, int alpha)
int ncpalette_use(notcurses *nc, const ncpalette *p)
int ncplane_set_bg_rgb(ncplane *n, unsigned channel)
int ncplane_destroy_family(ncplane *ncp)
const notcurses * ncplane_notcurses_const(const ncplane *n)
const nccapabilities * notcurses_capabilities(const notcurses *n)
ncplane * ncplane_reparent_family(ncplane *n, ncplane *newparent)
uint64_t ncplane_set_fchannel(ncplane *n, uint32_t channel)
int ncplane_move_yx(ncplane *n, int y, int x)
int ncplane_base(ncplane *ncp, nccell *c)
int reset_term_palette(const tinfo *ti, fbuf *f, unsigned touchedpalette)
void free_plane(ncplane *p)
int ncplane_resize_maximize(ncplane *n)
int nccell_load(ncplane *n, nccell *c, const char *gcluster)
int ncdirect_inputready_fd(ncdirect *n)
int ncplane_putwegc_stained(ncplane *n, const wchar_t *gclust, size_t *sbytes)
int notcurses_inputready_fd(notcurses *n)
void ncplane_translate(const ncplane *src, const ncplane *dst, int *restrict y, int *restrict x)
int ncplane_putegc_yx(ncplane *n, int y, int x, const char *gclust, size_t *sbytes)
int ncplane_set_base(ncplane *ncp, const char *egc, uint16_t stylemask, uint64_t channels)
int ncplane_set_bg_rgb8(ncplane *n, unsigned r, unsigned g, unsigned b)
int ncplane_move_family_below(ncplane *restrict n, ncplane *restrict bpoint)
int notcurses_mice_enable(notcurses *n, unsigned eventmask)
int ncplane_resize_internal(ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
const ncplane * notcurses_stdplane_const(const notcurses *nc)
uint64_t ncplane_set_bchannel(ncplane *n, uint32_t channel)
int ncplane_vprintf_stained(struct ncplane *n, const char *format, va_list ap)
const ncplane * ncplane_parent_const(const ncplane *n)
int ncplane_vprintf_yx(ncplane *n, int y, int x, const char *format, va_list ap)
ncplane * ncplane_above(ncplane *n)
int(*)(ncplane *) ncplane_resizecb(const ncplane *n)
notcurses * notcurses_core_init(const notcurses_options *opts, FILE *outfp)
void ncplane_set_resizecb(ncplane *n, int(*resizecb)(ncplane *))
bool ncplane_set_scrolling(ncplane *n, unsigned scrollp)
ncplane * ncplane_below(ncplane *n)
uint32_t * ncplane_as_rgba(const ncplane *nc, ncblitter_e blit, int begy, int begx, unsigned leny, unsigned lenx, unsigned *pxdimy, unsigned *pxdimx)
bool ncplane_scrolling_p(const ncplane *n)
int notcurses_stop(notcurses *nc)
char * ncplane_at_cursor(const ncplane *n, uint16_t *stylemask, uint64_t *channels)
void ncplane_set_bg_default(ncplane *n)
void ncplane_yx(const ncplane *n, int *y, int *x)
int ncplane_set_bg_palindex(ncplane *n, unsigned idx)
void scroll_down(ncplane *n)
int ncplane_hline_interp(ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2)
ncplane * ncplane_reparent(ncplane *n, ncplane *newparent)
int ncplane_set_name(ncplane *n, const char *name)
ncpixelimpl_e notcurses_check_pixel_support(const notcurses *nc)
int ncplane_at_cursor_cell(ncplane *n, nccell *c)
int notcurses_lex_scalemode(const char *op, ncscale_e *scalemode)
int ncplane_cursor_at(const ncplane *n, nccell *c, char **gclust)
int resize_callbacks_children(ncplane *n)
int ncplane_resize_realign(ncplane *n)
int reset_term_attributes(const tinfo *ti, fbuf *f)
char * ncplane_vprintf_prep(const char *format, va_list ap)
unsigned notcurses_palette_size(const notcurses *nc)
int notcurses_leave_alternate_screen(notcurses *nc)
ncplane * ncpile_bottom(ncplane *n)
int ncplane_move_below(ncplane *restrict n, ncplane *restrict below)
int ncplane_at_yx_cell(ncplane *n, int y, int x, nccell *c)
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
int ncplane_set_fg_rgb8(ncplane *n, unsigned r, unsigned g, unsigned b)
int ncplane_resize(ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
bool ncplane_translate_abs(const ncplane *n, int *restrict y, int *restrict x)
int ncplane_vline_interp(ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2)
uint64_t ncplane_channels(const ncplane *n)
notcurses * ncplane_notcurses(const ncplane *n)
ncplane * ncplane_create(ncplane *n, const ncplane_options *nopts)
const void * ncplane_userptr_const(const ncplane *n)
bool ncplane_set_autogrow(ncplane *n, unsigned growp)
void ncplane_erase(ncplane *n)
char * ncplane_name(const ncplane *n)
ncplane * ncplane_parent(ncplane *n)
uint16_t notcurses_supported_styles(const notcurses *nc)
int ncplane_move_above(ncplane *restrict n, ncplane *restrict above)
int ncplane_box(ncplane *n, const nccell *ul, const nccell *ur, const nccell *ll, const nccell *lr, const nccell *hl, const nccell *vl, unsigned ystop, unsigned xstop, unsigned ctlword)
int notcurses_enter_alternate_screen(notcurses *nc)
void notcurses_drop_planes(notcurses *nc)
int ncplane_putc_yx(ncplane *n, int y, int x, const nccell *c)
int notcurses_lex_margins(const char *op, notcurses_options *opts)
void ncplane_center_abs(const ncplane *n, int *RESTRICT y, int *RESTRICT x)
int ncplane_set_base_cell(ncplane *ncp, const nccell *c)
ncpalette * ncpalette_new(notcurses *nc)
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
#define NCOPTION_SUPPRESS_BANNERS
#define NCOPTION_INHIBIT_SETLOCALE
#define NCPLANE_OPTION_HORALIGNED
#define NCPLANE_OPTION_AUTOGROW
#define NCOPTION_NO_CLEAR_BITMAPS
#define NCPLANE_OPTION_MARGINALIZED
#define NCPLANE_OPTION_VSCROLL
const struct ncplane_options * opts
#define NCOPTION_DRAIN_INPUT
#define NCPLANE_OPTION_VERALIGNED
#define NCOPTION_PRESERVE_CURSOR
#define NCOPTION_SCROLLING
#define NCOPTION_NO_QUIT_SIGHANDLERS
#define NCOPTION_NO_WINCH_SIGHANDLER
#define NCCELL_TRIVIAL_INITIALIZER
#define NCPLANE_OPTION_FIXED
#define NCOPTION_NO_ALTERNATE_SCREEN
API int API int const nccell unsigned len
#define NCOPTION_NO_FONT_CHANGES
void nccell_release(ncplane *n, nccell *c)
int nccell_duplicate(ncplane *n, nccell *targ, const nccell *c)
int sprixel_rescale(sprixel *spx, unsigned ncellpxy, unsigned ncellpxx)
void notcurses_stats_reset(notcurses *nc, ncstats *stats)
uint32_t chans[NCPALETTESIZE]
int(* resizecb)(struct ncplane *)
void(* wdestruct)(void *)
int(* resizecb)(struct ncplane *)
bool palette_damage[NCPALETTESIZE]
ncpixelimpl_e pixel_implementation
ncpalette originalpalette
struct termios * tpreserved
int(* pixel_draw)(const struct tinfo *, const struct ncpile *p, struct sprixel *s, fbuf *f, int y, int x)
unsigned sixel_maxy_pristine
int enter_alternate_screen(int fd, FILE *ttyfp, tinfo *ti, unsigned drain)
int locate_cursor(tinfo *ti, unsigned *cursor_y, unsigned *cursor_x)
void free_terminfo_cache(tinfo *ti)
int interrogate_terminfo(tinfo *ti, FILE *out, unsigned utf8, unsigned noaltscreen, unsigned nocbreak, unsigned nonewfonts, int *cursor_y, int *cursor_x, ncsharedstats *stats, int lmargin, int tmargin, int rmargin, int bmargin, unsigned draininput)
int leave_alternate_screen(int fd, FILE *fp, tinfo *ti, unsigned drain)
char * termdesc_longterm(const tinfo *ti)
int tiocgwinsz(int fd, struct winsize *ws)
int setup_signals(void *vnc, bool no_quit_sigs, bool no_winch_sigs, int(*handler)(void *, void **))
int drop_signals(void *nc, void **altstack)