Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
direct.c File Reference
#include "version.h"
#include "builddef.h"
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include "visual-details.h"
#include "notcurses/direct.h"
#include "internal.h"
#include "unixsig.h"
Include dependency graph for direct.c:

Go to the source code of this file.

Functions

int ncdirect_putstr (ncdirect *nc, uint64_t channels, const char *utf8)
 
int ncdirect_putegc (ncdirect *nc, uint64_t channels, const char *utf8, int *sbytes)
 
int ncdirect_cursor_up (ncdirect *nc, int num)
 
int ncdirect_cursor_left (ncdirect *nc, int num)
 
int ncdirect_cursor_right (ncdirect *nc, int num)
 
int ncdirect_cursor_down (ncdirect *nc, int num)
 
int ncdirect_clear (ncdirect *nc)
 
unsigned ncdirect_dim_x (ncdirect *nc)
 
unsigned ncdirect_dim_y (ncdirect *nc)
 
int ncdirect_cursor_enable (ncdirect *nc)
 
int ncdirect_cursor_disable (ncdirect *nc)
 
int ncdirect_cursor_move_yx (ncdirect *n, int y, int x)
 
int ncdirect_cursor_yx (ncdirect *n, unsigned *y, unsigned *x)
 
int ncdirect_cursor_push (ncdirect *n)
 
int ncdirect_cursor_pop (ncdirect *n)
 
int ncdirect_raster_frame (ncdirect *n, ncdirectv *ncdv, ncalign_e align)
 
ncdirectvncdirect_render_frame (ncdirect *n, const char *file, ncblitter_e blitfxn, ncscale_e scale, int ymax, int xmax)
 
int ncdirect_render_image (ncdirect *n, const char *file, ncalign_e align, ncblitter_e blitfxn, ncscale_e scale)
 
int ncdirect_set_fg_palindex (ncdirect *nc, int pidx)
 
int ncdirect_set_bg_palindex (ncdirect *nc, int pidx)
 
int ncdirect_vprintf_aligned (ncdirect *n, int y, ncalign_e align, const char *fmt, va_list ap)
 
int ncdirect_printf_aligned (ncdirect *n, int y, ncalign_e align, const char *fmt,...)
 
ncdirectncdirect_core_init (const char *termtype, FILE *outfp, uint64_t flags)
 
int ncdirect_stop (ncdirect *nc)
 
char * ncdirect_readline (ncdirect *n, const char *prompt)
 
int ncdirect_on_styles (ncdirect *n, unsigned stylebits)
 
uint16_t ncdirect_styles (const ncdirect *n)
 
int ncdirect_off_styles (ncdirect *n, unsigned stylebits)
 
int ncdirect_set_styles (ncdirect *n, unsigned stylebits)
 
unsigned ncdirect_palette_size (const ncdirect *nc)
 
int ncdirect_set_fg_default (ncdirect *nc)
 
int ncdirect_set_bg_default (ncdirect *nc)
 
int ncdirect_hline_interp (ncdirect *n, const char *egc, unsigned len, uint64_t c1, uint64_t c2)
 
int ncdirect_vline_interp (ncdirect *n, const char *egc, unsigned len, uint64_t c1, uint64_t c2)
 
int ncdirect_box (ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, const wchar_t *wchars, unsigned ylen, unsigned xlen, unsigned ctlword)
 
int ncdirect_rounded_box (ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, unsigned ylen, unsigned xlen, unsigned ctlword)
 
int ncdirect_double_box (ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, unsigned ylen, unsigned xlen, unsigned ctlword)
 
bool ncdirect_canutf8 (const ncdirect *n)
 
int ncdirect_flush (const ncdirect *nc)
 
int ncdirect_check_pixel_support (const ncdirect *n)
 
int ncdirect_stream (ncdirect *n, const char *filename, ncstreamcb streamer, struct ncvisual_options *vopts, void *curry)
 
ncdirectfncdirectf_from_file (ncdirect *n __attribute__((unused)), const char *filename)
 
void ncdirectf_free (ncdirectf *frame)
 
ncdirectvncdirectf_render (ncdirect *n, ncdirectf *frame, const struct ncvisual_options *vopts)
 
int ncdirectf_geom (ncdirect *n, ncdirectf *frame, const struct ncvisual_options *vopts, ncvgeom *geom)
 
uint16_t ncdirect_supported_styles (const ncdirect *nc)
 
char * ncdirect_detected_terminal (const ncdirect *nc)
 
const nccapabilitiesncdirect_capabilities (const ncdirect *n)
 
bool ncdirect_canget_cursor (const ncdirect *n)
 

Function Documentation

◆ ncdirect_box()

int ncdirect_box ( ncdirect n,
uint64_t  ul,
uint64_t  ur,
uint64_t  ll,
uint64_t  lr,
const wchar_t *  wchars,
unsigned  ylen,
unsigned  xlen,
unsigned  ctlword 
)

Definition at line 1395 of file direct.c.

