Notcurses 3.0.16
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 1398 of file direct.c.

1400 {
1401 if(xlen < 2 || ylen < 2){
1402 return -1;
1403 }
1404 char hl[MB_LEN_MAX + 1];
1405 char vl[MB_LEN_MAX + 1];
1406 unsigned edges;
1407 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_LEFT);
1408 // FIXME rewrite all fprintfs as ncdirect_putstr()!
1409 if(edges >= box_corner_needs(ctlword)){
1410 if(activate_channels(n, ul)){
1411 return -1;
1412 }
1413 if(fprintf(n->ttyfp, "%lc", wchars[0]) < 0){
1414 logerror("error emitting %lc\n", wchars[0]);
1415 return -1;
1416 }
1417 }else{
1419 }
1420 mbstate_t ps = {0};
1421 size_t bytes;
1422 if((bytes = wcrtomb(hl, wchars[4], &ps)) == (size_t)-1){
1423 logerror("error converting %lc\n", wchars[4]);
1424 return -1;
1425 }
1426 hl[bytes] = '\0';
1427 memset(&ps, 0, sizeof(ps));
1428 if((bytes = wcrtomb(vl, wchars[5], &ps)) == (size_t)-1){
1429 logerror("error converting %lc\n", wchars[5]);
1430 return -1;
1431 }
1432 vl[bytes] = '\0';
1433 if(!(ctlword & NCBOXMASK_TOP)){ // draw top border, if called for
1434 if(xlen > 2){
1435 if(ncdirect_hline_interp(n, hl, xlen - 2, ul, ur) < 0){
1436 return -1;
1437 }
1438 }
1439 }else{
1441 }
1442 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_RIGHT);
1443 if(edges >= box_corner_needs(ctlword)){
1444 if(activate_channels(n, ur)){
1445 return -1;
1446 }
1447 if(fprintf(n->ttyfp, "%lc", wchars[1]) < 0){
1448 return -1;
1449 }
1451 }else{
1453 }
1455 // middle rows (vertical lines)
1456 if(ylen > 2){
1457 if(!(ctlword & NCBOXMASK_LEFT)){
1458 if(ncdirect_vline_interp(n, vl, ylen - 2, ul, ll) < 0){
1459 return -1;
1460 }
1463 }else{
1465 }
1466 if(!(ctlword & NCBOXMASK_RIGHT)){
1467 if(ncdirect_vline_interp(n, vl, ylen - 2, ur, lr) < 0){
1468 return -1;
1469 }
1471 }else{
1473 }
1475 }
1476 // bottom line
1477 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_LEFT);
1478 if(edges >= box_corner_needs(ctlword)){
1479 if(activate_channels(n, ll)){
1480 return -1;
1481 }
1482 if(fprintf(n->ttyfp, "%lc", wchars[2]) < 0){
1483 return -1;
1484 }
1485 }else{
1487 }
1488 if(!(ctlword & NCBOXMASK_BOTTOM)){
1489 if(xlen > 2){
1490 if(ncdirect_hline_interp(n, hl, xlen - 2, ll, lr) < 0){
1491 return -1;
1492 }
1493 }
1494 }else{
1496 }
1497 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_RIGHT);
1498 if(edges >= box_corner_needs(ctlword)){
1499 if(activate_channels(n, lr)){
1500 return -1;
1501 }
1502 if(fprintf(n->ttyfp, "%lc", wchars[3]) < 0){
1503 return -1;
1504 }
1505 }
1506 return 0;
1507}
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:1275
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:1333
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:2605
#define NCBOXMASK_LEFT
Definition notcurses.h:2608
vopts n
Definition notcurses.h:3506
#define NCBOXMASK_BOTTOM
Definition notcurses.h:2607
#define NCBOXMASK_RIGHT
Definition notcurses.h:2606
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 1630 of file direct.c.

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

◆ ncdirect_canutf8()

bool ncdirect_canutf8 ( const ncdirect n)

Definition at line 1522 of file direct.c.

1522 {
1523 return n->tcache.caps.utf8;
1524}
Here is the caller graph for this function:

◆ ncdirect_capabilities()

const nccapabilities * ncdirect_capabilities ( const ncdirect n)

Definition at line 1626 of file direct.c.

1626 {
1627 return &n->tcache.caps;
1628}
Here is the caller graph for this function:

◆ ncdirect_check_pixel_support()

int ncdirect_check_pixel_support ( const ncdirect n)

Definition at line 1530 of file direct.c.

1530 {
1531 if(n->tcache.pixel_draw || n->tcache.pixel_draw_late){
1532 return 1;
1533 }
1534 return 0;
1535}
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 871 of file direct.c.

871 {
872 if(outfp == NULL){
873 outfp = stdout;
874 }
875 if(flags > (NCDIRECT_OPTION_DRAIN_INPUT << 1)){ // allow them through with warning
876 logwarn("Passed unsupported flags 0x%016" PRIx64 "\n", flags);
877 }
878 if(termtype){
879 if(putenv_term(termtype)){
880 return NULL;
881 }
882 }
883 ncdirect* ret = malloc(sizeof(ncdirect));
884 if(ret == NULL){
885 return ret;
886 }
887 memset(ret, 0, sizeof(*ret));
888 if(pthread_mutex_init(&ret->stats.lock, NULL)){
889 free(ret);
890 return NULL;
891 }
892 ret->flags = flags;
893 ret->ttyfp = outfp;
895 init_lang();
896 }
897 const char* encoding = nl_langinfo(CODESET);
898 bool utf8 = false;
899 if(encoding && encoding_is_utf8(encoding)){
900 utf8 = true;
902 }
904 true, ncdirect_stop_minimal)){
905 pthread_mutex_destroy(&ret->stats.lock);
906 free(ret);
907 return NULL;
908 }
909 // don't set the loglevel until we've locked in signal handling, lest we
910 // change the loglevel out from under a running instance.
913 }else if(flags & NCDIRECT_OPTION_VERBOSE){
915 }else{
917 }
919 int cursor_y = -1;
920 int cursor_x = -1;
921 if(interrogate_terminfo(&ret->tcache, ret->ttyfp, utf8, 1,
923 0, &cursor_y, &cursor_x, &ret->stats, 0, 0, 0, 0,
925 goto err;
926 }
927 if(cursor_y >= 0){
928 // the u7 led the queries so that we would get a cursor position
929 // unaffected by any query spill (unconsumed control sequences). move
930 // us back to that location, in case there was any such spillage.
931 if(ncdirect_cursor_move_yx(ret, cursor_y, cursor_x)){
933 goto err;
934 }
935 }
938 goto err;
939 }
940 unsigned cgeo, pgeo; // both are don't-cares
941 update_term_dimensions(NULL, NULL, &ret->tcache, 0, &cgeo, &pgeo);
942 ncdirect_set_styles(ret, 0);
943 return ret;
944
945err:{
946 void* altstack;
947 if(ret->tcache.ttyfd >= 0){
948 (void)tcsetattr(ret->tcache.ttyfd, TCSANOW, ret->tcache.tpreserved);
949 }
950 drop_signals(ret, &altstack);
951 pthread_mutex_destroy(&ret->stats.lock);
952 free(ret);
953 }
954 return NULL;
955}
ncloglevel_e loglevel
Definition debug.c:3
int ncdirect_set_styles(ncdirect *n, unsigned stylebits)
Definition direct.c:1206
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
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:1655
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:1097
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:1317
int setup_signals(void *vnc, bool no_quit_sigs, bool no_winch_sigs, int(*handler)(void *, void **, int))
Definition unixsig.c:195
int drop_signals(void *nc, void **altstack)
Definition unixsig.c:104
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 1622 of file direct.c.

1622 {
1623 return termdesc_longterm(&nc->tcache);
1624}
char * termdesc_longterm(const tinfo *ti)
Definition termdesc.c:1558
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 1515 of file direct.c.

1517 {
1518 return ncdirect_box(n, ul, ur, ll, lr, NCBOXDOUBLEW, ylen, xlen, ctlword);
1519}
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:1398
#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 1526 of file direct.c.

1526 {
1527 return ncflush(nc->ttyfp);
1528}
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 1275 of file direct.c.

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

1189 {
1190 uint32_t stylemask = n->stylemask & ~stylebits;
1191 fbuf f = {0};
1192 if(fbuf_init_small(&f)){
1193 return -1;
1194 }
1195 if(ncdirect_style_emit(n, stylemask, &f)){
1196 fbuf_free(&f);
1197 return -1;
1198 }
1199 if(fbuf_finalize(&f, n->ttyfp)){
1200 return -1;
1201 }
1202 return 0;
1203}
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 1165 of file direct.c.

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

◆ ncdirect_palette_size()

unsigned ncdirect_palette_size ( const ncdirect nc)

Definition at line 1225 of file direct.c.

1225 {
1226 return ncdirect_capabilities(nc)->colors;
1227}
const nccapabilities * ncdirect_capabilities(const ncdirect *n)
Definition direct.c:1626
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:467
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 985 of file direct.c.

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

1511 {
1512 return ncdirect_box(n, ul, ur, ll, lr, NCBOXROUNDW, ylen, xlen, ctlword);
1513}
#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 1252 of file direct.c.

1252 {
1253 if(ncdirect_bg_default_p(nc)){
1254 return 0;
1255 }
1256 const char* esc;
1257 if((esc = get_escape(&nc->tcache, ESCAPE_BGOP)) != NULL){
1258 if(term_emit(esc, nc->ttyfp, false)){
1259 return -1;
1260 }
1261 }else if((esc = get_escape(&nc->tcache, ESCAPE_OP)) != NULL){
1262 if(term_emit(esc, nc->ttyfp, false)){
1263 return -1;
1264 }
1265 if(!ncdirect_fg_default_p(nc)){
1266 if(ncdirect_set_fg_rgb(nc, ncchannels_fg_rgb(nc->channels))){
1267 return -1;
1268 }
1269 }
1270 }
1271 ncchannels_set_bg_default(&nc->channels);
1272 return 0;
1273}
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 1229 of file direct.c.

1229 {
1230 if(ncdirect_fg_default_p(nc)){
1231 return 0;
1232 }
1233 const char* esc;
1234 if((esc = get_escape(&nc->tcache, ESCAPE_FGOP)) != NULL){
1235 if(term_emit(esc, nc->ttyfp, false)){
1236 return -1;
1237 }
1238 }else if((esc = get_escape(&nc->tcache, ESCAPE_OP)) != NULL){
1239 if(term_emit(esc, nc->ttyfp, false)){
1240 return -1;
1241 }
1242 if(!ncdirect_bg_default_p(nc)){
1243 if(ncdirect_set_bg_rgb(nc, ncchannels_bg_rgb(nc->channels))){
1244 return -1;
1245 }
1246 }
1247 }
1248 ncchannels_set_fg_default(&nc->channels);
1249 return 0;
1250}
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 1206 of file direct.c.

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

◆ ncdirect_stop()

int ncdirect_stop ( ncdirect nc)

Definition at line 957 of file direct.c.

957 {
958 int ret = 0;
959 if(nc){
960 void* altstack;
961 ret |= ncdirect_stop_minimal(nc, &altstack, 0);
963 if(nc->tcache.ttyfd >= 0){
964 ret |= close(nc->tcache.ttyfd);
965 }
966 pthread_mutex_destroy(&nc->stats.lock);
967 free(nc);
968 free(altstack);
969 }
970 return ret;
971}
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 1537 of file direct.c.

1538 {
1539 ncvisual* ncv = ncvisual_from_file(filename);
1540 if(ncv == NULL){
1541 return -1;
1542 }
1543 // starting position *after displaying one frame* so as to effect any
1544 // necessary scrolling.
1545 unsigned y = 0, x = 0;
1546 int lastid = -1;
1547 int thisid = -1;
1548 do{
1549 if(y > 0){
1550 if(x == ncdirect_dim_x(n)){
1551 x = 0;
1552 ++y;
1553 }
1554 ncdirect_cursor_up(n, y - 1);
1555 }
1556 if(x > 0){
1558 }
1559 ncdirectv* v = ncdirect_render_visual(n, ncv, vopts);
1560 if(v == NULL){
1562 return -1;
1563 }
1564 ncplane_dim_yx(v, &y, &x);
1565 if(v->sprite){
1566 thisid = v->sprite->id;
1567 }
1570 return -1;
1571 }
1572 if(lastid > -1){
1573 if(n->tcache.pixel_remove){
1574 fbuf f = {0};
1575 fbuf_init_small(&f);
1576 if(n->tcache.pixel_remove(lastid, &f)){
1577 fbuf_free(&f);
1579 return -1;
1580 }
1581 if(fbuf_finalize(&f, n->ttyfp) < 0){
1583 return -1;
1584 }
1585 }
1586 }
1587 streamer(ncv, vopts, NULL, curry);
1588 lastid = thisid;
1589 }while(ncvisual_decode(ncv) == 0);
1592 return 0;
1593}
int ncdirect_flush(const ncdirect *nc)
Definition direct.c:1526
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
Definition notcurses.c:304
#define NCVISUAL_OPTION_HORALIGNED
Definition notcurses.h:3343
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 1184 of file direct.c.

1184 {
1185 return n->stylemask;
1186}

◆ ncdirect_supported_styles()

uint16_t ncdirect_supported_styles ( const ncdirect nc)

Definition at line 1618 of file direct.c.

1618 {
1619 return term_supported_styles(&nc->tcache);
1620}

◆ ncdirect_vline_interp()

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

Definition at line 1333 of file direct.c.

1334 {
1335 if(len == 0){
1336 logerror("passed zero length\n");
1337 return -1;
1338 }
1339 unsigned ur, ug, ub;
1340 int r1, g1, b1, r2, g2, b2;
1341 int br1, bg1, bb1, br2, bg2, bb2;
1342 ncchannels_fg_rgb8(c1, &ur, &ug, &ub);
1343 r1 = ur; g1 = ug; b1 = ub;
1344 ncchannels_fg_rgb8(c2, &ur, &ug, &ub);
1345 r2 = ur; g2 = ug; b2 = ub;
1346 ncchannels_bg_rgb8(c1, &ur, &ug, &ub);
1347 br1 = ur; bg1 = ug; bb1 = ub;
1348 ncchannels_bg_rgb8(c2, &ur, &ug, &ub);
1349 br2 = ur; bg2 = ug; bb2 = ub;
1350 int deltr = (r2 - r1) / ((int)len + 1);
1351 int deltg = (g2 - g1) / ((int)len + 1);
1352 int deltb = (b2 - b1) / ((int)len + 1);
1353 int deltbr = (br2 - br1) / ((int)len + 1);
1354 int deltbg = (bg2 - bg1) / ((int)len + 1);
1355 int deltbb = (bb2 - bb1) / ((int)len + 1);
1356 unsigned ret;
1357 bool fgdef = false, bgdef = false;
1358 if(ncchannels_fg_default_p(c1) && ncchannels_fg_default_p(c2)){
1360 return -1;
1361 }
1362 fgdef = true;
1363 }
1364 if(ncchannels_bg_default_p(c1) && ncchannels_bg_default_p(c2)){
1366 return -1;
1367 }
1368 bgdef = true;
1369 }
1370 for(ret = 0 ; ret < len ; ++ret){
1371 r1 += deltr;
1372 g1 += deltg;
1373 b1 += deltb;
1374 br1 += deltbr;
1375 bg1 += deltbg;
1376 bb1 += deltbb;
1377 uint64_t channels = 0;
1378 if(!fgdef){
1379 ncchannels_set_fg_rgb8(&channels, r1, g1, b1);
1380 }
1381 if(!bgdef){
1382 ncchannels_set_bg_rgb8(&channels, br1, bg1, bb1);
1383 }
1384 if(ncdirect_putstr(n, channels, egc) == EOF){
1385 return -1;
1386 }
1387 if(len - ret > 1){
1389 return -1;
1390 }
1391 }
1392 }
1393 return ret;
1394}
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:2093
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
Definition notcurses.c:3311
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 1600 of file direct.c.

1600 {
1601 ncvisual_destroy(frame);
1602}
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 1595 of file direct.c.

1596 {
1597 return ncvisual_from_file(filename);
1598}
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 1608 of file direct.c.

1609 {
1610 const struct blitset* bset;
1611 unsigned disppxy, disppxx, outy, outx;
1612 int placey, placex;
1613 return ncvisual_geom_inner(&n->tcache, frame, vopts, geom, &bset,
1614 &disppxy, &disppxx, &outy, &outx,
1615 &placey, &placex);
1616}
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 1604 of file direct.c.

1604 {
1605 return ncdirect_render_visual(n, frame, vopts);
1606}
Here is the caller graph for this function: