Notcurses 3.0.16
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
direct.h File Reference
Include dependency graph for direct.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define API   __attribute__((visibility("default")))
 
#define ALLOC   __attribute__((malloc)) __attribute__((warn_unused_result))
 
#define NCDIRECT_OPTION_INHIBIT_SETLOCALE   0x0001ull
 
#define NCDIRECT_OPTION_INHIBIT_CBREAK   0x0002ull
 
#define NCDIRECT_OPTION_DRAIN_INPUT   0x0004ull
 
#define NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS   0x0008ull
 
#define NCDIRECT_OPTION_VERBOSE   0x0010ull
 
#define NCDIRECT_OPTION_VERY_VERBOSE   0x0020ull
 

Typedefs

typedef struct ncplane ncdirectv
 
typedef struct ncvisual ncdirectf
 

Functions

API ALLOC struct ncdirectncdirect_init (const char *termtype, FILE *fp, uint64_t flags)
 
API ALLOC struct ncdirectncdirect_core_init (const char *termtype, FILE *fp, uint64_t flags)
 
 __attribute__ ((nonnull(1))) API ALLOC char *ncdirect_readline(struct ncdirect *nc
 
API int ncdirect_set_fg_rgb (struct ncdirect *nc, unsigned rgb) __attribute__((nonnull(1)))
 
API int ncdirect_set_bg_rgb (struct ncdirect *nc, unsigned rgb) __attribute__((nonnull(1)))
 
API int ncdirect_set_fg_palindex (struct ncdirect *nc, int pidx) __attribute__((nonnull(1)))
 
API int ncdirect_set_bg_palindex (struct ncdirect *nc, int pidx) __attribute__((nonnull(1)))
 
API unsigned ncdirect_palette_size (const struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_putstr (struct ncdirect *nc, uint64_t channels, const char *utf8) __attribute__((nonnull(1
 
API int API int ncdirect_putegc (struct ncdirect *nc, uint64_t channels, const char *utf8, int *sbytes) __attribute__((nonnull(1
 
API int API int API int ncdirect_printf_aligned (struct ncdirect *n, int y, ncalign_e align, const char *fmt,...) __attribute__((nonnull(1
 
API int API int API int __attribute__ ((format(printf, 4, 5)))
 
API int ncdirect_flush (const struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_set_fg_default (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_set_bg_default (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API unsigned ncdirect_dim_x (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API unsigned ncdirect_dim_y (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API uint16_t ncdirect_supported_styles (const struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_set_styles (struct ncdirect *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API int ncdirect_on_styles (struct ncdirect *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API int ncdirect_off_styles (struct ncdirect *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API uint16_t ncdirect_styles (const struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_move_yx (struct ncdirect *n, int y, int x) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_enable (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_disable (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_up (struct ncdirect *nc, int num) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_left (struct ncdirect *nc, int num) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_right (struct ncdirect *nc, int num) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_down (struct ncdirect *nc, int num) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_yx (struct ncdirect *n, unsigned *y, unsigned *x) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_push (struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_cursor_pop (struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_clear (struct ncdirect *nc) __attribute__((nonnull(1)))
 
API const nccapabilitiesncdirect_capabilities (const struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_hline_interp (struct ncdirect *n, const char *egc, unsigned len, uint64_t h1, uint64_t h2) __attribute__((nonnull(1
 
API int API int ncdirect_vline_interp (struct ncdirect *n, const char *egc, unsigned len, uint64_t h1, uint64_t h2) __attribute__((nonnull(1
 
API int API int API int ncdirect_box (struct ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, const wchar_t *wchars, unsigned ylen, unsigned xlen, unsigned ctlword) __attribute__((nonnull(1
 
API int ncdirect_rounded_box (struct ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, unsigned ylen, unsigned xlen, unsigned ctlword) __attribute__((nonnull(1)))
 
API int ncdirect_double_box (struct ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, unsigned ylen, unsigned xlen, unsigned ctlword) __attribute__((nonnull(1)))
 
API uint32_t ncdirect_get (struct ncdirect *n, const struct timespec *absdl, ncinput *ni) __attribute__((nonnull(1)))
 
API int ncdirect_inputready_fd (struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_stop (struct ncdirect *nc)
 
API int ncdirect_render_image (struct ncdirect *n, const char *filename, ncalign_e align, ncblitter_e blitter, ncscale_e scale) __attribute__((nonnull(1
 
API int API ALLOC ncdirectvncdirect_render_frame (struct ncdirect *n, const char *filename, ncblitter_e blitter, ncscale_e scale, int maxy, int maxx) __attribute__((nonnull(1
 
API int API ALLOC ncdirectv API int ncdirect_raster_frame (struct ncdirect *n, ncdirectv *ncdv, ncalign_e align) __attribute__((nonnull(1
 
API int API ALLOC ncdirectv API int API ALLOC ncdirectfncdirectf_from_file (struct ncdirect *n, const char *filename) __attribute__((nonnull(1
 
API int API ALLOC ncdirectv API int API ALLOC ncdirectf API void ncdirectf_free (ncdirectf *frame)
 
API ALLOC ncdirectvncdirectf_render (struct ncdirect *n, ncdirectf *frame, const struct ncvisual_options *vopts) __attribute__((nonnull(1
 
API ALLOC ncdirectv API int ncdirectf_geom (struct ncdirect *n, ncdirectf *frame, const struct ncvisual_options *vopts, ncvgeom *geom) __attribute__((nonnull(1
 
API ALLOC ncdirectv API int API int ncdirect_stream (struct ncdirect *n, const char *filename, ncstreamcb streamer, struct ncvisual_options *vopts, void *curry) __attribute__((nonnull(1
 
API ALLOC ncdirectv API int API int ALLOC API char * ncdirect_detected_terminal (const struct ncdirect *n) __attribute__((nonnull(1)))
 
API bool ncdirect_canutf8 (const struct ncdirect *n) __attribute__((nonnull(1)))
 
API int ncdirect_check_pixel_support (const struct ncdirect *n) __attribute__((nonnull(1)))
 
API bool ncdirect_canget_cursor (const struct ncdirect *nc) __attribute__((nonnull(1)))
 

Variables

const char * prompt
 
API int API int API int uint64_t ul
 
API int API int API int uint64_t uint64_t ur
 
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 lr
 
API int API int API int uint64_t uint64_t uint64_t uint64_t unsigned ylen
 
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 unsigned unsigned ctlword
 

Macro Definition Documentation

◆ ALLOC

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

Definition at line 19 of file direct.h.

◆ API

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

Definition at line 15 of file direct.h.

◆ NCDIRECT_OPTION_DRAIN_INPUT

#define NCDIRECT_OPTION_DRAIN_INPUT   0x0004ull

Definition at line 38 of file direct.h.

◆ NCDIRECT_OPTION_INHIBIT_CBREAK

#define NCDIRECT_OPTION_INHIBIT_CBREAK   0x0002ull

Definition at line 33 of file direct.h.

◆ NCDIRECT_OPTION_INHIBIT_SETLOCALE

#define NCDIRECT_OPTION_INHIBIT_SETLOCALE   0x0001ull

Definition at line 29 of file direct.h.

◆ NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS

#define NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS   0x0008ull

Definition at line 43 of file direct.h.

◆ NCDIRECT_OPTION_VERBOSE

#define NCDIRECT_OPTION_VERBOSE   0x0010ull

Definition at line 46 of file direct.h.

◆ NCDIRECT_OPTION_VERY_VERBOSE

#define NCDIRECT_OPTION_VERY_VERBOSE   0x0020ull

Definition at line 50 of file direct.h.

Typedef Documentation

◆ ncdirectf

typedef struct ncvisual ncdirectf

Definition at line 282 of file direct.h.

◆ ncdirectv

typedef struct ncplane ncdirectv

Definition at line 281 of file direct.h.

Function Documentation

◆ __attribute__() [1/2]

static int __attribute__ ( (format(printf, 4, 5))  )

◆ __attribute__() [2/2]

__attribute__ ( (nonnull(1))  )

◆ ncdirect_box()

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

◆ ncdirect_canget_cursor()

API bool ncdirect_canget_cursor ( const struct ncdirect nc)

◆ ncdirect_canutf8()

API bool ncdirect_canutf8 ( const struct ncdirect n)

◆ ncdirect_capabilities()

API const nccapabilities * ncdirect_capabilities ( const struct ncdirect n)

◆ ncdirect_check_pixel_support()

API int ncdirect_check_pixel_support ( const struct ncdirect n)

◆ ncdirect_clear()

API int ncdirect_clear ( struct 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()

API ALLOC struct ncdirect * ncdirect_core_init ( const char *  termtype,
FILE *  fp,
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
return NULL
Definition termdesc.h:229
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()

API int ncdirect_cursor_disable ( struct 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()

API int ncdirect_cursor_down ( struct 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}
#define logerror(fmt,...)
Definition logging.h:32
Here is the caller graph for this function:

◆ ncdirect_cursor_enable()

API int ncdirect_cursor_enable ( struct 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()

API int ncdirect_cursor_left ( struct 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()

API int ncdirect_cursor_move_yx ( struct 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
vopts n
Definition notcurses.h:3506
int int x
Definition notcurses.h:1905
@ ESCAPE_CUP
Definition termdesc.h:45
@ ESCAPE_VPA
Definition termdesc.h:47
@ ESCAPE_U7
Definition termdesc.h:82
@ ESCAPE_HPA
Definition termdesc.h:46
Here is the caller graph for this function:

◆ ncdirect_cursor_pop()

API int ncdirect_cursor_pop ( struct 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()

API int ncdirect_cursor_push ( struct 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()

API int ncdirect_cursor_right ( struct 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()

API int ncdirect_cursor_up ( struct 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()

API int ncdirect_cursor_yx ( struct 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()

API ALLOC ncdirectv API int API int ALLOC API char * ncdirect_detected_terminal ( const struct ncdirect n)

◆ ncdirect_dim_x()

API unsigned ncdirect_dim_x ( struct 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()

API unsigned ncdirect_dim_y ( struct 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()

API int ncdirect_double_box ( struct 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
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 NCBOXDOUBLEW
Definition ncseqs.h:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_flush()

API int ncdirect_flush ( const struct ncdirect nc)
Here is the call graph for this function:

◆ ncdirect_get()

API uint32_t ncdirect_get ( struct ncdirect n,
const struct timespec *  absdl,
ncinput ni 
)

Definition at line 2798 of file in.c.

2798 {
2799 if(n->eof){
2800 logerror("already got EOF");
2801 return -1;
2802 }
2803 uint32_t r = internal_get(n->tcache.ictx, absdl, ni);
2804 if(r == NCKEY_EOF){
2805 n->eof = 1;
2806 }
2807 return r;
2808}
int r
Definition fbuf.h:226
#define NCKEY_EOF
Definition nckeys.h:183
Here is the caller graph for this function:

◆ ncdirect_hline_interp()

API int ncdirect_hline_interp ( struct ncdirect n,
const char *  egc,
unsigned  len,
uint64_t  h1,
uint64_t  h2 
)

◆ ncdirect_init()

API ALLOC struct ncdirect * ncdirect_init ( const char *  termtype,
FILE *  fp,
uint64_t  flags 
)
Here is the caller graph for this function:

◆ ncdirect_inputready_fd()

API int ncdirect_inputready_fd ( struct ncdirect n)

Definition at line 3100 of file notcurses.c.

3100 {
3101 return inputready_fd(n->tcache.ictx);
3102}
int inputready_fd(const inputctx *ictx)
Definition in.c:2672
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_off_styles()

API int ncdirect_off_styles ( struct 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()

API int ncdirect_on_styles ( struct 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()

API unsigned ncdirect_palette_size ( const struct ncdirect nc)

◆ ncdirect_printf_aligned()

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

◆ ncdirect_putegc()

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

◆ ncdirect_putstr()

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

◆ ncdirect_raster_frame()

API int API ALLOC ncdirectv API int ncdirect_raster_frame ( struct ncdirect n,
ncdirectv ncdv,
ncalign_e  align 
)

◆ ncdirect_render_frame()

API int API ALLOC ncdirectv * ncdirect_render_frame ( struct ncdirect n,
const char *  filename,
ncblitter_e  blitter,
ncscale_e  scale,
int  maxy,
int  maxx 
)

◆ ncdirect_render_image()

API int ncdirect_render_image ( struct ncdirect n,
const char *  filename,
ncalign_e  align,
ncblitter_e  blitter,
ncscale_e  scale 
)

◆ ncdirect_rounded_box()

API int ncdirect_rounded_box ( struct 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()

API int ncdirect_set_bg_default ( struct 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()

API int ncdirect_set_bg_palindex ( struct 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_bg_rgb()

API int ncdirect_set_bg_rgb ( struct ncdirect nc,
unsigned  rgb 
)

Definition at line 1667 of file render.c.

1667 {
1668 fbuf f = {0};
1669 if(fbuf_init_small(&f)){
1670 return -1;
1671 }
1672 if(ncdirect_set_bg_rgb_f(nc, rgb, &f)){
1673 fbuf_free(&f);
1674 return -1;
1675 }
1676 if(fbuf_finalize(&f, nc->ttyfp) < 0){
1677 return -1;
1678 }
1679 return 0;
1680}
int ncdirect_set_bg_rgb_f(ncdirect *nc, unsigned rgb, fbuf *f)
Definition render.c:1652
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_fg_default()

API int ncdirect_set_fg_default ( struct 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()

API int ncdirect_set_fg_palindex ( struct 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_fg_rgb()

API int ncdirect_set_fg_rgb ( struct ncdirect nc,
unsigned  rgb 
)

Definition at line 1697 of file render.c.

1697 {
1698 fbuf f = {0};
1699 if(fbuf_init_small(&f)){
1700 return -1;
1701 }
1702 if(ncdirect_set_fg_rgb_f(nc, rgb, &f)){
1703 fbuf_free(&f);
1704 return -1;
1705 }
1706 if(fbuf_finalize(&f, nc->ttyfp) < 0){
1707 return -1;
1708 }
1709 return 0;
1710}
int ncdirect_set_fg_rgb_f(ncdirect *nc, unsigned rgb, fbuf *f)
Definition render.c:1682
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncdirect_set_styles()

API int ncdirect_set_styles ( struct 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()

API int ncdirect_stop ( struct 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()

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

◆ ncdirect_styles()

API uint16_t ncdirect_styles ( const struct ncdirect n)

◆ ncdirect_supported_styles()

API uint16_t ncdirect_supported_styles ( const struct ncdirect nc)

◆ ncdirect_vline_interp()

API int API int ncdirect_vline_interp ( struct ncdirect n,
const char *  egc,
unsigned  len,
uint64_t  h1,
uint64_t  h2 
)

◆ ncdirectf_free()

API int API ALLOC ncdirectv API int API ALLOC ncdirectf API void ncdirectf_free ( ncdirectf frame)

Definition at line 1600 of file direct.c.

1600 {
1601 ncvisual_destroy(frame);
1602}
void ncvisual_destroy(ncvisual *ncv)
Definition visual.c:1231
Here is the call graph for this function:

◆ ncdirectf_from_file()

API int API ALLOC ncdirectv API int API ALLOC ncdirectf * ncdirectf_from_file ( struct ncdirect n,
const char *  filename 
)

◆ ncdirectf_geom()

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

◆ ncdirectf_render()

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

Variable Documentation

◆ ctlword

uint64_t uint64_t uint64_t uint64_t unsigned unsigned unsigned ctlword
Initial value:
{
API int API int API int ncdirect_box(struct ncdirect *n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, const wchar_t *wchars, unsigned ylen, unsigned xlen, unsigned ctlword) __attribute__((nonnull(1
#define NCBOXLIGHTW
Definition ncseqs.h:9

Definition at line 217 of file direct.h.

◆ ll

uint64_t uint64_t uint64_t ll

Definition at line 216 of file direct.h.

◆ lr

uint64_t uint64_t uint64_t uint64_t lr

Definition at line 216 of file direct.h.

◆ prompt

const char* prompt

Definition at line 68 of file direct.h.

◆ ul

uint64_t ul

Definition at line 215 of file direct.h.

◆ ur

uint64_t uint64_t ur

Definition at line 215 of file direct.h.

◆ xlen

uint64_t uint64_t uint64_t uint64_t unsigned unsigned xlen

Definition at line 217 of file direct.h.

◆ ylen

uint64_t uint64_t uint64_t uint64_t unsigned ylen

Definition at line 217 of file direct.h.