1397 {
1398 if(xlen < 2 || ylen < 2){
1399 return -1;
1400 }
1401 char hl[MB_LEN_MAX + 1];
1402 char vl[MB_LEN_MAX + 1];
1403 unsigned edges;
1404 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_LEFT);
1405 // FIXME rewrite all fprintfs as ncdirect_putstr()!
1406 if(edges >= box_corner_needs(ctlword)){
1407 if(activate_channels(n, ul)){
1408 return -1;
1409 }
1410 if(fprintf(n->ttyfp, "%lc", wchars[0]) < 0){
1411 logerror("error emitting %lc\n", wchars[0]);
1412 return -1;
1413 }
1414 }else{
1416 }
1417 mbstate_t ps = {0};
1418 size_t bytes;
1419 if((bytes = wcrtomb(hl, wchars[4], &ps)) == (size_t)-1){
1420 logerror("error converting %lc\n", wchars[4]);
1421 return -1;
1422 }
1423 hl[bytes] = '\0';
1424 memset(&ps, 0, sizeof(ps));
1425 if((bytes = wcrtomb(vl, wchars[5], &ps)) == (size_t)-1){
1426 logerror("error converting %lc\n", wchars[5]);
1427 return -1;
1428 }
1429 vl[bytes] = '\0';
1430 if(!(ctlword & NCBOXMASK_TOP)){ // draw top border, if called for
1431 if(xlen > 2){
1432 if(ncdirect_hline_interp(n, hl, xlen - 2, ul, ur) < 0){
1433 return -1;
1434 }
1435 }
1436 }else{
1438 }
1439 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_RIGHT);
1440 if(edges >= box_corner_needs(ctlword)){
1441 if(activate_channels(n, ur)){
1442 return -1;
1443 }
1444 if(fprintf(n->ttyfp, "%lc", wchars[1]) < 0){
1445 return -1;
1446 }
1448 }else{
1450 }
1452 // middle rows (vertical lines)
1453 if(ylen > 2){
1454 if(!(ctlword & NCBOXMASK_LEFT)){
1455 if(ncdirect_vline_interp(n, vl, ylen - 2, ul, ll) < 0){
1456 return -1;
1457 }
1460 }else{
1462 }
1463 if(!(ctlword & NCBOXMASK_RIGHT)){
1464 if(ncdirect_vline_interp(n, vl, ylen - 2, ur, lr) < 0){
1465 return -1;
1466 }
1468 }else{
1470 }
1472 }
1473 // bottom line
1474 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_LEFT);
1475 if(edges >= box_corner_needs(ctlword)){
1476 if(activate_channels(n, ll)){
1477 return -1;
1478 }
1479 if(fprintf(n->ttyfp, "%lc", wchars[2]) < 0){
1480 return -1;
1481 }
1482 }else{
1484 }
1485 if(!(ctlword & NCBOXMASK_BOTTOM)){
1486 if(xlen > 2){
1487 if(ncdirect_hline_interp(n, hl, xlen - 2, ll, lr) < 0){
1488 return -1;
1489 }
1490 }
1491 }else{
1493 }
1494 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_RIGHT);
1495 if(edges >= box_corner_needs(ctlword)){
1496 if(activate_channels(n, lr)){
1497 return -1;
1498 }
1499 if(fprintf(n->ttyfp, "%lc", wchars[3]) < 0){
1500 return -1;
1501 }
1502 }
1503 return 0;
1504}
int ncdirect_cursor_right(ncdirect *nc, int num)
Definition direct.c:98
int ncdirect_cursor_down(ncdirect *nc, int num)
Definition direct.c:117
int ncdirect_hline_interp(ncdirect *n, const char *egc, unsigned len, uint64_t c1, uint64_t c2)
Definition direct.c:1272
int ncdirect_cursor_up(ncdirect *nc, int num)
Definition direct.c:68
int ncdirect_cursor_left(ncdirect *nc, int num)
Definition direct.c:83
int ncdirect_vline_interp(ncdirect *n, const char *egc, unsigned len, uint64_t c1, uint64_t c2)
Definition direct.c:1330
API int API int API int uint64_t uint64_t uint64_t uint64_t lr
Definition direct.h:216
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned unsigned unsigned ctlword
Definition direct.h:217
API int API int API int uint64_t uint64_t uint64_t ll
Definition direct.h:216
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
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
#define logerror(fmt,...)
Definition logging.h:32
#define NCBOXMASK_TOP
Definition notcurses.h:2601
#define NCBOXMASK_LEFT
Definition notcurses.h:2604
vopts n
Definition notcurses.h:3502
#define NCBOXMASK_BOTTOM
Definition notcurses.h:2603
#define NCBOXMASK_RIGHT
Definition notcurses.h:2602
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_canget_cursor()

bool ncdirect_canget_cursor ( const ncdirect n)

Definition at line 1627 of file direct.c.

1627 {
1628 if(get_escape(&n->tcache, ESCAPE_U7) == NULL){
1629 return false;
1630 }
1631 if(n->tcache.ttyfd < 0){
1632 return false;
1633 }
1634 return true;
1635}
return NULL
Definition termdesc.h:229
@ ESCAPE_U7
Definition termdesc.h:82

◆ ncdirect_canutf8()

bool ncdirect_canutf8 ( const ncdirect n)

Definition at line 1519 of file direct.c.

1519 {
1520 return n->tcache.caps.utf8;
1521}
Here is the caller graph for this function:

◆ ncdirect_capabilities()

const nccapabilities * ncdirect_capabilities ( const ncdirect n)

Definition at line 1623 of file direct.c.

1623 {
1624 return &n->tcache.caps;
1625}
Here is the caller graph for this function:

◆ ncdirect_check_pixel_support()

int ncdirect_check_pixel_support ( const ncdirect n)

Definition at line 1527 of file direct.c.

1527 {
1528 if(n->tcache.pixel_draw || n->tcache.pixel_draw_late){
1529 return 1;
1530 }
1531 return 0;
1532}
Here is the caller graph for this function:

◆ ncdirect_clear()

int ncdirect_clear ( ncdirect nc)

Definition at line 140 of file direct.c.

140 {
141 const char* clearscr = get_escape(&nc->tcache, ESCAPE_CLEAR);
142 if(clearscr){
143 return term_emit(clearscr, nc->ttyfp, true);
144 }
145 return -1;
146}
tinfo tcache
Definition internal.h:253
FILE * ttyfp
Definition internal.h:252
@ ESCAPE_CLEAR
Definition termdesc.h:80
Here is the caller graph for this function:

◆ ncdirect_core_init()

ncdirect * ncdirect_core_init ( const char *  termtype,
FILE *  outfp,
uint64_t  flags 
)

Definition at line 868 of file direct.c.

868 {
869 if(outfp == NULL){
870 outfp = stdout;
871 }
872 if(flags > (NCDIRECT_OPTION_DRAIN_INPUT << 1)){ // allow them through with warning
873 logwarn("Passed unsupported flags 0x%016" PRIx64 "\n", flags);
874 }
875 if(termtype){
876 if(putenv_term(termtype)){
877 return NULL;
878 }
879 }
880 ncdirect* ret = malloc(sizeof(ncdirect));
881 if(ret == NULL){
882 return ret;
883 }
884 memset(ret, 0, sizeof(*ret));
885 if(pthread_mutex_init(&ret->stats.lock, NULL)){
886 free(ret);
887 return NULL;
888 }
889 ret->flags = flags;
890 ret->ttyfp = outfp;
892 init_lang();
893 }
894 const char* encoding = nl_langinfo(CODESET);
895 bool utf8 = false;
896 if(encoding && encoding_is_utf8(encoding)){
897 utf8 = true;
899 }
901 true, ncdirect_stop_minimal)){
902 pthread_mutex_destroy(&ret->stats.lock);
903 free(ret);
904 return NULL;
905 }
906 // don't set the loglevel until we've locked in signal handling, lest we
907 // change the loglevel out from under a running instance.
910 }else if(flags & NCDIRECT_OPTION_VERBOSE){
912 }else{
914 }
916 int cursor_y = -1;
917 int cursor_x = -1;
918 if(interrogate_terminfo(&ret->tcache, ret->ttyfp, utf8, 1,
920 0, &cursor_y, &cursor_x, &ret->stats, 0, 0, 0, 0,
922 goto err;
923 }
924 if(cursor_y >= 0){
925 // the u7 led the queries so that we would get a cursor position
926 // unaffected by any query spill (unconsumed control sequences). move
927 // us back to that location, in case there was any such spillage.
928 if(ncdirect_cursor_move_yx(ret, cursor_y, cursor_x)){
930 goto err;
931 }
932 }
935 goto err;
936 }
937 unsigned cgeo, pgeo; // both are don't-cares
938 update_term_dimensions(NULL, NULL, &ret->tcache, 0, &cgeo, &pgeo);
939 ncdirect_set_styles(ret, 0);
940 return ret;
941
942err:{
943 void* altstack;
944 if(ret->tcache.ttyfd >= 0){
945 (void)tcsetattr(ret->tcache.ttyfd, TCSANOW, ret->tcache.tpreserved);
946 }
947 drop_signals(ret, &altstack);
948 pthread_mutex_destroy(&ret->stats.lock);
949 free(ret);
950 }
951 return NULL;
952}
ncloglevel_e loglevel
Definition debug.c:3
int ncdirect_set_styles(ncdirect *n, unsigned stylebits)
Definition direct.c:1203
int ncdirect_cursor_move_yx(ncdirect *n, int y, int x)
Definition direct.c:216
#define NCDIRECT_OPTION_INHIBIT_SETLOCALE
Definition direct.h:29
#define NCDIRECT_OPTION_INHIBIT_CBREAK
Definition direct.h:33
#define NCDIRECT_OPTION_DRAIN_INPUT
Definition direct.h:38
#define NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS
Definition direct.h:43
#define NCDIRECT_OPTION_VERBOSE
Definition direct.h:46
#define NCDIRECT_OPTION_VERY_VERBOSE
Definition direct.h:50
free(duplicated)
int update_term_dimensions(unsigned *rows, unsigned *cols, tinfo *tcache, int margin_b, unsigned *cgeo_changed, unsigned *pgeo_changed) __attribute__((nonnull(3
int putenv_term(const char *termname) __attribute__((nonnull(1)))
Definition termdesc.c:1632
int ncvisual_init(int loglevel)
Definition visual.c:23
int set_loglevel_from_env(ncloglevel_e *loglevel) __attribute__((nonnull(1)))
Definition util.c:19
void init_lang(void)
Definition notcurses.c:1094
void ncmetric_use_utf8(void)
Definition metric.c:24
#define logwarn(fmt,...)
Definition logging.h:37
@ NCLOGLEVEL_WARNING
Definition notcurses.h:973
@ NCLOGLEVEL_SILENT
Definition notcurses.h:969
@ NCLOGLEVEL_TRACE
Definition notcurses.h:977
uint64_t flags
Definition internal.h:256
ncsharedstats stats
Definition internal.h:257
pthread_mutex_t lock
Definition internal.h:246
struct termios * tpreserved
Definition termdesc.h:180
int ttyfd
Definition termdesc.h:109
void free_terminfo_cache(tinfo *ti)
Definition termdesc.c:197
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)
Definition termdesc.c:1294
int setup_signals(void *vnc, bool no_quit_sigs, bool no_winch_sigs, int(*handler)(void *, void **))
Definition unixsig.c:188
int drop_signals(void *nc, void **altstack)
Definition unixsig.c:100
Here is the call graph for this function:

◆ ncdirect_cursor_disable()

int ncdirect_cursor_disable ( ncdirect nc)

Definition at line 182 of file direct.c.

182 {
183 const char* cinvis = get_escape(&nc->tcache, ESCAPE_CIVIS);
184 if(cinvis){
185 return term_emit(cinvis, nc->ttyfp, true);
186 }
187 return -1;
188}
@ ESCAPE_CIVIS
Definition termdesc.h:54
Here is the caller graph for this function:

◆ ncdirect_cursor_down()

int ncdirect_cursor_down ( ncdirect nc,
int  num 
)

Definition at line 117 of file direct.c.

117 {
118 if(num < 0){
119 logerror("requested negative move %d\n", num);
120 return -1;
121 }
122 if(num == 0){
123 return 0;
124 }
125 int ret = 0;
126 while(num--){
127 if(ncfputc('\v', nc->ttyfp) == EOF){
128 ret = -1;
129 break;
130 }
131 }
132 return ret;
133}
Here is the caller graph for this function:

◆ ncdirect_cursor_enable()

int ncdirect_cursor_enable ( ncdirect nc)

Definition at line 174 of file direct.c.

174 {
175 const char* cnorm = get_escape(&nc->tcache, ESCAPE_CNORM);
176 if(cnorm){
177 return term_emit(cnorm, nc->ttyfp, true);
178 }
179 return -1;
180}
@ ESCAPE_CNORM
Definition termdesc.h:55
Here is the caller graph for this function:

◆ ncdirect_cursor_left()

int ncdirect_cursor_left ( ncdirect nc,
int  num 
)

Definition at line 83 of file direct.c.

83 {
84 if(num < 0){
85 logerror("requested negative move %d\n", num);
86 return -1;
87 }
88 if(num == 0){
89 return 0;
90 }
91 const char* cub = get_escape(&nc->tcache, ESCAPE_CUB);
92 if(cub){
93 return term_emit(tiparm(cub, num), nc->ttyfp, false);
94 }
95 return -1;
96}
@ ESCAPE_CUB
Definition termdesc.h:60
Here is the caller graph for this function:

◆ ncdirect_cursor_move_yx()

int ncdirect_cursor_move_yx ( ncdirect n,
int  y,
int  x 
)

Definition at line 216 of file direct.c.

216 {
217 const char* hpa = get_escape(&n->tcache, ESCAPE_HPA);
218 const char* vpa = get_escape(&n->tcache, ESCAPE_VPA);
219 const char* u7 = get_escape(&n->tcache, ESCAPE_U7);
220 if(y == -1){ // keep row the same, horizontal move only
221 if(hpa){
222 return term_emit(tiparm(hpa, x), n->ttyfp, false);
223 }else if(n->tcache.ttyfd >= 0 && u7){
224 unsigned yprime;
225 if(cursor_yx_get(n, u7, &yprime, NULL)){
226 return -1;
227 }
228 y = yprime;
229 }else{
230 y = 0;
231 }
232 }else if(x == -1){ // keep column the same, vertical move only
233 if(!vpa){
234 return term_emit(tiparm(vpa, y), n->ttyfp, false);
235 }else if(n->tcache.ttyfd >= 0 && u7){
236 unsigned xprime;
237 if(cursor_yx_get(n, u7, NULL, &xprime)){
238 return -1;
239 }
240 x = xprime;
241 }else{
242 x = 0;
243 }
244 }
245 const char* cup = get_escape(&n->tcache, ESCAPE_CUP);
246 if(cup){
247 return term_emit(tiparm(cup, y, x), n->ttyfp, false);
248 }else if(vpa && hpa){
249 if(term_emit(tiparm(hpa, x), n->ttyfp, false) == 0 &&
250 term_emit(tiparm(vpa, y), n->ttyfp, false) == 0){
251 return 0;
252 }
253 }
254 return -1; // we will not be moving the cursor today
255}
int y
Definition notcurses.h:1905
int int x
Definition notcurses.h:1905
@ ESCAPE_CUP
Definition termdesc.h:45
@ ESCAPE_VPA
Definition termdesc.h:47
@ ESCAPE_HPA
Definition termdesc.h:46
Here is the caller graph for this function:

◆ ncdirect_cursor_pop()

int ncdirect_cursor_pop ( ncdirect n)

Definition at line 403 of file direct.c.

403 {
404 const char* rc = get_escape(&n->tcache, ESCAPE_RC);
405 if(rc){
406 return term_emit(rc, n->ttyfp, false);
407 }
408 return -1;
409}
@ ESCAPE_RC
Definition termdesc.h:79

◆ ncdirect_cursor_push()

int ncdirect_cursor_push ( ncdirect n)

Definition at line 395 of file direct.c.

395 {
396 const char* sc = get_escape(&n->tcache, ESCAPE_SC);
397 if(sc){
398 return term_emit(sc, n->ttyfp, false);
399 }
400 return -1;
401}
@ ESCAPE_SC
Definition termdesc.h:78

◆ ncdirect_cursor_right()

int ncdirect_cursor_right ( ncdirect nc,
int  num 
)

Definition at line 98 of file direct.c.

98 {
99 if(num < 0){
100 logerror("requested negative move %d\n", num);
101 return -1;
102 }
103 if(num == 0){
104 return 0;
105 }
106 const char* cuf = get_escape(&nc->tcache, ESCAPE_CUF);
107 if(cuf){
108 return term_emit(tiparm(cuf, num), nc->ttyfp, false);
109 }
110 return -1; // FIXME fall back to cuf1?
111}
@ ESCAPE_CUF
Definition termdesc.h:61
Here is the caller graph for this function:

◆ ncdirect_cursor_up()

int ncdirect_cursor_up ( ncdirect nc,
int  num 
)

Definition at line 68 of file direct.c.

68 {
69 if(num < 0){
70 logerror("requested negative move %d\n", num);
71 return -1;
72 }
73 if(num == 0){
74 return 0;
75 }
76 const char* cuu = get_escape(&nc->tcache, ESCAPE_CUU);
77 if(cuu){
78 return term_emit(tiparm(cuu, num), nc->ttyfp, false);
79 }
80 return -1;
81}
@ ESCAPE_CUU
Definition termdesc.h:59
Here is the caller graph for this function:

◆ ncdirect_cursor_yx()

int ncdirect_cursor_yx ( ncdirect n,
unsigned *  y,
unsigned *  x 
)

Definition at line 375 of file direct.c.

375 {
376 // this is only meaningful for real terminals
377 if(n->tcache.ttyfd < 0){
378 return -1;
379 }
380 const char* u7 = get_escape(&n->tcache, ESCAPE_U7);
381 if(u7 == NULL){
382 fprintf(stderr, "Terminal doesn't support cursor reporting\n");
383 return -1;
384 }
385 unsigned yval, xval;
386 if(!y){
387 y = &yval;
388 }
389 if(!x){
390 x = &xval;
391 }
392 return cursor_yx_get(n, u7, y, x);
393}
Here is the caller graph for this function:

◆ ncdirect_detected_terminal()

char * ncdirect_detected_terminal ( const ncdirect nc)

Definition at line 1619 of file direct.c.

1619 {
1620 return termdesc_longterm(&nc->tcache);
1621}
char * termdesc_longterm(const tinfo *ti)
Definition termdesc.c:1535
Here is the call graph for this function:

◆ ncdirect_dim_x()

unsigned ncdirect_dim_x ( ncdirect nc)

Definition at line 148 of file direct.c.

148 {
149 unsigned x;
150 if(nc->tcache.ttyfd >= 0){
151 unsigned cgeo, pgeo; // don't care about either
152 if(update_term_dimensions(NULL, &x, &nc->tcache, 0, &cgeo, &pgeo) == 0){
153 return x;
154 }
155 }else{
156 return 80; // lol
157 }
158 return 0;
159}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_dim_y()

unsigned ncdirect_dim_y ( ncdirect nc)

Definition at line 161 of file direct.c.

161 {
162 unsigned y;
163 if(nc->tcache.ttyfd >= 0){
164 unsigned cgeo, pgeo; // don't care about either
165 if(update_term_dimensions(&y, NULL, &nc->tcache, 0, &cgeo, &pgeo) == 0){
166 return y;
167 }
168 }else{
169 return 24; // lol
170 }
171 return 0;
172}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_double_box()

int ncdirect_double_box ( ncdirect n,
uint64_t  ul,
uint64_t  ur,
uint64_t  ll,
uint64_t  lr,
unsigned  ylen,
unsigned  xlen,
unsigned  ctlword 
)

Definition at line 1512 of file direct.c.

1514 {
1515 return ncdirect_box(n, ul, ur, ll, lr, NCBOXDOUBLEW, ylen, xlen, ctlword);
1516}
int ncdirect_box(ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, const wchar_t *wchars, unsigned ylen, unsigned xlen, unsigned ctlword)
Definition direct.c:1395
#define NCBOXDOUBLEW
Definition ncseqs.h:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_flush()

int ncdirect_flush ( const ncdirect nc)

Definition at line 1523 of file direct.c.

1523 {
1524 return ncflush(nc->ttyfp);
1525}
Here is the caller graph for this function:

◆ ncdirect_hline_interp()

int ncdirect_hline_interp ( ncdirect n,
const char *  egc,
unsigned  len,
uint64_t  c1,
uint64_t  c2 
)

Definition at line 1272 of file direct.c.

1273 {
1274 if(len == 0){
1275 logerror("passed zero length\n");
1276 return -1;
1277 }
1278 unsigned ur, ug, ub;
1279 int r1, g1, b1, r2, g2, b2;
1280 int br1, bg1, bb1, br2, bg2, bb2;
1281 ncchannels_fg_rgb8(c1, &ur, &ug, &ub);
1282 r1 = ur; g1 = ug; b1 = ub;
1283 ncchannels_fg_rgb8(c2, &ur, &ug, &ub);
1284 r2 = ur; g2 = ug; b2 = ub;
1285 ncchannels_bg_rgb8(c1, &ur, &ug, &ub);
1286 br1 = ur; bg1 = ug; bb1 = ub;
1287 ncchannels_bg_rgb8(c2, &ur, &ug, &ub);
1288 br2 = ur; bg2 = ug; bb2 = ub;
1289 int deltr = r2 - r1;
1290 int deltg = g2 - g1;
1291 int deltb = b2 - b1;
1292 int deltbr = br2 - br1;
1293 int deltbg = bg2 - bg1;
1294 int deltbb = bb2 - bb1;
1295 unsigned ret;
1296 bool fgdef = false, bgdef = false;
1297 if(ncchannels_fg_default_p(c1) && ncchannels_fg_default_p(c2)){
1299 return -1;
1300 }
1301 fgdef = true;
1302 }
1303 if(ncchannels_bg_default_p(c1) && ncchannels_bg_default_p(c2)){
1305 return -1;
1306 }
1307 bgdef = true;
1308 }
1309 for(ret = 0 ; ret < len ; ++ret){
1310 int r = (deltr * (int)ret) / (int)len + r1;
1311 int g = (deltg * (int)ret) / (int)len + g1;
1312 int b = (deltb * (int)ret) / (int)len + b1;
1313 int br = (deltbr * (int)ret) / (int)len + br1;
1314 int bg = (deltbg * (int)ret) / (int)len + bg1;
1315 int bb = (deltbb * (int)ret) / (int)len + bb1;
1316 if(!fgdef){
1317 ncdirect_set_fg_rgb8(n, r, g, b);
1318 }
1319 if(!bgdef){
1320 ncdirect_set_bg_rgb8(n, br, bg, bb);
1321 }
1322 if(fprintf(n->ttyfp, "%s", egc) < 0){
1323 logerror("error emitting egc [%s]\n", egc);
1324 return -1;
1325 }
1326 }
1327 return ret;
1328}
int ncdirect_set_fg_default(ncdirect *nc)
Definition direct.c:1226
int ncdirect_set_bg_default(ncdirect *nc)
Definition direct.c:1249
const char * egc
Definition egcpool.h:173
int r
Definition fbuf.h:226
API int API int const nccell unsigned len
Definition notcurses.h:2588
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_off_styles()

int ncdirect_off_styles ( ncdirect n,
unsigned  stylebits 
)

Definition at line 1186 of file direct.c.

1186 {
1187 uint32_t stylemask = n->stylemask & ~stylebits;
1188 fbuf f = {0};
1189 if(fbuf_init_small(&f)){
1190 return -1;
1191 }
1192 if(ncdirect_style_emit(n, stylemask, &f)){
1193 fbuf_free(&f);
1194 return -1;
1195 }
1196 if(fbuf_finalize(&f, n->ttyfp)){
1197 return -1;
1198 }
1199 return 0;
1200}
Definition fbuf.h:25
Here is the caller graph for this function:

◆ ncdirect_on_styles()

int ncdirect_on_styles ( ncdirect n,
unsigned  stylebits 
)

Definition at line 1162 of file direct.c.

1162 {
1163 if((stylebits & n->tcache.supported_styles) < stylebits){ // unsupported styles
1164 return -1;
1165 }
1166 uint32_t stylemask = n->stylemask | stylebits;
1167 fbuf f = {0};
1168 if(fbuf_init_small(&f)){
1169 return -1;
1170 }
1171 if(ncdirect_style_emit(n, stylemask, &f)){
1172 fbuf_free(&f);
1173 return -1;
1174 }
1175 if(fbuf_finalize(&f, n->ttyfp)){
1176 return -1;
1177 }
1178 return 0;
1179}
Here is the caller graph for this function:

◆ ncdirect_palette_size()

unsigned ncdirect_palette_size ( const ncdirect nc)

Definition at line 1222 of file direct.c.

1222 {
1223 return ncdirect_capabilities(nc)->colors;
1224}
const nccapabilities * ncdirect_capabilities(const ncdirect *n)
Definition direct.c:1623
unsigned colors
Definition notcurses.h:1637
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_printf_aligned()

int ncdirect_printf_aligned ( ncdirect n,
int  y,
ncalign_e  align,
const char *  fmt,
  ... 
)

Definition at line 826 of file direct.c.

826 {
827 va_list va;
828 va_start(va, fmt);
829 int ret = ncdirect_vprintf_aligned(n, y, align, fmt, va);
830 va_end(va);
831 return ret;
832}
int ncdirect_vprintf_aligned(ncdirect *n, int y, ncalign_e align, const char *fmt, va_list ap)
Definition direct.c:803
const char * fmt
Definition fbuf.h:220
va_end(va)
const char va_start(va, fmt)
Here is the call graph for this function:

◆ ncdirect_putegc()

int ncdirect_putegc ( ncdirect nc,
uint64_t  channels,
const char *  utf8,
int *  sbytes 
)

Definition at line 49 of file direct.c.

50 {
51 int cols;
52 int bytes = utf8_egc_len(utf8, &cols);
53 if(bytes < 0){
54 return -1;
55 }
56 if(sbytes){
57 *sbytes = bytes;
58 }
59 if(activate_channels(nc, channels)){
60 return -1;
61 }
62 if(fprintf(nc->ttyfp, "%.*s", bytes, utf8) < 0){
63 return -1;
64 }
65 return cols;
66}

◆ ncdirect_putstr()

int ncdirect_putstr ( ncdirect nc,
uint64_t  channels,
const char *  utf8 
)

Definition at line 42 of file direct.c.

42 {
43 if(activate_channels(nc, channels)){
44 return -1;
45 }
46 return ncfputs(utf8, nc->ttyfp);
47}
Here is the caller graph for this function:

◆ ncdirect_raster_frame()

int ncdirect_raster_frame ( ncdirect n,
ncdirectv ncdv,
ncalign_e  align 
)

Definition at line 627 of file direct.c.

627 {
628 int lenx = ncplane_dim_x(ncdv);
629 int xoff = ncdirect_align(n, align, lenx);
630 int r = ncdirect_dump_plane(n, ncdv, xoff);
631 free_plane(ncdv);
632 return r;
633}
void free_plane(ncplane *p)
Definition notcurses.c:464
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_readline()

char * ncdirect_readline ( ncdirect n,
const char *  prompt 
)

Definition at line 982 of file direct.c.

982 {
983 const char* u7 = get_escape(&n->tcache, ESCAPE_U7);
984 if(!u7){ // we probably *can*, but it would be a pita; screw it
985 logerror("can't readline without u7");
986 return NULL;
987 }
988 if(n->eof){
989 logerror("already got EOF");
990 return NULL;
991 }
992 if(fprintf(n->ttyfp, "%s", prompt) < 0){
993 return NULL;
994 }
995 unsigned dimx = ncdirect_dim_x(n);
996 if(dimx == 0){
997 return NULL;
998 }
999 // FIXME what if we're reading from redirected input, not a terminal?
1000 unsigned y, xstart;
1001 if(cursor_yx_get(n, u7, &y, &xstart)){
1002 return NULL;
1003 }
1004 int tline = y;
1005 unsigned bline = y;
1006 wchar_t* str;
1007 int wspace = BUFSIZ / sizeof(*str);
1008 if((str = malloc(wspace * sizeof(*str))) == NULL){
1009 return NULL;
1010 }
1011 int wpos = 0; // cursor location (single-dimensional)
1012 int wused = 0; // number used
1013 str[wused++] = L'\0';
1014 ncinput ni;
1015 uint32_t id;
1016 unsigned oldx = xstart;
1017 while((id = ncdirect_get_blocking(n, &ni)) != (uint32_t)-1){
1018 if(ni.evtype == NCTYPE_RELEASE){
1019 continue;
1020 }
1021 if(id == NCKEY_EOF || id == NCKEY_ENTER || (ncinput_ctrl_p(&ni) && id == 'D')){
1022 if(id == NCKEY_ENTER){
1023 if(fputc('\n', n->ttyfp) < 0){
1024 free(str);
1025 return NULL;
1026 }
1027 }else{
1028 n->eof = 1;
1029 if(wused == 1){ // NCKEY_EOF without input returns NULL
1030 free(str);
1031 return NULL;
1032 }
1033 }
1034 char* ustr = ncwcsrtombs(str);
1035 free(str);
1036 return ustr;
1037 }else if(id == NCKEY_BACKSPACE){
1038 if(wused > 1){
1039 str[wused - 2] = L'\0';
1040 --wused;
1041 }
1042 --wpos;
1043 }else if(id == NCKEY_LEFT){
1044 --wpos;
1045 }else if(id == NCKEY_RIGHT){
1046 ++wpos;
1047 }else if(id == NCKEY_UP){
1048 wpos -= dimx;
1049 }else if(id == NCKEY_DOWN){
1050 wpos += dimx;
1051 }else if(id == 'A' && ncinput_ctrl_p(&ni)){
1052 wpos = 1;
1053 }else if(id == 'E' && ncinput_ctrl_p(&ni)){
1054 wpos = wused - 1;
1055 }else if(nckey_synthesized_p(ni.id)){
1056 continue;
1057 }else{
1058 if(wspace - 1 < wused){
1059 wspace += BUFSIZ;
1060 wchar_t* tmp = realloc(str, wspace * sizeof(*str));
1061 if(tmp == NULL){
1062 free(str);
1063 return NULL;
1064 }
1065 str = tmp;
1066 }
1067 if(wpos < wused - 1){
1068 memmove(str + wpos + 1, str + wpos, (wused - wpos) * sizeof(*str));
1069 str[wpos] = id;
1070 ++wused;
1071 ++wpos;
1072 }else{
1073 str[wused - 1] = id;
1074 ++wused;
1075 ++wpos;
1076 str[wused - 1] = L'\0';
1077 }
1078 // FIXME check modifiers
1079 unsigned x;
1080 if(cursor_yx_get(n, u7, &y, &x)){
1081 break;
1082 }
1083 if(x < oldx){
1084 oldx = x;
1085 if(--tline < 0){
1086 tline = 0;
1087 }
1088 }
1089 if(y > bline){
1090 bline = y;
1091 }
1092 }
1093 if(wpos < 0){
1094 wpos = 0;
1095 }else if(wpos > wused - 1){
1096 wpos = wused - 1;
1097 }
1098 // clear to end of line(s)
1099 const char* el = get_escape(&n->tcache, ESCAPE_EL);
1100 for(int i = bline ; i >= tline ; --i){
1101 if(ncdirect_cursor_move_yx(n, i, i > tline ? 0 : xstart)){
1102 break;
1103 }
1104 if(term_emit(el, n->ttyfp, false)){
1105 break;
1106 }
1107 }
1108 if(fprintf(n->ttyfp, "%ls", str) < 0){
1109 break;
1110 }
1111 if(wpos != wused){
1112 int linear = xstart + wpos;
1113 int ylin = linear / dimx;
1114 int xlin = linear % dimx;
1115 if(ncdirect_cursor_move_yx(n, tline + ylin, xlin)){
1116 break;
1117 }
1118 }
1119 if(fflush(n->ttyfp)){
1120 break;
1121 }
1122 }
1123 free(str);
1124 return NULL;
1125}
unsigned ncdirect_dim_x(ncdirect *nc)
Definition direct.c:148
const char * prompt
Definition direct.h:68
#define NCKEY_UP
Definition nckeys.h:37
#define NCKEY_BACKSPACE
Definition nckeys.h:43
#define NCKEY_EOF
Definition nckeys.h:183
#define NCKEY_DOWN
Definition nckeys.h:39
#define NCKEY_RIGHT
Definition nckeys.h:38
#define NCKEY_ENTER
Definition nckeys.h:110
#define NCKEY_LEFT
Definition nckeys.h:40
@ NCTYPE_RELEASE
Definition notcurses.h:1198
ncintype_e evtype
Definition notcurses.h:1218
uint32_t id
Definition notcurses.h:1210
@ ESCAPE_EL
Definition termdesc.h:67
Here is the call graph for this function:

◆ ncdirect_render_frame()

ncdirectv * ncdirect_render_frame ( ncdirect n,
const char *  file,
ncblitter_e  blitfxn,
ncscale_e  scale,
int  ymax,
int  xmax 
)

Definition at line 739 of file direct.c.

741 {
742 if(ymax < 0 || xmax < 0){
743 return NULL;
744 }
746 if(ncv == NULL){
747 return NULL;
748 }
749 struct ncvisual_options vopts = {0};
750 const struct blitset* bset = rgba_blitter_low(&n->tcache, scale, true, blitfxn);
751 if(!bset){
752 return NULL;
753 }
754 vopts.blitter = bset->geom;
756 vopts.scaling = scale;
757 if(ymax > 0){
758 if((vopts.leny = ymax * bset->height) > ncv->pixy){
759 vopts.leny = 0;
760 }
761 }
762 if(xmax > 0){
763 if((vopts.lenx = xmax * bset->width) > ncv->pixx){
764 vopts.lenx = 0;
765 }
766 }
769 return v;
770}
ncdirectf * ncdirectf_from_file(ncdirect *n __attribute__((unused)), const char *filename)
Definition direct.c:1592
ncdirectv * ncdirectf_render(ncdirect *n, ncdirectf *frame, const struct ncvisual_options *vopts)
Definition direct.c:1601
const struct ncplane_options struct ncvisual * ncv
Definition notcurses.h:3484
const struct ncplane_options struct ncvisual struct ncvisual_options * vopts
Definition notcurses.h:3484
struct ncvisual_options v
Definition notcurses.h:3497
#define NCVISUAL_OPTION_NODEGRADE
Definition notcurses.h:3337
ncblitter_e geom
Definition internal.h:399
unsigned width
Definition internal.h:400
unsigned height
Definition internal.h:401
void ncvisual_destroy(ncvisual *ncv)
Definition visual.c:1225
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_render_image()

int ncdirect_render_image ( ncdirect n,
const char *  file,
ncalign_e  align,
ncblitter_e  blitfxn,
ncscale_e  scale 
)

Definition at line 772 of file direct.c.

773 {
774 ncdirectv* faken = ncdirect_render_frame(n, file, blitfxn, scale, 0, 0);
775 if(!faken){
776 return -1;
777 }
778 return ncdirect_raster_frame(n, faken, align);
779}
ncdirectv * ncdirect_render_frame(ncdirect *n, const char *file, ncblitter_e blitfxn, ncscale_e scale, int ymax, int xmax)
Definition direct.c:739
int ncdirect_raster_frame(ncdirect *n, ncdirectv *ncdv, ncalign_e align)
Definition direct.c:627
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_rounded_box()

int ncdirect_rounded_box ( ncdirect n,
uint64_t  ul,
uint64_t  ur,
uint64_t  ll,
uint64_t  lr,
unsigned  ylen,
unsigned  xlen,
unsigned  ctlword 
)

Definition at line 1506 of file direct.c.

1508 {
1509 return ncdirect_box(n, ul, ur, ll, lr, NCBOXROUNDW, ylen, xlen, ctlword);
1510}
#define NCBOXROUNDW
Definition ncseqs.h:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_bg_default()

int ncdirect_set_bg_default ( ncdirect nc)

Definition at line 1249 of file direct.c.

1249 {
1250 if(ncdirect_bg_default_p(nc)){
1251 return 0;
1252 }
1253 const char* esc;
1254 if((esc = get_escape(&nc->tcache, ESCAPE_BGOP)) != NULL){
1255 if(term_emit(esc, nc->ttyfp, false)){
1256 return -1;
1257 }
1258 }else if((esc = get_escape(&nc->tcache, ESCAPE_OP)) != NULL){
1259 if(term_emit(esc, nc->ttyfp, false)){
1260 return -1;
1261 }
1262 if(!ncdirect_fg_default_p(nc)){
1263 if(ncdirect_set_fg_rgb(nc, ncchannels_fg_rgb(nc->channels))){
1264 return -1;
1265 }
1266 }
1267 }
1268 ncchannels_set_bg_default(&nc->channels);
1269 return 0;
1270}
int ncdirect_set_fg_rgb(ncdirect *nc, unsigned rgb)
Definition render.c:1697
uint64_t channels
Definition internal.h:254
@ ESCAPE_OP
Definition termdesc.h:50
@ ESCAPE_BGOP
Definition termdesc.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_bg_palindex()

int ncdirect_set_bg_palindex ( ncdirect nc,
int  pidx 
)

Definition at line 792 of file direct.c.

792 {
793 const char* setab = get_escape(&nc->tcache, ESCAPE_SETAB);
794 if(!setab){
795 return -1;
796 }
797 if(ncchannels_set_bg_palindex(&nc->channels, pidx) < 0){
798 return -1;
799 }
800 return term_emit(tiparm(setab, pidx), nc->ttyfp, false);
801}
@ ESCAPE_SETAB
Definition termdesc.h:49
Here is the caller graph for this function:

◆ ncdirect_set_fg_default()

int ncdirect_set_fg_default ( ncdirect nc)

Definition at line 1226 of file direct.c.

1226 {
1227 if(ncdirect_fg_default_p(nc)){
1228 return 0;
1229 }
1230 const char* esc;
1231 if((esc = get_escape(&nc->tcache, ESCAPE_FGOP)) != NULL){
1232 if(term_emit(esc, nc->ttyfp, false)){
1233 return -1;
1234 }
1235 }else if((esc = get_escape(&nc->tcache, ESCAPE_OP)) != NULL){
1236 if(term_emit(esc, nc->ttyfp, false)){
1237 return -1;
1238 }
1239 if(!ncdirect_bg_default_p(nc)){
1240 if(ncdirect_set_bg_rgb(nc, ncchannels_bg_rgb(nc->channels))){
1241 return -1;
1242 }
1243 }
1244 }
1245 ncchannels_set_fg_default(&nc->channels);
1246 return 0;
1247}
int ncdirect_set_bg_rgb(ncdirect *nc, unsigned rgb)
Definition render.c:1667
@ ESCAPE_FGOP
Definition termdesc.h:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_fg_palindex()

int ncdirect_set_fg_palindex ( ncdirect nc,
int  pidx 
)

Definition at line 781 of file direct.c.

781 {
782 const char* setaf = get_escape(&nc->tcache, ESCAPE_SETAF);
783 if(!setaf){
784 return -1;
785 }
786 if(ncchannels_set_fg_palindex(&nc->channels, pidx) < 0){
787 return -1;
788 }
789 return term_emit(tiparm(setaf, pidx), nc->ttyfp, false);
790}
@ ESCAPE_SETAF
Definition termdesc.h:48
Here is the caller graph for this function:

◆ ncdirect_set_styles()

int ncdirect_set_styles ( ncdirect n,
unsigned  stylebits 
)

Definition at line 1203 of file direct.c.

1203 {
1204 if((stylebits & n->tcache.supported_styles) < stylebits){ // unsupported styles
1205 return -1;
1206 }
1207 uint32_t stylemask = stylebits;
1208 fbuf f = {0};
1209 if(fbuf_init_small(&f)){
1210 return -1;
1211 }
1212 if(ncdirect_style_emit(n, stylemask, &f)){
1213 fbuf_free(&f);
1214 return -1;
1215 }
1216 if(fbuf_finalize(&f, n->ttyfp)){
1217 return -1;
1218 }
1219 return 0;
1220}
Here is the caller graph for this function:

◆ ncdirect_stop()

int ncdirect_stop ( ncdirect nc)

Definition at line 954 of file direct.c.

954 {
955 int ret = 0;
956 if(nc){
957 void* altstack;
958 ret |= ncdirect_stop_minimal(nc, &altstack);
960 if(nc->tcache.ttyfd >= 0){
961 ret |= close(nc->tcache.ttyfd);
962 }
963 pthread_mutex_destroy(&nc->stats.lock);
964 free(nc);
965 free(altstack);
966 }
967 return ret;
968}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_stream()

int ncdirect_stream ( ncdirect n,
const char *  filename,
ncstreamcb  streamer,
struct ncvisual_options vopts,
void *  curry 
)

Definition at line 1534 of file direct.c.

1535 {
1536 ncvisual* ncv = ncvisual_from_file(filename);
1537 if(ncv == NULL){
1538 return -1;
1539 }
1540 // starting position *after displaying one frame* so as to effect any
1541 // necessary scrolling.
1542 unsigned y = 0, x = 0;
1543 int lastid = -1;
1544 int thisid = -1;
1545 do{
1546 if(y > 0){
1547 if(x == ncdirect_dim_x(n)){
1548 x = 0;
1549 ++y;
1550 }
1551 ncdirect_cursor_up(n, y - 1);
1552 }
1553 if(x > 0){
1555 }
1556 ncdirectv* v = ncdirect_render_visual(n, ncv, vopts);
1557 if(v == NULL){
1559 return -1;
1560 }
1561 ncplane_dim_yx(v, &y, &x);
1562 if(v->sprite){
1563 thisid = v->sprite->id;
1564 }
1567 return -1;
1568 }
1569 if(lastid > -1){
1570 if(n->tcache.pixel_remove){
1571 fbuf f = {0};
1572 fbuf_init_small(&f);
1573 if(n->tcache.pixel_remove(lastid, &f)){
1574 fbuf_free(&f);
1576 return -1;
1577 }
1578 if(fbuf_finalize(&f, n->ttyfp) < 0){
1580 return -1;
1581 }
1582 }
1583 }
1584 streamer(ncv, vopts, NULL, curry);
1585 lastid = thisid;
1586 }while(ncvisual_decode(ncv) == 0);
1589 return 0;
1590}
int ncdirect_flush(const ncdirect *nc)
Definition direct.c:1523
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
Definition notcurses.c:301
#define NCVISUAL_OPTION_HORALIGNED
Definition notcurses.h:3339
int ncvisual_decode(ncvisual *nc)
Definition visual.c:39
ncvisual * ncvisual_from_file(const char *filename)
Definition visual.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_styles()

uint16_t ncdirect_styles ( const ncdirect n)

Definition at line 1181 of file direct.c.

1181 {
1182 return n->stylemask;
1183}

◆ ncdirect_supported_styles()

uint16_t ncdirect_supported_styles ( const ncdirect nc)

Definition at line 1615 of file direct.c.

1615 {
1616 return term_supported_styles(&nc->tcache);
1617}

◆ ncdirect_vline_interp()

int ncdirect_vline_interp ( ncdirect n,
const char *  egc,
unsigned  len,
uint64_t  c1,
uint64_t  c2 
)

Definition at line 1330 of file direct.c.

1331 {
1332 if(len == 0){
1333 logerror("passed zero length\n");
1334 return -1;
1335 }
1336 unsigned ur, ug, ub;
1337 int r1, g1, b1, r2, g2, b2;
1338 int br1, bg1, bb1, br2, bg2, bb2;
1339 ncchannels_fg_rgb8(c1, &ur, &ug, &ub);
1340 r1 = ur; g1 = ug; b1 = ub;
1341 ncchannels_fg_rgb8(c2, &ur, &ug, &ub);
1342 r2 = ur; g2 = ug; b2 = ub;
1343 ncchannels_bg_rgb8(c1, &ur, &ug, &ub);
1344 br1 = ur; bg1 = ug; bb1 = ub;
1345 ncchannels_bg_rgb8(c2, &ur, &ug, &ub);
1346 br2 = ur; bg2 = ug; bb2 = ub;
1347 int deltr = (r2 - r1) / ((int)len + 1);
1348 int deltg = (g2 - g1) / ((int)len + 1);
1349 int deltb = (b2 - b1) / ((int)len + 1);
1350 int deltbr = (br2 - br1) / ((int)len + 1);
1351 int deltbg = (bg2 - bg1) / ((int)len + 1);
1352 int deltbb = (bb2 - bb1) / ((int)len + 1);
1353 unsigned ret;
1354 bool fgdef = false, bgdef = false;
1355 if(ncchannels_fg_default_p(c1) && ncchannels_fg_default_p(c2)){
1357 return -1;
1358 }
1359 fgdef = true;
1360 }
1361 if(ncchannels_bg_default_p(c1) && ncchannels_bg_default_p(c2)){
1363 return -1;
1364 }
1365 bgdef = true;
1366 }
1367 for(ret = 0 ; ret < len ; ++ret){
1368 r1 += deltr;
1369 g1 += deltg;
1370 b1 += deltb;
1371 br1 += deltbr;
1372 bg1 += deltbg;
1373 bb1 += deltbb;
1374 uint64_t channels = 0;
1375 if(!fgdef){
1376 ncchannels_set_fg_rgb8(&channels, r1, g1, b1);
1377 }
1378 if(!bgdef){
1379 ncchannels_set_bg_rgb8(&channels, br1, bg1, bb1);
1380 }
1381 if(ncdirect_putstr(n, channels, egc) == EOF){
1382 return -1;
1383 }
1384 if(len - ret > 1){
1386 return -1;
1387 }
1388 }
1389 }
1390 return ret;
1391}
int ncdirect_putstr(ncdirect *nc, uint64_t channels, const char *utf8)
Definition direct.c:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_vprintf_aligned()

int ncdirect_vprintf_aligned ( ncdirect n,
int  y,
ncalign_e  align,
const char *  fmt,
va_list  ap 
)

Definition at line 803 of file direct.c.

803 {
804 char* r = ncplane_vprintf_prep(fmt, ap);
805 if(r == NULL){
806 return -1;
807 }
808 const int len = ncstrwidth(r, NULL, NULL);
809 if(len < 0){
810 free(r);
811 return -1;
812 }
813 const int x = ncdirect_align(n, align, len);
815 free(r);
816 return -1;
817 }
818 int ret = puts(r);
819 free(r);
820 if(ret == EOF){
821 return -1;
822 }
823 return ret;
824}
ALLOC char * ncplane_vprintf_prep(const char *format, va_list ap)
Definition notcurses.c:2087
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
Definition notcurses.c:3309
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirectf_free()

void ncdirectf_free ( ncdirectf frame)

Definition at line 1597 of file direct.c.

1597 {
1598 ncvisual_destroy(frame);
1599}
Here is the call graph for this function:

◆ ncdirectf_from_file()

ncdirectf * ncdirectf_from_file ( ncdirect *n   __attribute__(unused),
const char *  filename 
)

Definition at line 1592 of file direct.c.

1593 {
1594 return ncvisual_from_file(filename);
1595}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirectf_geom()

int ncdirectf_geom ( ncdirect n,
ncdirectf frame,
const struct ncvisual_options vopts,
ncvgeom geom 
)

Definition at line 1605 of file direct.c.

1606 {
1607 const struct blitset* bset;
1608 unsigned disppxy, disppxx, outy, outx;
1609 int placey, placex;
1610 return ncvisual_geom_inner(&n->tcache, frame, vopts, geom, &bset,
1611 &disppxy, &disppxx, &outy, &outx,
1612 &placey, &placex);
1613}
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 call graph for this function:

◆ ncdirectf_render()

ncdirectv * ncdirectf_render ( ncdirect n,
ncdirectf frame,
const struct ncvisual_options vopts 
)

Definition at line 1601 of file direct.c.

1601 {
1602 return ncdirect_render_visual(n, frame, vopts);
1603}
Here is the caller graph for this function: