Notcurses 3.0.13
a blingful library for TUIs and character graphics
Loading...
Searching...
No Matches
notcurses.h File Reference
#include <time.h>
#include <ctype.h>
#include <wchar.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <stdbool.h>
#include <notcurses/ncport.h>
#include <notcurses/nckeys.h>
#include <notcurses/ncseqs.h>
Include dependency graph for notcurses.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nccell
 
struct  notcurses_options
 
struct  ncinput
 
struct  ncplane_options
 
struct  ncpalette
 
struct  nccapabilities
 
struct  ncstats
 
struct  ncvisual_options
 
struct  ncvgeom
 
struct  ncreel_options
 
struct  ncselector_item
 
struct  ncselector_options
 
struct  ncmselector_item
 
struct  ncmultiselector_options
 
struct  nctree_item
 
struct  nctree_options
 
struct  ncmenu_item
 
struct  ncmenu_section
 
struct  ncmenu_options
 
struct  ncprogbar_options
 
struct  nctabbed_options
 
struct  ncplot_options
 
struct  ncfdplane_options
 
struct  ncsubproc_options
 
struct  ncreader_options
 

Macros

#define RESTRICT   restrict
 
#define API   __attribute__((visibility("default")))
 
#define ALLOC   __attribute__((malloc)) __attribute__((warn_unused_result))
 
#define NCALIGN_TOP   NCALIGN_LEFT
 
#define NCALIGN_BOTTOM   NCALIGN_RIGHT
 
#define NCALPHA_HIGHCONTRAST   0x30000000ull
 
#define NCALPHA_TRANSPARENT   0x20000000ull
 
#define NCALPHA_BLEND   0x10000000ull
 
#define NCALPHA_OPAQUE   0x00000000ull
 
#define NCPALETTESIZE   256
 
#define NC_NOBACKGROUND_MASK   0x8700000000000000ull
 
#define NC_BGDEFAULT_MASK   0x0000000040000000ull
 
#define NC_BG_RGB_MASK   0x0000000000ffffffull
 
#define NC_BG_PALETTE   0x0000000008000000ull
 
#define NC_BG_ALPHA_MASK   0x30000000ull
 
#define NCCHANNEL_INITIALIZER(r, g, b)    (((uint32_t)(r) << 16u) + ((uint32_t)(g) << 8u) + (b) + NC_BGDEFAULT_MASK)
 
#define NCCHANNELS_INITIALIZER(fr, fg, fb, br, bg, bb)
 
#define WCHAR_MAX_UTF8BYTES   4
 
#define NCCELL_INITIALIZER(c, s, chan)
 
#define NCCELL_CHAR_INITIALIZER(c)
 
#define NCCELL_TRIVIAL_INITIALIZER
 
#define NCSTYLE_MASK   0xffffu
 
#define NCSTYLE_ITALIC   0x0010u
 
#define NCSTYLE_UNDERLINE   0x0008u
 
#define NCSTYLE_UNDERCURL   0x0004u
 
#define NCSTYLE_BOLD   0x0002u
 
#define NCSTYLE_STRUCK   0x0001u
 
#define NCSTYLE_NONE   0
 
#define NCOPTION_INHIBIT_SETLOCALE   0x0001ull
 
#define NCOPTION_NO_CLEAR_BITMAPS   0x0002ull
 
#define NCOPTION_NO_WINCH_SIGHANDLER   0x0004ull
 
#define NCOPTION_NO_QUIT_SIGHANDLERS   0x0008ull
 
#define NCOPTION_PRESERVE_CURSOR   0x0010ull
 
#define NCOPTION_SUPPRESS_BANNERS   0x0020ull
 
#define NCOPTION_NO_ALTERNATE_SCREEN   0x0040ull
 
#define NCOPTION_NO_FONT_CHANGES   0x0080ull
 
#define NCOPTION_DRAIN_INPUT   0x0100ull
 
#define NCOPTION_SCROLLING   0x0200ull
 
#define NCOPTION_CLI_MODE
 
#define NCINPUT_MAX_EFF_TEXT_CODEPOINTS   4
 
#define NCMICE_NO_EVENTS   0
 
#define NCMICE_MOVE_EVENT   0x1
 
#define NCMICE_BUTTON_EVENT   0x2
 
#define NCMICE_DRAG_EVENT   0x4
 
#define NCMICE_ALL_EVENTS   0x7
 
#define NCPLANE_OPTION_HORALIGNED   0x0001ull
 
#define NCPLANE_OPTION_VERALIGNED   0x0002ull
 
#define NCPLANE_OPTION_MARGINALIZED   0x0004ull
 
#define NCPLANE_OPTION_FIXED   0x0008ull
 
#define NCPLANE_OPTION_AUTOGROW   0x0010ull
 
#define NCPLANE_OPTION_VSCROLL   0x0020ull
 
#define NCBOXMASK_TOP   0x0001
 
#define NCBOXMASK_RIGHT   0x0002
 
#define NCBOXMASK_BOTTOM   0x0004
 
#define NCBOXMASK_LEFT   0x0008
 
#define NCBOXGRAD_TOP   0x0010
 
#define NCBOXGRAD_RIGHT   0x0020
 
#define NCBOXGRAD_BOTTOM   0x0040
 
#define NCBOXGRAD_LEFT   0x0080
 
#define NCBOXCORNER_MASK   0x0300
 
#define NCBOXCORNER_SHIFT   8u
 
#define NCVISUAL_OPTION_NODEGRADE   0x0001ull
 
#define NCVISUAL_OPTION_BLEND   0x0002ull
 
#define NCVISUAL_OPTION_HORALIGNED   0x0004ull
 
#define NCVISUAL_OPTION_VERALIGNED   0x0008ull
 
#define NCVISUAL_OPTION_ADDALPHA   0x0010ull
 
#define NCVISUAL_OPTION_CHILDPLANE   0x0020ull
 
#define NCVISUAL_OPTION_NOINTERPOLATE   0x0040ull
 
#define NCREEL_OPTION_INFINITESCROLL   0x0001ull
 
#define NCREEL_OPTION_CIRCULAR   0x0002ull
 
#define NCPREFIXCOLUMNS   7
 
#define NCIPREFIXCOLUMNS   8
 
#define NCBPREFIXCOLUMNS   9
 
#define NCPREFIXSTRLEN   (NCPREFIXCOLUMNS + 1)
 
#define NCIPREFIXSTRLEN   (NCIPREFIXCOLUMNS + 1)
 
#define NCBPREFIXSTRLEN   (NCBPREFIXCOLUMNS + 1)
 
#define NCMETRICFWIDTH(x, cols)    ((int)(strlen(x) - ncstrwidth(x, NULL, NULL) + (cols)))
 
#define NCPREFIXFMT(x)   NCMETRICFWIDTH((x), NCPREFIXCOLUMNS), (x)
 
#define NCIPREFIXFMT(x)   NCMETRICFWIDTH((x), NCIPREFIXCOLUMNS), (x)
 
#define NCBPREFIXFMT(x)   NCMETRICFWIDTH((x), NCBPREFIXCOLUMNS), (x)
 
#define NCMENU_OPTION_BOTTOM   0x0001ull
 
#define NCMENU_OPTION_HIDING   0x0002ull
 
#define NCPROGBAR_OPTION_RETROGRADE   0x0001u
 
#define NCTABBED_OPTION_BOTTOM   0x0001ull
 
#define NCPLOT_OPTION_LABELTICKSD   0x0001u
 
#define NCPLOT_OPTION_EXPONENTIALD   0x0002u
 
#define NCPLOT_OPTION_VERTICALI   0x0004u
 
#define NCPLOT_OPTION_NODEGRADE   0x0008u
 
#define NCPLOT_OPTION_DETECTMAXONLY   0x0010u
 
#define NCPLOT_OPTION_PRINTSAMPLE   0x0020u
 
#define NCREADER_OPTION_HORSCROLL   0x0001ull
 
#define NCREADER_OPTION_VERSCROLL   0x0002ull
 
#define NCREADER_OPTION_NOCMDKEYS   0x0004ull
 
#define NCREADER_OPTION_CURSOR   0x0008ull
 

Typedefs

typedef API int struct nccell nccell
 
typedef struct notcurses_options notcurses_options
 
typedef struct ncinput ncinput
 
typedef struct ncplane_options ncplane_options
 
typedef struct ncpalette ncpalette
 
typedef struct nccapabilities nccapabilities
 
typedef struct ncstats ncstats
 
typedef int(* fadecb) (struct notcurses *nc, struct ncplane *n, const struct timespec *, void *curry)
 
typedef struct ncvgeom ncvgeom
 
typedef int(* ncstreamcb) (struct ncvisual *, struct ncvisual_options *, const struct timespec *, void *)
 
typedef struct ncreel_options ncreel_options
 
typedef int(* tabletcb) (struct nctablet *t, bool drawfromtop)
 
typedef struct ncselector_options ncselector_options
 
typedef struct ncmultiselector_options ncmultiselector_options
 
typedef struct nctree_options nctree_options
 
typedef struct ncmenu_options ncmenu_options
 
typedef struct ncprogbar_options ncprogbar_options
 
typedef struct nctabbed_options nctabbed_options
 
typedef void(* tabcb) (struct nctab *t, struct ncplane *ncp, void *curry)
 
typedef struct ncplot_options ncplot_options
 
typedef int(* ncfdplane_callback) (struct ncfdplane *n, const void *buf, size_t s, void *curry)
 
typedef int(* ncfdplane_done_cb) (struct ncfdplane *n, int fderrno, void *curry)
 
typedef struct ncfdplane_options ncfdplane_options
 
typedef struct ncsubproc_options ncsubproc_options
 
typedef struct ncreader_options ncreader_options
 

Enumerations

enum  ncblitter_e {
  NCBLIT_DEFAULT , NCBLIT_1x1 , NCBLIT_2x1 , NCBLIT_2x2 ,
  NCBLIT_3x2 , NCBLIT_4x2 , NCBLIT_BRAILLE , NCBLIT_PIXEL ,
  NCBLIT_4x1 , NCBLIT_8x1
}
 
enum  ncalign_e { NCALIGN_UNALIGNED , NCALIGN_LEFT , NCALIGN_CENTER , NCALIGN_RIGHT }
 
enum  ncscale_e {
  NCSCALE_NONE , NCSCALE_SCALE , NCSCALE_STRETCH , NCSCALE_NONE_HIRES ,
  NCSCALE_SCALE_HIRES
}
 
enum  ncloglevel_e {
  NCLOGLEVEL_SILENT = -1 , NCLOGLEVEL_PANIC = 0 , NCLOGLEVEL_FATAL = 1 , NCLOGLEVEL_ERROR = 2 ,
  NCLOGLEVEL_WARNING = 3 , NCLOGLEVEL_INFO = 4 , NCLOGLEVEL_VERBOSE = 5 , NCLOGLEVEL_DEBUG = 6 ,
  NCLOGLEVEL_TRACE = 7
}
 
enum  ncintype_e { NCTYPE_UNKNOWN , NCTYPE_PRESS , NCTYPE_REPEAT , NCTYPE_RELEASE }
 
enum  ncpixelimpl_e {
  NCPIXEL_NONE = 0 , NCPIXEL_SIXEL , NCPIXEL_LINUXFB , NCPIXEL_ITERM2 ,
  NCPIXEL_KITTY_STATIC , NCPIXEL_KITTY_ANIMATED , NCPIXEL_KITTY_SELFREF
}
 

Functions

API const char * notcurses_version (void)
 
API void notcurses_version_components (int *major, int *minor, int *patch, int *tweak)
 
API int ncstrwidth (const char *egcs, int *validbytes, int *validwidth) __attribute__((nonnull(1)))
 
API int notcurses_ucs32_to_utf8 (const uint32_t *ucs32, unsigned ucs32count, unsigned char *resultbuf, size_t buflen) __attribute__((nonnull(1
 
API int nccell_load (struct ncplane *n, nccell *c, const char *gcluster)
 
API int nccell_duplicate (struct ncplane *n, nccell *targ, const nccell *c)
 
API void nccell_release (struct ncplane *n, nccell *c)
 
API __attribute__ ((returns_nonnull)) const char *nccell_extended_gcluster(const struct ncplane *n
 
API int notcurses_lex_margins (const char *op, notcurses_options *opts) __attribute__((nonnull(1)))
 
API int notcurses_lex_blitter (const char *op, ncblitter_e *blitter) __attribute__((nonnull(1)))
 
API const char * notcurses_str_blitter (ncblitter_e blitter)
 
API int notcurses_lex_scalemode (const char *op, ncscale_e *scalemode) __attribute__((nonnull(1)))
 
API const char * notcurses_str_scalemode (ncscale_e scalemode)
 
API ALLOC struct notcursesnotcurses_init (const notcurses_options *opts, FILE *fp)
 
API ALLOC struct notcursesnotcurses_core_init (const notcurses_options *opts, FILE *fp)
 
API int notcurses_stop (struct notcurses *nc)
 
API int notcurses_enter_alternate_screen (struct notcurses *nc) __attribute__((nonnull(1)))
 
API int notcurses_leave_alternate_screen (struct notcurses *nc) __attribute__((nonnull(1)))
 
API struct ncplanenotcurses_stdplane (struct notcurses *nc) __attribute__((nonnull(1)))
 
API const struct ncplanenotcurses_stdplane_const (const struct notcurses *nc) __attribute__((nonnull(1)))
 
API struct ncplanencpile_top (struct ncplane *n) __attribute__((nonnull(1)))
 
API struct ncplanencpile_bottom (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncpile_render (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncpile_rasterize (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncpile_render_to_buffer (struct ncplane *p, char **buf, size_t *buflen) __attribute__((nonnull(1
 
API int API int ncpile_render_to_file (struct ncplane *p, FILE *fp) __attribute__((nonnull(1
 
API int API int API void notcurses_drop_planes (struct notcurses *nc) __attribute__((nonnull(1)))
 
API uint32_t notcurses_get (struct notcurses *n, const struct timespec *ts, ncinput *ni) __attribute__((nonnull(1)))
 
API int notcurses_getvec (struct notcurses *n, const struct timespec *ts, ncinput *ni, int vcount) __attribute__((nonnull(1
 
API int API int notcurses_inputready_fd (struct notcurses *n) __attribute__((nonnull(1)))
 
API int notcurses_mice_enable (struct notcurses *n, unsigned eventmask) __attribute__((nonnull(1)))
 
 __attribute__ ((nonnull(1))) static inline int notcurses_mice_disable(struct notcurses *n)
 
API int notcurses_linesigs_disable (struct notcurses *n) __attribute__((nonnull(1)))
 
API int notcurses_linesigs_enable (struct notcurses *n) __attribute__((nonnull(1)))
 
API int notcurses_refresh (struct notcurses *n, unsigned *RESTRICT y, unsigned *RESTRICT x) __attribute__((nonnull(1)))
 
API struct notcursesncplane_notcurses (const struct ncplane *n) __attribute__((nonnull(1)))
 
API const struct notcursesncplane_notcurses_const (const struct ncplane *n) __attribute__((nonnull(1)))
 
API void ncplane_dim_yx (const struct ncplane *n, unsigned *RESTRICT y, unsigned *RESTRICT x) __attribute__((nonnull(1)))
 
API void ncplane_pixel_geom (const struct ncplane *n, unsigned *RESTRICT pxy, unsigned *RESTRICT pxx, unsigned *RESTRICT celldimy, unsigned *RESTRICT celldimx, unsigned *RESTRICT maxbmapy, unsigned *RESTRICT maxbmapx) __attribute__((nonnull(1)))
 
API char * notcurses_at_yx (struct notcurses *nc, unsigned yoff, unsigned xoff, uint16_t *stylemask, uint64_t *channels) __attribute__((nonnull(1)))
 
API ALLOC struct ncplanencplane_create (struct ncplane *n, const ncplane_options *nopts) __attribute__((nonnull(1
 
API ALLOC struct ncplane API ALLOC struct ncplanencpile_create (struct notcurses *nc, const ncplane_options *nopts) __attribute__((nonnull(1
 
API ALLOC struct ncplane API ALLOC struct ncplane API int ncplane_resize_maximize (struct ncplane *n)
 
API int ncplane_resize_marginalized (struct ncplane *n)
 
API int ncplane_resize_realign (struct ncplane *n)
 
API int ncplane_resize_placewithin (struct ncplane *n)
 
API void ncplane_set_resizecb (struct ncplane *n, int(*resizecb)(struct ncplane *))
 
API int ncplane_set_name (struct ncplane *n, const char *name) __attribute__((nonnull(1)))
 
API ALLOC char * ncplane_name (const struct ncplane *n) __attribute__((nonnull(1)))
 
API struct ncplanencplane_reparent (struct ncplane *n, struct ncplane *newparent) __attribute__((nonnull(1
 
API struct ncplane API struct ncplanencplane_reparent_family (struct ncplane *n, struct ncplane *newparent) __attribute__((nonnull(1
 
API struct ncplane API struct ncplane API ALLOC struct ncplanencplane_dup (const struct ncplane *n, void *opaque) __attribute__((nonnull(1)))
 
API void ncplane_translate (const struct ncplane *src, const struct ncplane *dst, int *RESTRICT y, int *RESTRICT x) __attribute__((nonnull(1)))
 
API bool ncplane_translate_abs (const struct ncplane *n, int *RESTRICT y, int *RESTRICT x) __attribute__((nonnull(1)))
 
API bool ncplane_set_scrolling (struct ncplane *n, unsigned scrollp) __attribute__((nonnull(1)))
 
API bool ncplane_scrolling_p (const struct ncplane *n) __attribute__((nonnull(1)))
 
API bool ncplane_set_autogrow (struct ncplane *n, unsigned growp) __attribute__((nonnull(1)))
 
API bool ncplane_autogrow_p (const struct ncplane *n) __attribute__((nonnull(1)))
 
API ALLOC ncpalettencpalette_new (struct notcurses *nc) __attribute__((nonnull(1)))
 
API int ncpalette_use (struct notcurses *nc, const ncpalette *p) __attribute__((nonnull(1
 
API void ncpalette_free (ncpalette *p)
 
API uint16_t notcurses_supported_styles (const struct notcurses *nc) __attribute__((nonnull(1))) __attribute__((pure))
 
API unsigned notcurses_palette_size (const struct notcurses *nc) __attribute__((nonnull(1))) __attribute__((pure))
 
ALLOC API char * notcurses_detected_terminal (const struct notcurses *nc) __attribute__((nonnull(1)))
 
API const nccapabilitiesnotcurses_capabilities (const struct notcurses *n) __attribute__((nonnull(1)))
 
API ncpixelimpl_e notcurses_check_pixel_support (const struct notcurses *nc) __attribute__((nonnull(1))) __attribute__((pure))
 
API bool notcurses_canopen_images (const struct notcurses *nc) __attribute__((pure))
 
API bool notcurses_canopen_videos (const struct notcurses *nc) __attribute__((pure))
 
API ALLOC ncstatsnotcurses_stats_alloc (const struct notcurses *nc __attribute__((unused))) __attribute__((nonnull(1)))
 
API void notcurses_stats (struct notcurses *nc, ncstats *stats) __attribute__((nonnull(1
 
API void API void notcurses_stats_reset (struct notcurses *nc, ncstats *stats) __attribute__((nonnull(1)))
 
API int ncplane_resize (struct ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
 
API int ncplane_destroy (struct ncplane *n)
 
API int ncplane_set_base_cell (struct ncplane *n, const nccell *c)
 
API int ncplane_set_base (struct ncplane *n, const char *egc, uint16_t stylemask, uint64_t channels)
 
API int ncplane_base (struct ncplane *n, nccell *c)
 
API void ncplane_yx (const struct ncplane *n, int *RESTRICT y, int *RESTRICT x) __attribute__((nonnull(1)))
 
API int ncplane_y (const struct ncplane *n) __attribute__((pure))
 
API int ncplane_x (const struct ncplane *n) __attribute__((pure))
 
API int ncplane_move_yx (struct ncplane *n, int y, int x)
 
 ncplane_yx (n, &oy, &ox)
 
return ncplane_move_yx (n, oy+y, ox+x)
 
API void ncplane_abs_yx (const struct ncplane *n, int *RESTRICT y, int *RESTRICT x) __attribute__((nonnull(1)))
 
API int ncplane_abs_y (const struct ncplane *n) __attribute__((pure))
 
API int ncplane_abs_x (const struct ncplane *n) __attribute__((pure))
 
API struct ncplanencplane_parent (struct ncplane *n) __attribute__((nonnull(1)))
 
API const struct ncplanencplane_parent_const (const struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncplane_move_above (struct ncplane *RESTRICT n, struct ncplane *RESTRICT above) __attribute__((nonnull(1)))
 
API int ncplane_move_below (struct ncplane *RESTRICT n, struct ncplane *RESTRICT below) __attribute__((nonnull(1)))
 
API int ncplane_move_family_above (struct ncplane *n, struct ncplane *targ) __attribute__((nonnull(1)))
 
API int ncplane_move_family_below (struct ncplane *n, struct ncplane *targ) __attribute__((nonnull(1)))
 
API struct ncplanencplane_below (struct ncplane *n) __attribute__((nonnull(1)))
 
API struct ncplanencplane_above (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncplane_scrollup (struct ncplane *n, int r) __attribute__((nonnull(1)))
 
API int ncplane_scrollup_child (struct ncplane *n, const struct ncplane *child) __attribute__((nonnull(1
 
API int API int ncplane_rotate_cw (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncplane_rotate_ccw (struct ncplane *n) __attribute__((nonnull(1)))
 
API char * ncplane_at_cursor (const struct ncplane *n, uint16_t *stylemask, uint64_t *channels) __attribute__((nonnull(1)))
 
API int ncplane_at_cursor_cell (struct ncplane *n, nccell *c) __attribute__((nonnull(1
 
API int API char * ncplane_at_yx (const struct ncplane *n, int y, int x, uint16_t *stylemask, uint64_t *channels) __attribute__((nonnull(1)))
 
API int ncplane_at_yx_cell (struct ncplane *n, int y, int x, nccell *c) __attribute__((nonnull(1
 
API int API char * ncplane_contents (struct ncplane *n, int begy, int begx, unsigned leny, unsigned lenx) __attribute__((nonnull(1)))
 
API void * ncplane_set_userptr (struct ncplane *n, void *opaque) __attribute__((nonnull(1)))
 
API void * ncplane_userptr (struct ncplane *n) __attribute__((nonnull(1)))
 
API void ncplane_center_abs (const struct ncplane *n, int *RESTRICT y, int *RESTRICT x) __attribute__((nonnull(1)))
 
API ALLOC uint32_t * ncplane_as_rgba (const struct ncplane *n, ncblitter_e blit, int begy, int begx, unsigned leny, unsigned lenx, unsigned *pxdimy, unsigned *pxdimx) __attribute__((nonnull(1)))
 
API int ncplane_cursor_move_yx (struct ncplane *n, int y, int x) __attribute__((nonnull(1)))
 
API int ncplane_cursor_move_rel (struct ncplane *n, int y, int x) __attribute__((nonnull(1)))
 
API void ncplane_home (struct ncplane *n) __attribute__((nonnull(1)))
 
API void ncplane_cursor_yx (const struct ncplane *n, unsigned *RESTRICT y, unsigned *RESTRICT x) __attribute__((nonnull(1)))
 
API uint64_t ncplane_channels (const struct ncplane *n) __attribute__((nonnull(1)))
 
API uint16_t ncplane_styles (const struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncplane_putc_yx (struct ncplane *n, int y, int x, const nccell *c) __attribute__((nonnull(1
 
API int ncplane_putchar_stained (struct ncplane *n, char c) __attribute__((nonnull(1)))
 
API int ncplane_putegc_yx (struct ncplane *n, int y, int x, const char *gclust, size_t *sbytes) __attribute__((nonnull(1
 
API int ncplane_putegc_stained (struct ncplane *n, const char *gclust, size_t *sbytes) __attribute__((nonnull(1
 
API int ncplane_putwegc_stained (struct ncplane *n, const wchar_t *gclust, size_t *sbytes) __attribute__((nonnull(1
 
API int ncplane_putnstr_aligned (struct ncplane *n, int y, ncalign_e align, size_t s, const char *str) __attribute__((nonnull(1
 
API int ncplane_putwstr_stained (struct ncplane *n, const wchar_t *gclustarr) __attribute__((nonnull(1
 
API int ncplane_vprintf_aligned (struct ncplane *n, int y, ncalign_e align, const char *format, va_list ap) __attribute__((nonnull(1
 
API int __attribute__ ((format(printf, 4, 0)))
 
API int ncplane_vprintf_yx (struct ncplane *n, int y, int x, const char *format, va_list ap) __attribute__((nonnull(1
 
API int ncplane_vprintf_stained (struct ncplane *n, const char *format, va_list ap) __attribute__((nonnull(1
 
API int __attribute__ ((format(printf, 2, 0)))
 
static int __attribute__ ((format(printf, 2, 3)))
 
static int __attribute__ ((format(printf, 4, 5)))
 
API int ncplane_puttext (struct ncplane *n, int y, ncalign_e align, const char *text, size_t *bytes) __attribute__((nonnull(1
 
API int API int ncplane_hline_interp (struct ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2) __attribute__((nonnull(1
 
API int API int __attribute__ ((nonnull(1, 2))) static inline int ncplane_hline(struct ncplane *n
 
API int ncplane_vline_interp (struct ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2) __attribute__((nonnull(1
 
API int ncplane_box (struct ncplane *n, const nccell *ul, const nccell *ur, const nccell *ll, const nccell *lr, const nccell *hline, const nccell *vline, unsigned ystop, unsigned xstop, unsigned ctlword)
 
API int ncplane_polyfill_yx (struct ncplane *n, int y, int x, const nccell *c) __attribute__((nonnull(1
 
API int API int ncplane_gradient (struct ncplane *n, int y, int x, unsigned ylen, unsigned xlen, const char *egc, uint16_t styles, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) __attribute__((nonnull(1
 
API int API int API int ncplane_gradient2x1 (struct ncplane *n, int y, int x, unsigned ylen, unsigned xlen, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr) __attribute__((nonnull(1)))
 
API int ncplane_format (struct ncplane *n, int y, int x, unsigned ylen, unsigned xlen, uint16_t stylemask) __attribute__((nonnull(1)))
 
API int ncplane_stain (struct ncplane *n, int y, int x, unsigned ylen, unsigned xlen, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) __attribute__((nonnull(1)))
 
API int ncplane_mergedown_simple (struct ncplane *RESTRICT src, struct ncplane *RESTRICT dst) __attribute__((nonnull(1
 
API int API int ncplane_mergedown (struct ncplane *RESTRICT src, struct ncplane *RESTRICT dst, int begsrcy, int begsrcx, unsigned leny, unsigned lenx, int dsty, int dstx) __attribute__((nonnull(1
 
API int API int API void ncplane_erase (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncplane_erase_region (struct ncplane *n, int ystart, int xstart, int ylen, int xlen) __attribute__((nonnull(1)))
 
API void ncplane_set_channels (struct ncplane *n, uint64_t channels) __attribute__((nonnull(1)))
 
API uint64_t ncplane_set_bchannel (struct ncplane *n, uint32_t channel) __attribute__((nonnull(1)))
 
API uint64_t ncplane_set_fchannel (struct ncplane *n, uint32_t channel) __attribute__((nonnull(1)))
 
API void ncplane_set_styles (struct ncplane *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API void ncplane_on_styles (struct ncplane *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API void ncplane_off_styles (struct ncplane *n, unsigned stylebits) __attribute__((nonnull(1)))
 
API int ncplane_set_fg_rgb8 (struct ncplane *n, unsigned r, unsigned g, unsigned b)
 
API int ncplane_set_bg_rgb8 (struct ncplane *n, unsigned r, unsigned g, unsigned b)
 
API void ncplane_set_bg_rgb8_clipped (struct ncplane *n, int r, int g, int b)
 
API void ncplane_set_fg_rgb8_clipped (struct ncplane *n, int r, int g, int b)
 
API int ncplane_set_fg_rgb (struct ncplane *n, uint32_t channel)
 
API int ncplane_set_bg_rgb (struct ncplane *n, uint32_t channel)
 
API void ncplane_set_fg_default (struct ncplane *n)
 
API void ncplane_set_bg_default (struct ncplane *n)
 
API int ncplane_set_fg_palindex (struct ncplane *n, unsigned idx)
 
API int ncplane_set_bg_palindex (struct ncplane *n, unsigned idx)
 
API int ncplane_set_fg_alpha (struct ncplane *n, int alpha)
 
API int ncplane_set_bg_alpha (struct ncplane *n, int alpha)
 
API int ncplane_fadeout (struct ncplane *n, const struct timespec *ts, fadecb fader, void *curry) __attribute__((nonnull(1)))
 
API int ncplane_fadein (struct ncplane *n, const struct timespec *ts, fadecb fader, void *curry) __attribute__((nonnull(1)))
 
API ALLOC struct ncfadectxncfadectx_setup (struct ncplane *n) __attribute__((nonnull(1)))
 
API int ncfadectx_iterations (const struct ncfadectx *nctx) __attribute__((nonnull(1)))
 
API int ncplane_fadeout_iteration (struct ncplane *n, struct ncfadectx *nctx, int iter, fadecb fader, void *curry) __attribute__((nonnull(1
 
API int API int ncplane_fadein_iteration (struct ncplane *n, struct ncfadectx *nctx, int iter, fadecb fader, void *curry) __attribute__((nonnull(1
 
API int API int API int ncplane_pulse (struct ncplane *n, const struct timespec *ts, fadecb fader, void *curry) __attribute__((nonnull(1)))
 
API void ncfadectx_free (struct ncfadectx *nctx)
 
API ALLOC struct ncvisualncvisual_from_file (const char *file) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_rgba (const void *rgba, int rows, int rowstride, int cols) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_rgb_packed (const void *rgba, int rows, int rowstride, int cols, int alpha) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_rgb_loose (const void *rgba, int rows, int rowstride, int cols, int alpha) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_bgra (const void *bgra, int rows, int rowstride, int cols) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_palidx (const void *data, int rows, int rowstride, int cols, int palsize, int pstride, const uint32_t *palette) __attribute__((nonnull(1
 
API ALLOC struct ncvisual API ALLOC struct ncvisualncvisual_from_plane (const struct ncplane *n, ncblitter_e blit, int begy, int begx, unsigned leny, unsigned lenx) __attribute__((nonnull(1)))
 
API ALLOC struct ncvisualncvisual_from_sixel (const char *s, unsigned leny, unsigned lenx) __attribute__((nonnull(1)))
 
API int ncvisual_geom (const struct notcurses *nc, const struct ncvisual *n, const struct ncvisual_options *vopts, ncvgeom *geom) __attribute__((nonnull(4)))
 
API void ncvisual_destroy (struct ncvisual *ncv)
 
API int ncvisual_decode (struct ncvisual *nc) __attribute__((nonnull(1)))
 
API int ncvisual_decode_loop (struct ncvisual *nc) __attribute__((nonnull(1)))
 
API int ncvisual_rotate (struct ncvisual *n, double rads) __attribute__((nonnull(1)))
 
API int ncvisual_resize (struct ncvisual *n, int rows, int cols) __attribute__((nonnull(1)))
 
API int ncvisual_resize_noninterpolative (struct ncvisual *n, int rows, int cols) __attribute__((nonnull(1)))
 
API int ncvisual_polyfill_yx (struct ncvisual *n, unsigned y, unsigned x, uint32_t rgba) __attribute__((nonnull(1)))
 
API int ncvisual_at_yx (const struct ncvisual *n, unsigned y, unsigned x, uint32_t *pixel) __attribute__((nonnull(1
 
API int API int ncvisual_set_yx (const struct ncvisual *n, unsigned y, unsigned x, uint32_t pixel) __attribute__((nonnull(1)))
 
API struct ncplanencvisual_blit (struct notcurses *nc, struct ncvisual *ncv, const struct ncvisual_options *vopts) __attribute__((nonnull(2)))
 
 __attribute__ ((nonnull(1, 2, 3))) static inline struct ncplane *ncvisualplane_create(struct notcurses *nc
 
 if (vopts &&vopts->n)
 
 if (newn==NULL)
 
 if (!vopts)
 
 if (ncvisual_blit(nc, ncv, vopts)==NULL)
 
API ALLOC struct ncplanencvisual_subtitle_plane (struct ncplane *parent, const struct ncvisual *ncv) __attribute__((nonnull(1
 
API ALLOC struct ncplane API ncblitter_e ncvisual_media_defblitter (const struct notcurses *nc, ncscale_e scale) __attribute__((nonnull(1)))
 
API int ncvisual_simple_streamer (struct ncvisual *ncv, struct ncvisual_options *vopts, const struct timespec *tspec, void *curry) __attribute__((nonnull(1)))
 
API int ncvisual_stream (struct notcurses *nc, struct ncvisual *ncv, float timescale, ncstreamcb streamer, const struct ncvisual_options *vopts, void *curry) __attribute__((nonnull(1
 
API int API int ncblit_rgba (const void *data, int linesize, const struct ncvisual_options *vopts) __attribute__((nonnull(1)))
 
API int ncblit_bgrx (const void *data, int linesize, const struct ncvisual_options *vopts) __attribute__((nonnull(1)))
 
API int ncblit_rgb_packed (const void *data, int linesize, const struct ncvisual_options *vopts, int alpha) __attribute__((nonnull(1)))
 
API int ncblit_rgb_loose (const void *data, int linesize, const struct ncvisual_options *vopts, int alpha) __attribute__((nonnull(1)))
 
API ALLOC struct ncreelncreel_create (struct ncplane *n, const ncreel_options *popts) __attribute__((nonnull(1)))
 
API struct ncplanencreel_plane (struct ncreel *nr) __attribute__((nonnull(1)))
 
API ALLOC struct nctabletncreel_add (struct ncreel *nr, struct nctablet *after, struct nctablet *before, tabletcb cb, void *opaque) __attribute__((nonnull(1)))
 
API int ncreel_tabletcount (const struct ncreel *nr) __attribute__((nonnull(1)))
 
API int ncreel_del (struct ncreel *nr, struct nctablet *t) __attribute__((nonnull(1)))
 
API int ncreel_redraw (struct ncreel *nr) __attribute__((nonnull(1)))
 
API bool ncreel_offer_input (struct ncreel *nr, const ncinput *ni) __attribute__((nonnull(1
 
API bool API struct nctabletncreel_focused (struct ncreel *nr) __attribute__((nonnull(1)))
 
API struct nctabletncreel_next (struct ncreel *nr) __attribute__((nonnull(1)))
 
API struct nctabletncreel_prev (struct ncreel *nr) __attribute__((nonnull(1)))
 
API void ncreel_destroy (struct ncreel *nr)
 
API void * nctablet_userptr (struct nctablet *t)
 
API struct ncplanenctablet_plane (struct nctablet *t)
 
API const char * ncnmetric (uintmax_t val, size_t s, uintmax_t decimal, char *buf, int omitdec, uintmax_t mult, int uprefix) __attribute__((nonnull(4)))
 
API int notcurses_default_foreground (const struct notcurses *nc, uint32_t *fg) __attribute__((nonnull(1)))
 
API int notcurses_default_background (const struct notcurses *nc, uint32_t *bg) __attribute__((nonnull(1)))
 
API int notcurses_cursor_enable (struct notcurses *nc, int y, int x) __attribute__((nonnull(1)))
 
API int notcurses_cursor_disable (struct notcurses *nc) __attribute__((nonnull(1)))
 
API int notcurses_cursor_yx (const struct notcurses *nc, int *y, int *x) __attribute__((nonnull(1)))
 
API void ncplane_greyscale (struct ncplane *n) __attribute__((nonnull(1)))
 
API ALLOC struct ncselectorncselector_create (struct ncplane *n, const ncselector_options *opts) __attribute__((nonnull(1)))
 
API int ncselector_additem (struct ncselector *n, const struct ncselector_item *item)
 
API int ncselector_delitem (struct ncselector *n, const char *item)
 
API const char * ncselector_selected (const struct ncselector *n) __attribute__((nonnull(1)))
 
API struct ncplanencselector_plane (struct ncselector *n) __attribute__((nonnull(1)))
 
API const char * ncselector_previtem (struct ncselector *n) __attribute__((nonnull(1)))
 
API const char * ncselector_nextitem (struct ncselector *n) __attribute__((nonnull(1)))
 
API bool ncselector_offer_input (struct ncselector *n, const ncinput *nc) __attribute__((nonnull(1
 
API bool API void ncselector_destroy (struct ncselector *n, char **item)
 
API ALLOC struct ncmultiselectorncmultiselector_create (struct ncplane *n, const ncmultiselector_options *opts) __attribute__((nonnull(1)))
 
API int ncmultiselector_selected (struct ncmultiselector *n, bool *selected, unsigned count)
 
API struct ncplanencmultiselector_plane (struct ncmultiselector *n)
 
API bool ncmultiselector_offer_input (struct ncmultiselector *n, const ncinput *nc) __attribute__((nonnull(1
 
API bool API void ncmultiselector_destroy (struct ncmultiselector *n)
 
API ALLOC struct nctreenctree_create (struct ncplane *n, const nctree_options *opts) __attribute__((nonnull(1
 
API ALLOC struct nctree API struct ncplanenctree_plane (struct nctree *n) __attribute__((nonnull(1)))
 
API int nctree_redraw (struct nctree *n) __attribute__((nonnull(1)))
 
API bool nctree_offer_input (struct nctree *n, const ncinput *ni) __attribute__((nonnull(1
 
API bool API void * nctree_focused (struct nctree *n) __attribute__((nonnull(1)))
 
API void * nctree_next (struct nctree *n) __attribute__((nonnull(1)))
 
API void * nctree_prev (struct nctree *n) __attribute__((nonnull(1)))
 
API void * nctree_goto (struct nctree *n, const unsigned *spec, int *failspec)
 
API int nctree_add (struct nctree *n, const unsigned *spec, const struct nctree_item *add) __attribute__((nonnull(1
 
API int API int nctree_del (struct nctree *n, const unsigned *spec) __attribute__((nonnull(1
 
API int API int API void nctree_destroy (struct nctree *n)
 
API ALLOC struct ncmenuncmenu_create (struct ncplane *n, const ncmenu_options *opts) __attribute__((nonnull(1)))
 
API int ncmenu_unroll (struct ncmenu *n, int sectionidx)
 
API int ncmenu_rollup (struct ncmenu *n) __attribute__((nonnull(1)))
 
API int ncmenu_nextsection (struct ncmenu *n) __attribute__((nonnull(1)))
 
API int ncmenu_prevsection (struct ncmenu *n) __attribute__((nonnull(1)))
 
API int ncmenu_nextitem (struct ncmenu *n) __attribute__((nonnull(1)))
 
API int ncmenu_previtem (struct ncmenu *n) __attribute__((nonnull(1)))
 
API int ncmenu_item_set_status (struct ncmenu *n, const char *section, const char *item, bool enabled)
 
API const char * ncmenu_selected (const struct ncmenu *n, ncinput *ni)
 
API const char * ncmenu_mouse_selected (const struct ncmenu *n, const ncinput *click, ncinput *ni)
 
API struct ncplanencmenu_plane (struct ncmenu *n)
 
API bool ncmenu_offer_input (struct ncmenu *n, const ncinput *nc) __attribute__((nonnull(1
 
API bool API void ncmenu_destroy (struct ncmenu *n)
 
API ALLOC struct ncprogbarncprogbar_create (struct ncplane *n, const ncprogbar_options *opts) __attribute__((nonnull(1)))
 
API struct ncplanencprogbar_plane (struct ncprogbar *n) __attribute__((nonnull(1)))
 
API int ncprogbar_set_progress (struct ncprogbar *n, double p) __attribute__((nonnull(1)))
 
API double ncprogbar_progress (const struct ncprogbar *n) __attribute__((nonnull(1)))
 
API void ncprogbar_destroy (struct ncprogbar *n)
 
API ALLOC struct nctabbednctabbed_create (struct ncplane *n, const nctabbed_options *opts) __attribute((nonnull(1)))
 
API void nctabbed_destroy (struct nctabbed *nt)
 
API void nctabbed_redraw (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API void nctabbed_ensure_selected_header_visible (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct nctabnctabbed_selected (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct nctabnctabbed_leftmost (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API int nctabbed_tabcount (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct ncplanenctabbed_plane (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct ncplanenctabbed_content_plane (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API tabcb nctab_cb (struct nctab *t) __attribute__((nonnull(1)))
 
API const char * nctab_name (struct nctab *t) __attribute__((nonnull(1)))
 
API int nctab_name_width (struct nctab *t) __attribute__((nonnull(1)))
 
API void * nctab_userptr (struct nctab *t) __attribute__((nonnull(1)))
 
API struct nctabnctab_next (struct nctab *t) __attribute__((nonnull(1)))
 
API struct nctabnctab_prev (struct nctab *t) __attribute__((nonnull(1)))
 
API ALLOC struct nctabnctabbed_add (struct nctabbed *nt, struct nctab *after, struct nctab *before, tabcb tcb, const char *name, void *opaque) __attribute__((nonnull(1
 
API ALLOC struct nctab API int nctabbed_del (struct nctabbed *nt, struct nctab *t) __attribute__((nonnull(1)))
 
API int nctab_move (struct nctabbed *nt, struct nctab *t, struct nctab *after, struct nctab *before) __attribute__((nonnull(1
 
API int API void nctab_move_right (struct nctabbed *nt, struct nctab *t) __attribute__((nonnull(1
 
API int API void API void nctab_move_left (struct nctabbed *nt, struct nctab *t) __attribute__((nonnull(1
 
API int API void API void API void nctabbed_rotate (struct nctabbed *nt, int amt) __attribute__((nonnull(1)))
 
API struct nctabnctabbed_next (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct nctabnctabbed_prev (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API struct nctabnctabbed_select (struct nctabbed *nt, struct nctab *t) __attribute__((nonnull(1
 
API struct nctab API void nctabbed_channels (struct nctabbed *nt, uint64_t *RESTRICT hdrchan, uint64_t *RESTRICT selchan, uint64_t *RESTRICT sepchan) __attribute__((nonnull(1)))
 
API const char * nctabbed_separator (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API int nctabbed_separator_width (struct nctabbed *nt) __attribute__((nonnull(1)))
 
API void nctabbed_set_hdrchan (struct nctabbed *nt, uint64_t chan) __attribute__((nonnull(1)))
 
API void nctabbed_set_selchan (struct nctabbed *nt, uint64_t chan) __attribute__((nonnull(1)))
 
API void nctabbed_set_sepchan (struct nctabbed *nt, uint64_t chan) __attribute__((nonnull(1)))
 
API tabcb nctab_set_cb (struct nctab *t, tabcb newcb) __attribute__((nonnull(1)))
 
API int nctab_set_name (struct nctab *t, const char *newname) __attribute__((nonnull(1
 
API int API void * nctab_set_userptr (struct nctab *t, void *newopaque) __attribute__((nonnull(1)))
 
API int nctabbed_set_separator (struct nctabbed *nt, const char *separator) __attribute__((nonnull(1
 
API ALLOC struct ncuplot * ncuplot_create (struct ncplane *n, const ncplot_options *opts, uint64_t miny, uint64_t maxy) __attribute__((nonnull(1)))
 
API ALLOC struct ncdplot * ncdplot_create (struct ncplane *n, const ncplot_options *opts, double miny, double maxy) __attribute__((nonnull(1)))
 
API struct ncplanencuplot_plane (struct ncuplot *n) __attribute__((nonnull(1)))
 
API struct ncplanencdplot_plane (struct ncdplot *n) __attribute__((nonnull(1)))
 
API int ncuplot_add_sample (struct ncuplot *n, uint64_t x, uint64_t y) __attribute__((nonnull(1)))
 
API int ncdplot_add_sample (struct ncdplot *n, uint64_t x, double y) __attribute__((nonnull(1)))
 
API int ncuplot_set_sample (struct ncuplot *n, uint64_t x, uint64_t y) __attribute__((nonnull(1)))
 
API int ncdplot_set_sample (struct ncdplot *n, uint64_t x, double y) __attribute__((nonnull(1)))
 
API int ncuplot_sample (const struct ncuplot *n, uint64_t x, uint64_t *y) __attribute__((nonnull(1)))
 
API int ncdplot_sample (const struct ncdplot *n, uint64_t x, double *y) __attribute__((nonnull(1)))
 
API void ncuplot_destroy (struct ncuplot *n)
 
API void ncdplot_destroy (struct ncdplot *n)
 
API ALLOC struct ncfdplanencfdplane_create (struct ncplane *n, const ncfdplane_options *opts, int fd, ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__((nonnull(1)))
 
API struct ncplanencfdplane_plane (struct ncfdplane *n) __attribute__((nonnull(1)))
 
API int ncfdplane_destroy (struct ncfdplane *n)
 
API ALLOC struct ncsubprocncsubproc_createv (struct ncplane *n, const ncsubproc_options *opts, const char *bin, const char *const arg[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__((nonnull(1)))
 
API ALLOC struct ncsubprocncsubproc_createvp (struct ncplane *n, const ncsubproc_options *opts, const char *bin, const char *const arg[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__((nonnull(1)))
 
API ALLOC struct ncsubprocncsubproc_createvpe (struct ncplane *n, const ncsubproc_options *opts, const char *bin, const char *const arg[], const char *const env[], ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn) __attribute__((nonnull(1)))
 
API struct ncplanencsubproc_plane (struct ncsubproc *n) __attribute__((nonnull(1)))
 
API int ncsubproc_destroy (struct ncsubproc *n)
 
API int ncplane_qrcode (struct ncplane *n, unsigned *ymax, unsigned *xmax, const void *data, size_t len) __attribute__((nonnull(1
 
API ALLOC struct ncreaderncreader_create (struct ncplane *n, const ncreader_options *opts) __attribute__((nonnull(1)))
 
API int ncreader_clear (struct ncreader *n) __attribute__((nonnull(1)))
 
API struct ncplanencreader_plane (struct ncreader *n) __attribute__((nonnull(1)))
 
API bool ncreader_offer_input (struct ncreader *n, const ncinput *ni) __attribute__((nonnull(1
 
API bool API int ncreader_move_left (struct ncreader *n) __attribute__((nonnull(1)))
 
API int ncreader_move_right (struct ncreader *n) __attribute__((nonnull(1)))
 
API int ncreader_move_up (struct ncreader *n) __attribute__((nonnull(1)))
 
API int ncreader_move_down (struct ncreader *n) __attribute__((nonnull(1)))
 
API int ncreader_write_egc (struct ncreader *n, const char *egc) __attribute__((nonnull(1
 
API int API char * ncreader_contents (const struct ncreader *n) __attribute__((nonnull(1)))
 
API void ncreader_destroy (struct ncreader *n, char **contents)
 
API ALLOC char * notcurses_accountname (void)
 
API ALLOC char * notcurses_hostname (void)
 
API ALLOC char * notcurses_osversion (void)
 
API void notcurses_debug (const struct notcurses *nc, FILE *debugfp) __attribute__((nonnull(1
 

Variables

API const nccellc
 
API int(*)(struct ncplane *) ncplane_resizecb (const struct ncplane *n)
 
int y
 
int int x
 
API int API int const nccell unsigned len
 
const struct ncplane_optionsopts
 
const struct ncplane_options struct ncvisualncv
 
const struct ncplane_options struct ncvisual struct ncvisual_optionsvopts
 
 else
 
struct ncvisual_options v
 
vopts n = newn
 
return newn
 

Macro Definition Documentation

◆ ALLOC

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

Definition at line 36 of file notcurses.h.

◆ API

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

Definition at line 32 of file notcurses.h.

◆ NC_BG_ALPHA_MASK

#define NC_BG_ALPHA_MASK   0x30000000ull

Definition at line 125 of file notcurses.h.

◆ NC_BG_PALETTE

#define NC_BG_PALETTE   0x0000000008000000ull

Definition at line 123 of file notcurses.h.

◆ NC_BG_RGB_MASK

#define NC_BG_RGB_MASK   0x0000000000ffffffull

Definition at line 120 of file notcurses.h.

◆ NC_BGDEFAULT_MASK

#define NC_BGDEFAULT_MASK   0x0000000040000000ull

Definition at line 118 of file notcurses.h.

◆ NC_NOBACKGROUND_MASK

#define NC_NOBACKGROUND_MASK   0x8700000000000000ull

Definition at line 116 of file notcurses.h.

◆ NCALIGN_BOTTOM

#define NCALIGN_BOTTOM   NCALIGN_RIGHT

Definition at line 88 of file notcurses.h.

◆ NCALIGN_TOP

#define NCALIGN_TOP   NCALIGN_LEFT

Definition at line 87 of file notcurses.h.

◆ NCALPHA_BLEND

#define NCALPHA_BLEND   0x10000000ull

Definition at line 107 of file notcurses.h.

◆ NCALPHA_HIGHCONTRAST

#define NCALPHA_HIGHCONTRAST   0x30000000ull

Definition at line 105 of file notcurses.h.

◆ NCALPHA_OPAQUE

#define NCALPHA_OPAQUE   0x00000000ull

Definition at line 108 of file notcurses.h.

◆ NCALPHA_TRANSPARENT

#define NCALPHA_TRANSPARENT   0x20000000ull

Definition at line 106 of file notcurses.h.

◆ NCBOXCORNER_MASK

#define NCBOXCORNER_MASK   0x0300

Definition at line 2609 of file notcurses.h.

◆ NCBOXCORNER_SHIFT

#define NCBOXCORNER_SHIFT   8u

Definition at line 2610 of file notcurses.h.

◆ NCBOXGRAD_BOTTOM

#define NCBOXGRAD_BOTTOM   0x0040

Definition at line 2607 of file notcurses.h.

◆ NCBOXGRAD_LEFT

#define NCBOXGRAD_LEFT   0x0080

Definition at line 2608 of file notcurses.h.

◆ NCBOXGRAD_RIGHT

#define NCBOXGRAD_RIGHT   0x0020

Definition at line 2606 of file notcurses.h.

◆ NCBOXGRAD_TOP

#define NCBOXGRAD_TOP   0x0010

Definition at line 2605 of file notcurses.h.

◆ NCBOXMASK_BOTTOM

#define NCBOXMASK_BOTTOM   0x0004

Definition at line 2603 of file notcurses.h.

◆ NCBOXMASK_LEFT

#define NCBOXMASK_LEFT   0x0008

Definition at line 2604 of file notcurses.h.

◆ NCBOXMASK_RIGHT

#define NCBOXMASK_RIGHT   0x0002

Definition at line 2602 of file notcurses.h.

◆ NCBOXMASK_TOP

#define NCBOXMASK_TOP   0x0001

Definition at line 2601 of file notcurses.h.

◆ NCBPREFIXCOLUMNS

#define NCBPREFIXCOLUMNS   9

Definition at line 3827 of file notcurses.h.

◆ NCBPREFIXFMT

#define NCBPREFIXFMT (   x)    NCMETRICFWIDTH((x), NCBPREFIXCOLUMNS), (x)

Definition at line 3837 of file notcurses.h.

◆ NCBPREFIXSTRLEN

#define NCBPREFIXSTRLEN   (NCBPREFIXCOLUMNS + 1)

Definition at line 3830 of file notcurses.h.

◆ NCCELL_CHAR_INITIALIZER

#define NCCELL_CHAR_INITIALIZER (   c)
Value:
{ .gcluster = (htole(c)), .gcluster_backstop = 0,\
.width = (uint8_t)((wcwidth(c) < 0 || !c) ? 1 : wcwidth(c)), .stylemask = 0, .channels = 0, }
#define htole(x)
Definition ncport.h:36
API const nccell * c
Definition notcurses.h:861

Definition at line 734 of file notcurses.h.

734 { .gcluster = (htole(c)), .gcluster_backstop = 0,\
735 .width = (uint8_t)((wcwidth(c) < 0 || !c) ? 1 : wcwidth(c)), .stylemask = 0, .channels = 0, }

◆ NCCELL_INITIALIZER

#define NCCELL_INITIALIZER (   c,
  s,
  chan 
)
Value:
{ .gcluster = (htole(c)), .gcluster_backstop = 0,\
.width = (uint8_t)((wcwidth(c) < 0 || !c) ? 1 : wcwidth(c)), .stylemask = (s), .channels = (chan), }

Definition at line 731 of file notcurses.h.

731 { .gcluster = (htole(c)), .gcluster_backstop = 0,\
732 .width = (uint8_t)((wcwidth(c) < 0 || !c) ? 1 : wcwidth(c)), .stylemask = (s), .channels = (chan), }

◆ NCCELL_TRIVIAL_INITIALIZER

#define NCCELL_TRIVIAL_INITIALIZER
Value:
{ .gcluster = 0, .gcluster_backstop = 0,\
.width = 1, .stylemask = 0, .channels = 0, }

Definition at line 737 of file notcurses.h.

737 { .gcluster = 0, .gcluster_backstop = 0,\
738 .width = 1, .stylemask = 0, .channels = 0, }

◆ NCCHANNEL_INITIALIZER

#define NCCHANNEL_INITIALIZER (   r,
  g,
 
)     (((uint32_t)(r) << 16u) + ((uint32_t)(g) << 8u) + (b) + NC_BGDEFAULT_MASK)

Definition at line 128 of file notcurses.h.

◆ NCCHANNELS_INITIALIZER

#define NCCHANNELS_INITIALIZER (   fr,
  fg,
  fb,
  br,
  bg,
  bb 
)
Value:
((NCCHANNEL_INITIALIZER((fr), (fg), (fb)) << 32ull) + \
(NCCHANNEL_INITIALIZER((br), (bg), (bb))))
#define NCCHANNEL_INITIALIZER(r, g, b)
Definition notcurses.h:128

Definition at line 132 of file notcurses.h.

◆ NCINPUT_MAX_EFF_TEXT_CODEPOINTS

#define NCINPUT_MAX_EFF_TEXT_CODEPOINTS   4

Definition at line 1203 of file notcurses.h.

◆ NCIPREFIXCOLUMNS

#define NCIPREFIXCOLUMNS   8

Definition at line 3826 of file notcurses.h.

◆ NCIPREFIXFMT

#define NCIPREFIXFMT (   x)    NCMETRICFWIDTH((x), NCIPREFIXCOLUMNS), (x)

Definition at line 3836 of file notcurses.h.

◆ NCIPREFIXSTRLEN

#define NCIPREFIXSTRLEN   (NCIPREFIXCOLUMNS + 1)

Definition at line 3829 of file notcurses.h.

◆ NCMENU_OPTION_BOTTOM

#define NCMENU_OPTION_BOTTOM   0x0001ull

Definition at line 4127 of file notcurses.h.

◆ NCMENU_OPTION_HIDING

#define NCMENU_OPTION_HIDING   0x0002ull

Definition at line 4128 of file notcurses.h.

◆ NCMETRICFWIDTH

#define NCMETRICFWIDTH (   x,
  cols 
)     ((int)(strlen(x) - ncstrwidth(x, NULL, NULL) + (cols)))

Definition at line 3833 of file notcurses.h.

◆ NCMICE_ALL_EVENTS

#define NCMICE_ALL_EVENTS   0x7

Definition at line 1344 of file notcurses.h.

◆ NCMICE_BUTTON_EVENT

#define NCMICE_BUTTON_EVENT   0x2

Definition at line 1342 of file notcurses.h.

◆ NCMICE_DRAG_EVENT

#define NCMICE_DRAG_EVENT   0x4

Definition at line 1343 of file notcurses.h.

◆ NCMICE_MOVE_EVENT

#define NCMICE_MOVE_EVENT   0x1

Definition at line 1341 of file notcurses.h.

◆ NCMICE_NO_EVENTS

#define NCMICE_NO_EVENTS   0

Definition at line 1340 of file notcurses.h.

◆ NCOPTION_CLI_MODE

#define NCOPTION_CLI_MODE
Value:
#define NCOPTION_NO_CLEAR_BITMAPS
Definition notcurses.h:996
#define NCOPTION_PRESERVE_CURSOR
Definition notcurses.h:1011
#define NCOPTION_SCROLLING
Definition notcurses.h:1034
#define NCOPTION_NO_ALTERNATE_SCREEN
Definition notcurses.h:1019

Definition at line 1037 of file notcurses.h.

◆ NCOPTION_DRAIN_INPUT

#define NCOPTION_DRAIN_INPUT   0x0100ull

Definition at line 1030 of file notcurses.h.

◆ NCOPTION_INHIBIT_SETLOCALE

#define NCOPTION_INHIBIT_SETLOCALE   0x0001ull

Definition at line 990 of file notcurses.h.

◆ NCOPTION_NO_ALTERNATE_SCREEN

#define NCOPTION_NO_ALTERNATE_SCREEN   0x0040ull

Definition at line 1019 of file notcurses.h.

◆ NCOPTION_NO_CLEAR_BITMAPS

#define NCOPTION_NO_CLEAR_BITMAPS   0x0002ull

Definition at line 996 of file notcurses.h.

◆ NCOPTION_NO_FONT_CHANGES

#define NCOPTION_NO_FONT_CHANGES   0x0080ull

Definition at line 1025 of file notcurses.h.

◆ NCOPTION_NO_QUIT_SIGHANDLERS

#define NCOPTION_NO_QUIT_SIGHANDLERS   0x0008ull

Definition at line 1005 of file notcurses.h.

◆ NCOPTION_NO_WINCH_SIGHANDLER

#define NCOPTION_NO_WINCH_SIGHANDLER   0x0004ull

Definition at line 1000 of file notcurses.h.

◆ NCOPTION_PRESERVE_CURSOR

#define NCOPTION_PRESERVE_CURSOR   0x0010ull

Definition at line 1011 of file notcurses.h.

◆ NCOPTION_SCROLLING

#define NCOPTION_SCROLLING   0x0200ull

Definition at line 1034 of file notcurses.h.

◆ NCOPTION_SUPPRESS_BANNERS

#define NCOPTION_SUPPRESS_BANNERS   0x0020ull

Definition at line 1015 of file notcurses.h.

◆ NCPALETTESIZE

#define NCPALETTESIZE   256

Definition at line 111 of file notcurses.h.

◆ NCPLANE_OPTION_AUTOGROW

#define NCPLANE_OPTION_AUTOGROW   0x0010ull

Definition at line 1458 of file notcurses.h.

◆ NCPLANE_OPTION_FIXED

#define NCPLANE_OPTION_FIXED   0x0008ull

Definition at line 1454 of file notcurses.h.

◆ NCPLANE_OPTION_HORALIGNED

#define NCPLANE_OPTION_HORALIGNED   0x0001ull

Definition at line 1441 of file notcurses.h.

◆ NCPLANE_OPTION_MARGINALIZED

#define NCPLANE_OPTION_MARGINALIZED   0x0004ull

Definition at line 1450 of file notcurses.h.

◆ NCPLANE_OPTION_VERALIGNED

#define NCPLANE_OPTION_VERALIGNED   0x0002ull

Definition at line 1443 of file notcurses.h.

◆ NCPLANE_OPTION_VSCROLL

#define NCPLANE_OPTION_VSCROLL   0x0020ull

Definition at line 1462 of file notcurses.h.

◆ NCPLOT_OPTION_DETECTMAXONLY

#define NCPLOT_OPTION_DETECTMAXONLY   0x0010u

Definition at line 4484 of file notcurses.h.

◆ NCPLOT_OPTION_EXPONENTIALD

#define NCPLOT_OPTION_EXPONENTIALD   0x0002u

Definition at line 4481 of file notcurses.h.

◆ NCPLOT_OPTION_LABELTICKSD

#define NCPLOT_OPTION_LABELTICKSD   0x0001u

Definition at line 4480 of file notcurses.h.

◆ NCPLOT_OPTION_NODEGRADE

#define NCPLOT_OPTION_NODEGRADE   0x0008u

Definition at line 4483 of file notcurses.h.

◆ NCPLOT_OPTION_PRINTSAMPLE

#define NCPLOT_OPTION_PRINTSAMPLE   0x0020u

Definition at line 4485 of file notcurses.h.

◆ NCPLOT_OPTION_VERTICALI

#define NCPLOT_OPTION_VERTICALI   0x0004u

Definition at line 4482 of file notcurses.h.

◆ NCPREFIXCOLUMNS

#define NCPREFIXCOLUMNS   7

Definition at line 3825 of file notcurses.h.

◆ NCPREFIXFMT

#define NCPREFIXFMT (   x)    NCMETRICFWIDTH((x), NCPREFIXCOLUMNS), (x)

Definition at line 3835 of file notcurses.h.

◆ NCPREFIXSTRLEN

#define NCPREFIXSTRLEN   (NCPREFIXCOLUMNS + 1)

Definition at line 3828 of file notcurses.h.

◆ NCPROGBAR_OPTION_RETROGRADE

#define NCPROGBAR_OPTION_RETROGRADE   0x0001u

Definition at line 4203 of file notcurses.h.

◆ NCREADER_OPTION_CURSOR

#define NCREADER_OPTION_CURSOR   0x0008ull

Definition at line 4618 of file notcurses.h.

◆ NCREADER_OPTION_HORSCROLL

#define NCREADER_OPTION_HORSCROLL   0x0001ull

Definition at line 4611 of file notcurses.h.

◆ NCREADER_OPTION_NOCMDKEYS

#define NCREADER_OPTION_NOCMDKEYS   0x0004ull

Definition at line 4615 of file notcurses.h.

◆ NCREADER_OPTION_VERSCROLL

#define NCREADER_OPTION_VERSCROLL   0x0002ull

Definition at line 4613 of file notcurses.h.

◆ NCREEL_OPTION_CIRCULAR

#define NCREEL_OPTION_CIRCULAR   0x0002ull

Definition at line 3698 of file notcurses.h.

◆ NCREEL_OPTION_INFINITESCROLL

#define NCREEL_OPTION_INFINITESCROLL   0x0001ull

Definition at line 3694 of file notcurses.h.

◆ NCSTYLE_BOLD

#define NCSTYLE_BOLD   0x0002u

Definition at line 773 of file notcurses.h.

◆ NCSTYLE_ITALIC

#define NCSTYLE_ITALIC   0x0010u

Definition at line 770 of file notcurses.h.

◆ NCSTYLE_MASK

#define NCSTYLE_MASK   0xffffu

Definition at line 769 of file notcurses.h.

◆ NCSTYLE_NONE

#define NCSTYLE_NONE   0

Definition at line 775 of file notcurses.h.

◆ NCSTYLE_STRUCK

#define NCSTYLE_STRUCK   0x0001u

Definition at line 774 of file notcurses.h.

◆ NCSTYLE_UNDERCURL

#define NCSTYLE_UNDERCURL   0x0004u

Definition at line 772 of file notcurses.h.

◆ NCSTYLE_UNDERLINE

#define NCSTYLE_UNDERLINE   0x0008u

Definition at line 771 of file notcurses.h.

◆ NCTABBED_OPTION_BOTTOM

#define NCTABBED_OPTION_BOTTOM   0x0001ull

Definition at line 4237 of file notcurses.h.

◆ NCVISUAL_OPTION_ADDALPHA

#define NCVISUAL_OPTION_ADDALPHA   0x0010ull

Definition at line 3341 of file notcurses.h.

◆ NCVISUAL_OPTION_BLEND

#define NCVISUAL_OPTION_BLEND   0x0002ull

Definition at line 3338 of file notcurses.h.

◆ NCVISUAL_OPTION_CHILDPLANE

#define NCVISUAL_OPTION_CHILDPLANE   0x0020ull

Definition at line 3342 of file notcurses.h.

◆ NCVISUAL_OPTION_HORALIGNED

#define NCVISUAL_OPTION_HORALIGNED   0x0004ull

Definition at line 3339 of file notcurses.h.

◆ NCVISUAL_OPTION_NODEGRADE

#define NCVISUAL_OPTION_NODEGRADE   0x0001ull

Definition at line 3337 of file notcurses.h.

◆ NCVISUAL_OPTION_NOINTERPOLATE

#define NCVISUAL_OPTION_NOINTERPOLATE   0x0040ull

Definition at line 3343 of file notcurses.h.

◆ NCVISUAL_OPTION_VERALIGNED

#define NCVISUAL_OPTION_VERALIGNED   0x0008ull

Definition at line 3340 of file notcurses.h.

◆ RESTRICT

#define RESTRICT   restrict

Definition at line 24 of file notcurses.h.

◆ WCHAR_MAX_UTF8BYTES

#define WCHAR_MAX_UTF8BYTES   4

Definition at line 594 of file notcurses.h.

Typedef Documentation

◆ fadecb

typedef int(* fadecb) (struct notcurses *nc, struct ncplane *n, const struct timespec *, void *curry)

Definition at line 3029 of file notcurses.h.

◆ nccapabilities

◆ nccell

typedef API int struct nccell nccell

◆ ncfdplane_callback

typedef int(* ncfdplane_callback) (struct ncfdplane *n, const void *buf, size_t s, void *curry)

Definition at line 4546 of file notcurses.h.

◆ ncfdplane_done_cb

typedef int(* ncfdplane_done_cb) (struct ncfdplane *n, int fderrno, void *curry)

Definition at line 4547 of file notcurses.h.

◆ ncfdplane_options

◆ ncinput

typedef struct ncinput ncinput

◆ ncmenu_options

◆ ncmultiselector_options

◆ ncpalette

typedef struct ncpalette ncpalette

◆ ncplane_options

◆ ncplot_options

◆ ncprogbar_options

◆ ncreader_options

◆ ncreel_options

◆ ncselector_options

◆ ncstats

typedef struct ncstats ncstats

◆ ncstreamcb

typedef int(* ncstreamcb) (struct ncvisual *, struct ncvisual_options *, const struct timespec *, void *)

Definition at line 3533 of file notcurses.h.

◆ ncsubproc_options

◆ nctabbed_options

◆ nctree_options

◆ ncvgeom

typedef struct ncvgeom ncvgeom

◆ notcurses_options

◆ tabcb

typedef void(* tabcb) (struct nctab *t, struct ncplane *ncp, void *curry)

Definition at line 4250 of file notcurses.h.

◆ tabletcb

typedef int(* tabletcb) (struct nctablet *t, bool drawfromtop)

Definition at line 3728 of file notcurses.h.

Enumeration Type Documentation

◆ ncalign_e

enum ncalign_e
Enumerator
NCALIGN_UNALIGNED 
NCALIGN_LEFT 
NCALIGN_CENTER 
NCALIGN_RIGHT 

Definition at line 80 of file notcurses.h.

80 {
85} ncalign_e;
ncalign_e
Definition notcurses.h:80
@ NCALIGN_LEFT
Definition notcurses.h:82
@ NCALIGN_UNALIGNED
Definition notcurses.h:81
@ NCALIGN_CENTER
Definition notcurses.h:83
@ NCALIGN_RIGHT
Definition notcurses.h:84

◆ ncblitter_e

Enumerator
NCBLIT_DEFAULT 
NCBLIT_1x1 
NCBLIT_2x1 
NCBLIT_2x2 
NCBLIT_3x2 
NCBLIT_4x2 
NCBLIT_BRAILLE 
NCBLIT_PIXEL 
NCBLIT_4x1 
NCBLIT_8x1 

Definition at line 65 of file notcurses.h.

65 {
66 NCBLIT_DEFAULT, // let the ncvisual pick
67 NCBLIT_1x1, // space, compatible with ASCII
68 NCBLIT_2x1, // halves + 1x1 (space) ▄▀
69 NCBLIT_2x2, // quadrants + 2x1 ▗▐ ▖▀▟▌▙
70 NCBLIT_3x2, // sextants + 2x1 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬉🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞
71 NCBLIT_4x2, // octants + 2x2 there are a great many octants
72 NCBLIT_BRAILLE, // 4 rows, 2 cols (braille) ⡀⡄⡆⡇⢀⣀⣄⣆⣇⢠⣠⣤⣦⣧⢰⣰⣴⣶⣷⢸⣸⣼⣾⣿
73 NCBLIT_PIXEL, // pixel graphics
74 // these blitters are suitable only for plots, not general media
75 NCBLIT_4x1, // four vertical levels █▆▄▂
76 NCBLIT_8x1, // eight vertical levels █▇▆▅▄▃▂▁
ncblitter_e
Definition notcurses.h:65
@ NCBLIT_PIXEL
Definition notcurses.h:73
@ NCBLIT_4x2
Definition notcurses.h:71
@ NCBLIT_DEFAULT
Definition notcurses.h:66
@ NCBLIT_4x1
Definition notcurses.h:75
@ NCBLIT_2x2
Definition notcurses.h:69
@ NCBLIT_3x2
Definition notcurses.h:70
@ NCBLIT_1x1
Definition notcurses.h:67
@ NCBLIT_BRAILLE
Definition notcurses.h:72
@ NCBLIT_2x1
Definition notcurses.h:68
@ NCBLIT_8x1
Definition notcurses.h:76

◆ ncintype_e

enum ncintype_e
Enumerator
NCTYPE_UNKNOWN 
NCTYPE_PRESS 
NCTYPE_REPEAT 
NCTYPE_RELEASE 

Definition at line 1194 of file notcurses.h.

1194 {
1199} ncintype_e;
ncintype_e
Definition notcurses.h:1194
@ NCTYPE_REPEAT
Definition notcurses.h:1197
@ NCTYPE_RELEASE
Definition notcurses.h:1198
@ NCTYPE_PRESS
Definition notcurses.h:1196
@ NCTYPE_UNKNOWN
Definition notcurses.h:1195

◆ ncloglevel_e

Enumerator
NCLOGLEVEL_SILENT 
NCLOGLEVEL_PANIC 
NCLOGLEVEL_FATAL 
NCLOGLEVEL_ERROR 
NCLOGLEVEL_WARNING 
NCLOGLEVEL_INFO 
NCLOGLEVEL_VERBOSE 
NCLOGLEVEL_DEBUG 
NCLOGLEVEL_TRACE 

Definition at line 968 of file notcurses.h.

968 {
969 NCLOGLEVEL_SILENT = -1,// default. print nothing once fullscreen service begins
970 NCLOGLEVEL_PANIC = 0, // print diagnostics related to catastrophic failure
971 NCLOGLEVEL_FATAL = 1, // we're hanging around, but we've had a horrible fault
972 NCLOGLEVEL_ERROR = 2, // we can't keep doing this, but we can do other things
973 NCLOGLEVEL_WARNING = 3,// you probably don't want what's happening to happen
974 NCLOGLEVEL_INFO = 4, // "standard information"
975 NCLOGLEVEL_VERBOSE = 5,// "detailed information"
976 NCLOGLEVEL_DEBUG = 6, // this is honestly a bit much
977 NCLOGLEVEL_TRACE = 7, // there's probably a better way to do what you want
ncloglevel_e
Definition notcurses.h:968
@ NCLOGLEVEL_WARNING
Definition notcurses.h:973
@ NCLOGLEVEL_VERBOSE
Definition notcurses.h:975
@ NCLOGLEVEL_DEBUG
Definition notcurses.h:976
@ NCLOGLEVEL_INFO
Definition notcurses.h:974
@ NCLOGLEVEL_ERROR
Definition notcurses.h:972
@ NCLOGLEVEL_PANIC
Definition notcurses.h:970
@ NCLOGLEVEL_FATAL
Definition notcurses.h:971
@ NCLOGLEVEL_SILENT
Definition notcurses.h:969
@ NCLOGLEVEL_TRACE
Definition notcurses.h:977

◆ ncpixelimpl_e

Enumerator
NCPIXEL_NONE 
NCPIXEL_SIXEL 
NCPIXEL_LINUXFB 
NCPIXEL_ITERM2 
NCPIXEL_KITTY_STATIC 
NCPIXEL_KITTY_ANIMATED 
NCPIXEL_KITTY_SELFREF 

Definition at line 1672 of file notcurses.h.

1672 {
1673 NCPIXEL_NONE = 0,
1674 NCPIXEL_SIXEL, // sixel
1675 NCPIXEL_LINUXFB, // linux framebuffer
1676 NCPIXEL_ITERM2, // iTerm2
1677 // C=1 (disabling scrolling) was only introduced in 0.20.0, at the same
1678 // time as animation. prior to this, graphics had to be entirely redrawn
1679 // on any change, and it wasn't possible to use the bottom line.
1681 // until 0.22.0's introduction of 'a=c' for self-referential composition, we
1682 // had to keep a complete copy of the RGBA data, in case a wiped cell needed
1683 // to be rebuilt. we'd otherwise have to unpack the glyph and store it into
1684 // the auxvec on the fly.
1686 // with 0.22.0, we only ever write transparent cells after writing the
1687 // original image (which we now deflate, since we needn't unpack it later).
1688 // the only data we need keep is the auxvecs.
ncpixelimpl_e
Definition notcurses.h:1672
@ NCPIXEL_KITTY_STATIC
Definition notcurses.h:1680
@ NCPIXEL_NONE
Definition notcurses.h:1673
@ NCPIXEL_ITERM2
Definition notcurses.h:1676
@ NCPIXEL_KITTY_SELFREF
Definition notcurses.h:1689
@ NCPIXEL_KITTY_ANIMATED
Definition notcurses.h:1685
@ NCPIXEL_SIXEL
Definition notcurses.h:1674
@ NCPIXEL_LINUXFB
Definition notcurses.h:1675

◆ ncscale_e

enum ncscale_e
Enumerator
NCSCALE_NONE 
NCSCALE_SCALE 
NCSCALE_STRETCH 
NCSCALE_NONE_HIRES 
NCSCALE_SCALE_HIRES 

Definition at line 96 of file notcurses.h.

96 {
102} ncscale_e;
ncscale_e
Definition notcurses.h:96
@ NCSCALE_SCALE_HIRES
Definition notcurses.h:101
@ NCSCALE_STRETCH
Definition notcurses.h:99
@ NCSCALE_SCALE
Definition notcurses.h:98
@ NCSCALE_NONE
Definition notcurses.h:97
@ NCSCALE_NONE_HIRES
Definition notcurses.h:100

Function Documentation

◆ __attribute__() [1/8]

API int __attribute__ ( (format(printf, 2, 0))  )

◆ __attribute__() [2/8]

static int __attribute__ ( (format(printf, 2, 3))  )
Here is the call graph for this function:

◆ __attribute__() [3/8]

API int __attribute__ ( (format(printf, 4, 0))  )

◆ __attribute__() [4/8]

static int __attribute__ ( (format(printf, 4, 5))  )
Here is the call graph for this function:

◆ __attribute__() [5/8]

__attribute__ ( (nonnull(1))  )

Definition at line 1353 of file notcurses.h.

1354 {
1356}
#define NCMICE_NO_EVENTS
Definition notcurses.h:1340
API int notcurses_mice_enable(struct notcurses *n, unsigned eventmask) __attribute__((nonnull(1)))
Definition notcurses.c:2556
vopts n
Definition notcurses.h:3502
Here is the call graph for this function:

◆ __attribute__() [6/8]

API int API int __attribute__ ( (nonnull(1, 2))  )

◆ __attribute__() [7/8]

__attribute__ ( (nonnull(1, 2, 3))  )

◆ __attribute__() [8/8]

API __attribute__ ( (returns_nonnull)  ) const

◆ if() [1/4]

if ( vopts)

Definition at line 3498 of file notcurses.h.

3498 {
3499 vopts = &v;
3500 memset(vopts, 0, sizeof(*vopts));
3501 }
const struct ncplane_options struct ncvisual struct ncvisual_options * vopts
Definition notcurses.h:3484
struct ncvisual_options v
Definition notcurses.h:3497

◆ if() [2/4]

if ( ncvisual_blit(nc, ncv, vopts = NULL)

Definition at line 3503 of file notcurses.h.

3503 {
3505 vopts->n = NULL;
3506 return NULL;
3507 }
return newn
Definition notcurses.h:3508
API int ncplane_destroy(struct ncplane *n)
Definition notcurses.c:1018
return NULL
Definition termdesc.h:229
Here is the call graph for this function:

◆ if() [3/4]

if ( newn  = NULL)

Definition at line 3494 of file notcurses.h.

3494 {
3495 return NULL;
3496 }

◆ if() [4/4]

if ( vopts &&vopts->  n)

Definition at line 3486 of file notcurses.h.

3486 {
3488 return NULL; // the whole point is to create a new plane
3489 }
3491 }else{
#define NCVISUAL_OPTION_CHILDPLANE
Definition notcurses.h:3342
API ALLOC struct ncplane * ncplane_create(struct ncplane *n, const ncplane_options *nopts) __attribute__((nonnull(1
const struct ncplane_options * opts
Definition notcurses.h:3483
Here is the call graph for this function:

◆ ncblit_bgrx()

API int ncblit_bgrx ( const void *  data,
int  linesize,
const struct ncvisual_options vopts 
)

Definition at line 1408 of file blit.c.

1408 {
1409 if(vopts->leny <= 0 || vopts->lenx <= 0){
1410 logerror("invalid lengths %u %u", vopts->leny, vopts->lenx);
1411 return -1;
1412 }
1413 if(vopts->n == NULL){
1414 logerror("prohibited null plane");
1415 return -1;
1416 }
1417 void* rdata = bgra_to_rgba(data, vopts->leny, &linesize, vopts->lenx, 0xff);
1418 if(rdata == NULL){
1419 return -1;
1420 }
1421 int r = ncblit_rgba(rdata, linesize, vopts);
1422 free(rdata);
1423 return r;
1424}
int ncblit_rgba(const void *data, int linesize, const struct ncvisual_options *vopts)
Definition blit.c:1454
free(duplicated)
int r
Definition fbuf.h:226
ALLOC void * bgra_to_rgba(const void *data, int rows, int *rowstride, int cols, int alpha)
Definition visual.c:506
#define logerror(fmt,...)
Definition logging.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncblit_rgb_loose()

API int ncblit_rgb_loose ( const void *  data,
int  linesize,
const struct ncvisual_options vopts,
int  alpha 
)

Definition at line 1426 of file blit.c.

1427 {
1428 if(vopts->leny <= 0 || vopts->lenx <= 0){
1429 return -1;
1430 }
1431 void* rdata = rgb_loose_to_rgba(data, vopts->leny, &linesize, vopts->lenx, alpha);
1432 if(rdata == NULL){
1433 return -1;
1434 }
1435 int r = ncblit_rgba(rdata, linesize, vopts);
1436 free(rdata);
1437 return r;
1438}
ALLOC void * rgb_loose_to_rgba(const void *data, int rows, int *rowstride, int cols, int alpha)
Definition visual.c:461
Here is the call graph for this function:

◆ ncblit_rgb_packed()

API int ncblit_rgb_packed ( const void *  data,
int  linesize,
const struct ncvisual_options vopts,
int  alpha 
)

Definition at line 1440 of file blit.c.

1441 {
1442 if(vopts->leny <= 0 || vopts->lenx <= 0){
1443 return -1;
1444 }
1445 void* rdata = rgb_packed_to_rgba(data, vopts->leny, &linesize, vopts->lenx, alpha);
1446 if(rdata == NULL){
1447 return -1;
1448 }
1449 int r = ncblit_rgba(rdata, linesize, vopts);
1450 free(rdata);
1451 return r;
1452}
ALLOC void * rgb_packed_to_rgba(const void *data, int rows, int *rowstride, int cols, int alpha)
Definition visual.c:485
Here is the call graph for this function:

◆ ncblit_rgba()

API int API int ncblit_rgba ( const void *  data,
int  linesize,
const struct ncvisual_options vopts 
)

Definition at line 1454 of file blit.c.

1454 {
1455 if(vopts->leny <= 0 || vopts->lenx <= 0){
1456 logerror("invalid lengths %u %u", vopts->leny, vopts->lenx);
1457 return -1;
1458 }
1459 if(vopts->n == NULL){
1460 logerror("prohibited null plane");
1461 return -1;
1462 }
1463 struct ncvisual* ncv = ncvisual_from_rgba(data, vopts->leny, linesize, vopts->lenx);
1464 if(ncv == NULL){
1465 return -1;
1466 }
1469 return -1;
1470 }
1472 return 0;
1473}
notcurses * ncplane_notcurses(const ncplane *n)
Definition notcurses.c:2626
const struct ncplane_options struct ncvisual * ncv
Definition notcurses.h:3484
uint32_t * data
ncvisual * ncvisual_from_rgba(const void *rgba, int rows, int rowstride, int cols)
Definition visual.c:776
void ncvisual_destroy(ncvisual *ncv)
Definition visual.c:1225
ncplane * ncvisual_blit(notcurses *nc, ncvisual *ncv, const struct ncvisual_options *vopts)
Definition visual.c:1136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nccell_duplicate()

API int nccell_duplicate ( struct ncplane n,
nccell targ,
const nccell c 
)

Definition at line 133 of file render.c.

133 {
134 if(cell_duplicate_far(&n->pool, targ, n, c) < 0){
135 logerror("failed duplicating cell");
136 return -1;
137 }
138 return 0;
139}
const nccell * c
Definition egcpool.h:296
Here is the caller graph for this function:

◆ nccell_load()

API int nccell_load ( struct ncplane n,
nccell c,
const char *  gcluster 
)

Definition at line 1833 of file notcurses.c.

1833 {
1834 int cols;
1835 int bytes = utf8_egc_len(gcluster, &cols);
1836 return pool_load_direct(&n->pool, c, gcluster, bytes, cols);
1837}
Here is the caller graph for this function:

◆ nccell_release()

API void nccell_release ( struct ncplane n,
nccell c 
)

Definition at line 128 of file render.c.

128 {
129 pool_release(&n->pool, c);
130}
Here is the caller graph for this function:

◆ ncdplot_add_sample()

API int ncdplot_add_sample ( struct ncdplot *  n,
uint64_t  x,
double  y 
)

Definition at line 709 of file plot.c.

712 {
713 if(n){
714 ncplot_destroy(&n->plot);
715 free(n->slots);
716 free(n);
717 }
718}
719
720// takes ownership of n on all paths
721ncdplot* ncdplot_create(ncplane* n, const ncplot_options* opts, double miny, double maxy){
722 ncdplot* ret = malloc(sizeof(*ret));
723 if(ret == NULL){
725 return NULL;
726 }
727 memset(ret, 0, sizeof(*ret));
728 const struct blitset* bset = create_double(ret, n, opts, miny, maxy, -DBL_MAX, DBL_MAX);
729 if(bset == NULL){ // create_double() destroys n on error
730 ncdplot_destroy(ret);
731 return NULL;
732 }
733 return ret;
734}
735
736ncplane* ncdplot_plane(ncdplot* n){
737 return n->plot.ncp;
738}
739
740int ncdplot_add_sample(ncdplot* n, uint64_t x, double y){
741 return add_sample_double(n, x, y);
742}
743
744int ncdplot_set_sample(ncdplot* n, uint64_t x, double y){
745 if(window_slide_double(n, x)){
746 return -1;
747 }
748 update_sample_double(n, x, y, true);
750 return -1;
751 }
752 return redraw_plot_double(n);
753}
754
755int ncuplot_sample(const ncuplot* n, uint64_t x, uint64_t* y){
756 return sample_uint64_t(n, x, y);
757}
758
759int ncdplot_sample(const ncdplot* n, uint64_t x, double* y){
760 return sample_double(n, x, y);
761}
762
763void ncdplot_destroy(ncdplot* n) {
764 if(n){
765 ncplot_destroy(&n->plot);
766 free(n->slots);
767 free(n);
768 }
769}
int ncplane_destroy(ncplane *ncp)
Definition notcurses.c:1018
int y
Definition notcurses.h:1905
int int x
Definition notcurses.h:1905
int ncdplot_add_sample(ncdplot *n, uint64_t x, double y)
Definition plot.c:709
ncplane * ncdplot_plane(ncdplot *n)
Definition plot.c:705
int ncdplot_set_sample(ncdplot *n, uint64_t x, double y)
Definition plot.c:713
void ncdplot_destroy(ncdplot *n)
Definition plot.c:732
ncdplot * ncdplot_create(ncplane *n, const ncplot_options *opts, double miny, double maxy)
Definition plot.c:690
int ncdplot_sample(const ncdplot *n, uint64_t x, double *y)
Definition plot.c:728
int ncuplot_sample(const ncuplot *n, uint64_t x, uint64_t *y)
Definition plot.c:724
int update_domain_double(ncdplot *ncp, uint64_t x)
Definition plot.c:603
Here is the caller graph for this function:

◆ ncdplot_create()

API ALLOC struct ncdplot * ncdplot_create ( struct ncplane n,
const ncplot_options opts,
double  miny,
double  maxy 
)

Definition at line 690 of file plot.c.

693 {
694 return n->plot.ncp;
695}
696
697int ncuplot_add_sample(ncuplot* n, uint64_t x, uint64_t y){
698 return add_sample_uint64_t(n, x, y);
699}
700
701int ncuplot_set_sample(ncuplot* n, uint64_t x, uint64_t y){
702 if(window_slide_uint64_t(n, x)){
703 return -1;
int ncuplot_set_sample(ncuplot *n, uint64_t x, uint64_t y)
Definition plot.c:670
int ncuplot_add_sample(ncuplot *n, uint64_t x, uint64_t y)
Definition plot.c:666
Here is the caller graph for this function:

◆ ncdplot_destroy()

API void ncdplot_destroy ( struct ncdplot *  n)

Definition at line 732 of file plot.c.

736 {
737 return n->plot.ncp;
738}
Here is the caller graph for this function:

◆ ncdplot_plane()

API struct ncplane * ncdplot_plane ( struct ncdplot *  n)

Definition at line 705 of file plot.c.

706 {
707 return -1;

◆ ncdplot_sample()

API int ncdplot_sample ( const struct ncdplot *  n,
uint64_t  x,
double *  y 
)

◆ ncdplot_set_sample()

API int ncdplot_set_sample ( struct ncdplot *  n,
uint64_t  x,
double  y 
)

Definition at line 713 of file plot.c.

713 {
714 ncplot_destroy(&n->plot);
715 free(n->slots);
716 free(n);
717 }
718}
719
720// takes ownership of n on all paths
721ncdplot* ncdplot_create(ncplane* n, const ncplot_options* opts, double miny, double maxy){
722 ncdplot* ret = malloc(sizeof(*ret));
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncfadectx_free()

API void ncfadectx_free ( struct ncfadectx nctx)

Definition at line 253 of file fade.c.

253 {
254 if(nctx){
255 free(nctx->channels);
256 free(nctx);
257 }
258}
uint64_t * channels
Definition fade.c:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncfadectx_iterations()

API int ncfadectx_iterations ( const struct ncfadectx nctx)

◆ ncfadectx_setup()

API ALLOC struct ncfadectx * ncfadectx_setup ( struct ncplane n)

Definition at line 249 of file fade.c.

249 {
250 return ncfadectx_setup_internal(n, NULL);
251}

◆ ncfdplane_create()

API ALLOC struct ncfdplane * ncfdplane_create ( struct ncplane n,
const ncfdplane_options opts,
int  fd,
ncfdplane_callback  cbfxn,
ncfdplane_done_cb  donecbfxn 
)

Definition at line 120 of file fd.c.

121 {
122 ncfdplane_options zeroed = {0};
123 if(!opts){
124 opts = &zeroed;
125 }
126 if(fd < 0 || !cbfxn || !donecbfxn){
127 return NULL;
128 }
129 return ncfdplane_create_internal(n, opts, fd, cbfxn, donecbfxn, true);
130}

◆ ncfdplane_destroy()

API int ncfdplane_destroy ( struct ncfdplane n)

Definition at line 136 of file fd.c.

136 {
137 int ret = 0;
138 if(n){
139 if(pthread_equal(pthread_self(), n->tid)){
140 n->destroyed = true; // ncfdplane_destroy_inner() is called on thread exit
141 }else{
142 void* vret = NULL;
143 ret |= cancel_and_join("fdplane", n->tid, &vret);
144 ret |= ncfdplane_destroy_inner(n);
145 }
146 }
147 return ret;
148}
Here is the caller graph for this function:

◆ ncfdplane_plane()

API struct ncplane * ncfdplane_plane ( struct ncfdplane n)

Definition at line 132 of file fd.c.

132 {
133 return n->ncp;
134}
Here is the caller graph for this function:

◆ ncmenu_create()

API ALLOC struct ncmenu * ncmenu_create ( struct ncplane n,
const ncmenu_options opts 
)

Definition at line 377 of file menu.c.

377 {
378 ncmenu_options zeroed = {0};
379 if(!opts){
380 opts = &zeroed;
381 }
382 if(opts->sectioncount <= 0 || !opts->sections){
383 logerror("invalid %d-ary section information", opts->sectioncount);
384 return NULL;
385 }
386 if(opts->flags >= (NCMENU_OPTION_HIDING << 1u)){
387 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
388 }
389 unsigned totalheight = 1;
390 unsigned totalwidth = 2; // start with two-character margin on the left
391 ncmenu* ret = malloc(sizeof(*ret));
392 ret->sectioncount = opts->sectioncount;
393 ret->sections = NULL;
394 unsigned dimy, dimx;
395 ncplane_dim_yx(n, &dimy, &dimx);
396 if(ret){
398 if(dup_menu_sections(ret, opts, &totalwidth, &totalheight) == 0){
399 ret->headerwidth = totalwidth;
400 if(totalwidth < dimx){
401 totalwidth = dimx;
402 }
403 struct ncplane_options nopts = {
404 .y = ret->bottom ? dimy - totalheight : 0,
405 .x = 0,
406 .rows = totalheight,
407 .cols = totalwidth,
408 .userptr = ret,
409 .name = "menu",
410 .resizecb = resize_menu,
411 .flags = NCPLANE_OPTION_FIXED,
412 };
413 ret->ncp = ncplane_create(n, &nopts);
414 if(ret->ncp){
415 if(ncplane_set_widget(ret->ncp, ret, (void(*)(void*))ncmenu_destroy) == 0){
416 ret->unrolledsection = -1;
417 ret->headerchannels = opts->headerchannels;
418 ret->dissectchannels = opts->headerchannels;
419 ncchannels_set_fg_rgb(&ret->dissectchannels, 0xdddddd);
420 ret->sectionchannels = opts->sectionchannels;
422 ncchannels_set_fg_rgb(&ret->disablechannels, 0xdddddd);
424 nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT);
425 nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT);
427 nccell_release(ret->ncp, &c);
428 if(write_header(ret) == 0){
429 return ret;
430 }
431 }
432 ncplane_destroy(ret->ncp);
433 }
434 free_menu_sections(ret);
435 }
436 free(ret);
437 }
438 logerror("error creating ncmenu");
439 return NULL;
440}
#define logwarn(fmt,...)
Definition logging.h:37
void ncmenu_destroy(ncmenu *n)
Definition menu.c:825
ncplane * ncplane_create(ncplane *n, const ncplane_options *nopts)
Definition notcurses.c:707
int ncplane_set_base_cell(ncplane *ncp, const nccell *c)
Definition notcurses.c:1558
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
Definition notcurses.c:301
#define NCMENU_OPTION_HIDING
Definition notcurses.h:4128
#define NCALPHA_TRANSPARENT
Definition notcurses.h:106
#define NCMENU_OPTION_BOTTOM
Definition notcurses.h:4127
#define NCCELL_TRIVIAL_INITIALIZER
Definition notcurses.h:737
#define NCPLANE_OPTION_FIXED
Definition notcurses.h:1454
void nccell_release(ncplane *n, nccell *c)
Definition render.c:128
Definition menu.c:25
int unrolledsection
Definition menu.c:29
uint64_t disablechannels
Definition menu.c:34
ncplane * ncp
Definition menu.c:26
uint64_t sectionchannels
Definition menu.c:33
ncmenu_int_section * sections
Definition menu.c:28
int headerwidth
Definition menu.c:30
int sectioncount
Definition menu.c:27
uint64_t headerchannels
Definition menu.c:31
bool bottom
Definition menu.c:35
uint64_t dissectchannels
Definition menu.c:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_destroy()

API bool API void ncmenu_destroy ( struct ncmenu n)

Definition at line 825 of file menu.c.

825 {
826 if(n){
827 free_menu_sections(n);
828 if(ncplane_set_widget(n->ncp, NULL, NULL) == 0){
829 ncplane_destroy(n->ncp);
830 }
831 free(n);
832 }
833}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_item_set_status()

API int ncmenu_item_set_status ( struct ncmenu n,
const char *  section,
const char *  item,
bool  enabled 
)

Definition at line 784 of file menu.c.

785 {
786 for(int si = 0 ; si < n->sectioncount ; ++si){
787 struct ncmenu_int_section* sec = &n->sections[si];
788 if(strcmp(sec->name, section) == 0){
789 for(unsigned ii = 0 ; ii < sec->itemcount ; ++ii){
790 struct ncmenu_int_item* i = &sec->items[ii];
791 if(strcmp(i->desc, item) == 0){
792 const bool changed = (i->disabled != enabled);
793 i->disabled = !enabled;
794 if(changed){
795 if(i->disabled){
796 if(--sec->enabled_item_count == 0){
797 write_header(n);
798 }
799 }else{
800 if(++sec->enabled_item_count == 1){
801 write_header(n);
802 }
803 }
804 if(n->unrolledsection == si){
805 if(sec->enabled_item_count == 0){
807 }else{
808 ncmenu_unroll(n, n->unrolledsection);
809 }
810 }
811 }
812 return 0;
813 }
814 }
815 break;
816 }
817 }
818 return -1;
819}
int ncmenu_rollup(ncmenu *n)
Definition menu.c:554
int ncmenu_unroll(ncmenu *n, int sectionidx)
Definition menu.c:452
char * desc
Definition menu.c:5
bool disabled
Definition menu.c:10
ncmenu_int_item * items
Definition menu.c:16
char * name
Definition menu.c:14
unsigned itemcount
Definition menu.c:15
int enabled_item_count
Definition menu.c:22
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_mouse_selected()

API const char * ncmenu_mouse_selected ( const struct ncmenu n,
const ncinput click,
ncinput ni 
)

◆ ncmenu_nextitem()

API int ncmenu_nextitem ( struct ncmenu n)

Definition at line 593 of file menu.c.

593 {
594 if(n->unrolledsection == -1){
595 if(ncmenu_unroll(n, 0)){
596 return -1;
597 }
598 }
599 ncmenu_int_section* sec = &n->sections[n->unrolledsection];
600 int origselected = sec->itemselected;
601 if(origselected >= 0){
602 do{
603 if((unsigned)++sec->itemselected == sec->itemcount){
604 sec->itemselected = 0;
605 }
606 if(sec->itemselected == origselected){
607 break;
608 }
609 }while(!sec->items[sec->itemselected].desc || sec->items[sec->itemselected].disabled);
610 }
611 return ncmenu_unroll(n, n->unrolledsection);
612}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_nextsection()

API int ncmenu_nextsection ( struct ncmenu n)

Definition at line 563 of file menu.c.

563 {
564 int nextsection = n->unrolledsection;
565 int origselected = n->unrolledsection;
566 do{
567 if(++nextsection == n->sectioncount){
568 nextsection = 0;
569 }
570 if(nextsection == origselected){
571 break;
572 }
573 }while(n->sections[nextsection].name == NULL ||
574 n->sections[nextsection].enabled_item_count == 0);
575 return ncmenu_unroll(n, nextsection);
576}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_offer_input()

API bool ncmenu_offer_input ( struct ncmenu n,
const ncinput nc 
)

◆ ncmenu_plane()

API struct ncplane * ncmenu_plane ( struct ncmenu n)

Definition at line 821 of file menu.c.

821 {
822 return menu->ncp;
823}

◆ ncmenu_previtem()

API int ncmenu_previtem ( struct ncmenu n)

Definition at line 614 of file menu.c.

614 {
615 if(n->unrolledsection == -1){
616 if(ncmenu_unroll(n, 0)){
617 return -1;
618 }
619 }
620 ncmenu_int_section* sec = &n->sections[n->unrolledsection];
621 int origselected = sec->itemselected;
622 if(origselected >= 0){
623 do{
624 if(sec->itemselected-- == 0){
625 sec->itemselected = sec->itemcount - 1;
626 }
627 if(sec->itemselected == origselected){
628 break;
629 }
630 }while(!sec->items[sec->itemselected].desc || sec->items[sec->itemselected].disabled);
631 }
632 return ncmenu_unroll(n, n->unrolledsection);
633}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_prevsection()

API int ncmenu_prevsection ( struct ncmenu n)

Definition at line 578 of file menu.c.

578 {
579 int prevsection = n->unrolledsection;
580 int origselected = n->unrolledsection;
581 do{
582 if(--prevsection < 0){
583 prevsection = n->sectioncount - 1;
584 }
585 if(prevsection == origselected){
586 break;
587 }
588 }while(n->sections[prevsection].name == NULL ||
589 n->sections[prevsection].enabled_item_count == 0);
590 return ncmenu_unroll(n, prevsection);
591}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_rollup()

API int ncmenu_rollup ( struct ncmenu n)

Definition at line 554 of file menu.c.

554 {
555 if(n->unrolledsection < 0){
556 return 0;
557 }
558 n->unrolledsection = -1;
559 ncplane_erase(n->ncp);
560 return write_header(n);
561}
void ncplane_erase(ncplane *n)
Definition notcurses.c:2458
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmenu_selected()

API const char * ncmenu_selected ( const struct ncmenu n,
ncinput ni 
)

◆ ncmenu_unroll()

API int ncmenu_unroll ( struct ncmenu n,
int  sectionidx 
)

Definition at line 452 of file menu.c.

452 {
453 if(ncmenu_rollup(n)){ // roll up any unrolled section
454 return -1;
455 }
456 if(sectionidx < 0 || sectionidx >= n->sectioncount){
457 logerror("unrolled invalid sectionidx %d", sectionidx);
458 return -1;
459 }
460 if(n->sections[sectionidx].enabled_item_count <= 0){
461 return 0;
462 }
463 if(n->sections[sectionidx].name == NULL){
464 return -1;
465 }
466 n->unrolledsection = sectionidx;
467 unsigned dimy, dimx;
468 ncplane_dim_yx(n->ncp, &dimy, &dimx);
469 const int height = section_height(n, sectionidx);
470 const int width = section_width(n, sectionidx);
471 int xpos = n->sections[sectionidx].xoff < 0 ?
472 (int)dimx + (n->sections[sectionidx].xoff - 2) : n->sections[sectionidx].xoff;
473 if(xpos + width >= (int)dimx){
474 xpos = dimx - (width + 2);
475 }
476 int ypos = n->bottom ? dimy - height - 1 : 1;
477 if(ncplane_cursor_move_yx(n->ncp, ypos, xpos)){
478 return -1;
479 }
480 if(ncplane_rounded_box_sized(n->ncp, 0, n->headerchannels, height, width, 0)){
481 return -1;
482 }
483 ncmenu_int_section* sec = &n->sections[sectionidx];
484 for(unsigned i = 0 ; i < sec->itemcount ; ++i){
485 ++ypos;
486 if(sec->items[i].desc){
487 // FIXME the user ought be able to configure the disabled channel
488 if(!sec->items[i].disabled){
489 ncplane_set_channels(n->ncp, n->sectionchannels);
490 if(sec->itemselected < 0){
491 sec->itemselected = i;
492 }
493 }else{
494 ncplane_set_channels(n->ncp, n->disablechannels);
495 }
496 if(sec->itemselected >= 0){
497 if(i == (unsigned)sec->itemselected){
498 ncplane_set_channels(n->ncp, ncchannels_reverse(ncplane_channels(n->ncp)));
499 }
500 }
501 ncplane_set_styles(n->ncp, 0);
502 int cols = ncplane_putstr_yx(n->ncp, ypos, xpos + 1, sec->items[i].desc);
503 if(cols < 0){
504 return -1;
505 }
506 // we need pad out the remaining columns of this line with spaces. if
507 // there's a shortcut description, we align it to the right, printing
508 // spaces only through the start of the aligned description.
509 int thiswidth = width;
510 if(sec->items[i].shortdesc){
511 thiswidth -= sec->items[i].shortdesccols;
512 }
513 // print any necessary padding spaces
514 for(int j = cols + 1 ; j < thiswidth - 1 ; ++j){
515 if(ncplane_putchar(n->ncp, ' ') < 0){
516 return -1;
517 }
518 }
519 if(sec->items[i].shortdesc){
520 if(ncplane_putstr(n->ncp, sec->items[i].shortdesc) < 0){
521 return -1;
522 }
523 }
524 if(sec->items[i].shortcut_offset >= 0){
526 if(ncplane_at_yx_cell(n->ncp, ypos, xpos + 1 + sec->items[i].shortcut_offset, &cl) < 0){
527 return -1;
528 }
529 nccell_on_styles(&cl, NCSTYLE_UNDERLINE|NCSTYLE_BOLD);
530 if(ncplane_putc_yx(n->ncp, ypos, xpos + 1 + sec->items[i].shortcut_offset, &cl) < 0){
531 return -1;
532 }
533 nccell_release(n->ncp, &cl);
534 }
535 }else{
536 n->ncp->channels = n->headerchannels;
537 ncplane_set_styles(n->ncp, 0);
538 if(ncplane_putegc_yx(n->ncp, ypos, xpos, "├", NULL) < 0){
539 return -1;
540 }
541 for(int j = 1 ; j < width - 1 ; ++j){
542 if(ncplane_putegc(n->ncp, "─", NULL) < 0){
543 return -1;
544 }
545 }
546 if(ncplane_putegc(n->ncp, "┤", NULL) < 0){
547 return -1;
548 }
549 }
550 }
551 return 0;
552}
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
Definition notcurses.c:720
void ncplane_set_channels(ncplane *n, uint64_t channels)
Definition notcurses.c:1494
void ncplane_set_styles(ncplane *n, unsigned stylebits)
Definition notcurses.c:2071
int ncplane_putegc_yx(ncplane *n, int y, int x, const char *gclust, size_t *sbytes)
Definition notcurses.c:1995
int ncplane_at_yx_cell(ncplane *n, int y, int x, nccell *c)
Definition notcurses.c:270
uint64_t ncplane_channels(const ncplane *n)
Definition notcurses.c:1490
int ncplane_putc_yx(ncplane *n, int y, int x, const nccell *c)
Definition notcurses.c:1980
#define NCSTYLE_UNDERLINE
Definition notcurses.h:771
#define NCSTYLE_BOLD
Definition notcurses.h:773
int shortdesccols
Definition menu.c:9
char * shortdesc
Definition menu.c:8
int shortcut_offset
Definition menu.c:7
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_create()

API ALLOC struct ncmultiselector * ncmultiselector_create ( struct ncplane n,
const ncmultiselector_options opts 
)

Definition at line 885 of file selector.c.

885 {
887 logerror("won't use the standard plane"); // would fail later on resize
888 return NULL;
889 }
890 ncmultiselector_options zeroed = {0};
891 if(!opts){
892 opts = &zeroed;
893 }
894 if(opts->flags > 0){
895 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
896 }
897 unsigned itemcount = 0;
898 if(opts->items){
899 for(const struct ncmselector_item* i = opts->items ; i->option ; ++i){
900 ++itemcount;
901 }
902 }
903 ncmultiselector* ns = malloc(sizeof(*ns));
904 if(ns == NULL){
905 return NULL;
906 }
907 memset(ns, 0, sizeof(*ns));
908 ns->title = opts->title ? strdup(opts->title) : NULL;
909 ns->titlecols = opts->title ? ncstrwidth(opts->title, NULL, NULL) : 0;
910 ns->secondary = opts->secondary ? strdup(opts->secondary) : NULL;
911 ns->secondarycols = opts->secondary ? ncstrwidth(opts->secondary, NULL, NULL) : 0;
912 ns->footer = opts->footer ? strdup(opts->footer) : NULL;
913 ns->footercols = opts->footer ? ncstrwidth(opts->footer, NULL, NULL) : 0;
914 ns->current = 0;
915 ns->startdisp = 0;
916 ns->longitem = 0;
917 ns->maxdisplay = opts->maxdisplay;
918 ns->opchannels = opts->opchannels;
919 ns->boxchannels = opts->boxchannels;
920 ns->descchannels = opts->descchannels;
921 ns->titlechannels = opts->titlechannels;
922 ns->footchannels = opts->footchannels;
923 ns->boxchannels = opts->boxchannels;
924 ns->darrowy = ns->uarrowy = ns->arrowx = -1;
925 if(itemcount){
926 if(!(ns->items = malloc(sizeof(*ns->items) * itemcount))){
927 goto freeitems;
928 }
929 }else{
930 ns->items = NULL;
931 }
932 for(ns->itemcount = 0 ; ns->itemcount < itemcount ; ++ns->itemcount){
933 const struct ncmselector_item* src = &opts->items[ns->itemcount];
934 int unsafe = ncstrwidth(src->option, NULL, NULL);
935 if(unsafe < 0){
936 goto freeitems;
937 }
938 unsigned cols = unsafe;
939 if(cols > ns->longitem){
940 ns->longitem = cols;
941 }
942 unsafe = ncstrwidth(src->desc, NULL, NULL);
943 if(unsafe < 0){
944 goto freeitems;
945 }
946 unsigned cols2 = unsafe;
947 if(cols + cols2 > ns->longitem){
948 ns->longitem = cols + cols2;
949 }
950 ns->items[ns->itemcount].option = strdup(src->option);
951 ns->items[ns->itemcount].desc = strdup(src->desc);
952 ns->items[ns->itemcount].selected = src->selected;
953 if(!(ns->items[ns->itemcount].desc && ns->items[ns->itemcount].option)){
954 free(ns->items[ns->itemcount].option);
955 free(ns->items[ns->itemcount].desc);
956 goto freeitems;
957 }
958 }
959 unsigned dimy, dimx;
960 ns->ncp = n;
961 if(ncmultiselector_dim_yx(ns, &dimy, &dimx)){
962 goto freeitems;
963 }
964 if(ncplane_resize_simple(ns->ncp, dimy, dimx)){
965 goto freeitems;
966 }
967 if(ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncmultiselector_destroy)){
968 goto freeitems;
969 }
970 ncmultiselector_draw(ns); // deal with error here?
971 return ns;
972
973freeitems:
974 while(ns->itemcount--){
975 free(ns->items[ns->itemcount].option);
976 free(ns->items[ns->itemcount].desc);
977 }
978 free(ns->items);
979 free(ns->title); free(ns->secondary); free(ns->footer);
980 free(ns);
982 return NULL;
983}
ncplane * notcurses_stdplane(notcurses *nc)
Definition notcurses.c:699
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
Definition notcurses.c:3309
void ncmultiselector_destroy(ncmultiselector *n)
Definition selector.c:985
char * option
Definition selector.c:12
const char * option
Definition notcurses.h:3968
const char * desc
Definition notcurses.h:3969
char * secondary
Definition selector.c:50
unsigned maxdisplay
Definition selector.c:44
ncplane * ncp
Definition selector.c:41
uint64_t footchannels
Definition selector.c:57
unsigned longitem
Definition selector.c:45
unsigned startdisp
Definition selector.c:43
uint64_t descchannels
Definition selector.c:55
uint64_t titlechannels
Definition selector.c:56
unsigned itemcount
Definition selector.c:47
unsigned titlecols
Definition selector.c:49
uint64_t boxchannels
Definition selector.c:58
unsigned current
Definition selector.c:42
unsigned secondarycols
Definition selector.c:51
struct ncmselector_int * items
Definition selector.c:46
unsigned footercols
Definition selector.c:53
char * footer
Definition selector.c:52
uint64_t opchannels
Definition selector.c:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_destroy()

API bool API void ncmultiselector_destroy ( struct ncmultiselector n)

Definition at line 985 of file selector.c.

985 {
986 if(n){
987 while(n->itemcount--){
988 free(n->items[n->itemcount].option);
989 free(n->items[n->itemcount].desc);
990 }
991 if(ncplane_set_widget(n->ncp, NULL, NULL) == 0){
992 ncplane_destroy(n->ncp);
993 }
994 free(n->items);
995 free(n->title);
996 free(n->secondary);
997 free(n->footer);
998 free(n);
999 }
1000}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncmultiselector_offer_input()

API bool ncmultiselector_offer_input ( struct ncmultiselector n,
const ncinput nc 
)

◆ ncmultiselector_plane()

API struct ncplane * ncmultiselector_plane ( struct ncmultiselector n)

Definition at line 586 of file selector.c.

586 {
587 return n->ncp;
588}

◆ ncmultiselector_selected()

API int ncmultiselector_selected ( struct ncmultiselector n,
bool *  selected,
unsigned  count 
)

Definition at line 1002 of file selector.c.

1002 {
1003 if(n->itemcount != count || n->itemcount < 1){
1004 return -1;
1005 }
1006 while(--count){
1007 selected[count] = n->items[count].selected;
1008 }
1009 return 0;
1010}
Here is the caller graph for this function:

◆ ncnmetric()

API const char * ncnmetric ( uintmax_t  val,
size_t  s,
uintmax_t  decimal,
char *  buf,
int  omitdec,
uintmax_t  mult,
int  uprefix 
)

Definition at line 28 of file metric.c.

30 {
31 fesetround(FE_TONEAREST); // FIXME global to the process...ick :/
32 // these two must have the same number of elements
33 const wchar_t* subprefixes = SUBPREFIXES;
34 const wchar_t prefixes[] = L"KMGTPEZY"; // 10^21-1 encompasses 2^64-1
35 if(decimal == 0 || mult == 0){
36 return NULL;
37 }
38 if(decimal > UINTMAX_MAX / 10){
39 return NULL;
40 }
41 unsigned consumed = 0;
42 uintmax_t dv = mult;
43 if(decimal <= val || val == 0){
44 // FIXME verify that input < 2^89
45 while((val / decimal) >= dv && consumed < sizeof(prefixes) / sizeof(*prefixes)){
46 dv *= mult;
47 ++consumed;
48 if(UINTMAX_MAX / dv < mult){ // near overflow--can't scale dv again
49 break;
50 }
51 }
52 }else{
53 while(val < decimal && consumed < sizeof(prefixes) / sizeof(*prefixes)){
54 val *= mult;
55 ++consumed;
56 if(UINTMAX_MAX / dv < mult){ // near overflow--can't scale dv again
57 break;
58 }
59 }
60 }
61 int sprintfed;
62 if(dv != mult){ // if consumed == 0, dv must equal mult
63 if((val / decimal) / dv > 0){
64 ++consumed;
65 }else{
66 dv /= mult;
67 }
68 val /= decimal;
69 // Remainder is val % dv, but we want a percentage as scaled integer.
70 // Ideally we would multiply by 100 and divide the result by dv, for
71 // maximum accuracy (dv might not be a multiple of 10--it is not for
72 // 1,024). That can overflow with large 64-bit values, but we can first
73 // divide both sides by mult, and then scale by 100.
74 if(omitdec && (val % dv) == 0){
75 sprintfed = snprintf(buf, s, "%" PRIu64 "%lc", (uint64_t)(val / dv),
76 (wint_t)prefixes[consumed - 1]);
77 }else{
78 sprintfed = snprintf(buf, s, "%.2f%lc", (double)val / dv,
79 (wint_t)prefixes[consumed - 1]);
80 }
81 if(sprintfed < 0){
82 return NULL;
83 }
84 if(uprefix){
85 if((size_t)sprintfed < s){
86 buf[sprintfed] = uprefix;
87 buf[++sprintfed] = '\0';
88 }
89 }
90 return buf;
91 }
92 // unscaled output, consumed == 0, dv == mult
93 // val / decimal < dv (or we ran out of prefixes)
94 if(omitdec && val % decimal == 0){
95 if(consumed){
96 sprintfed = snprintf(buf, s, "%" PRIu64 "%lc", (uint64_t)(val / decimal),
97 (wint_t)subprefixes[consumed - 1]);
98 }else{
99 sprintfed = snprintf(buf, s, "%" PRIu64, (uint64_t)(val / decimal));
100 }
101 }else{
102 if(consumed){
103 sprintfed = snprintf(buf, s, "%.2f%lc", (double)val / decimal,
104 (wint_t)subprefixes[consumed - 1]);
105 }else{
106 sprintfed = snprintf(buf, s, "%.2f", (double)val / decimal);
107 }
108 }
109 if(sprintfed < 0){
110 return NULL;
111 }
112 if(consumed && uprefix){
113 if((size_t)sprintfed < s){
114 buf[sprintfed] = uprefix;
115 buf[++sprintfed] = '\0';
116 }
117 }
118 return buf;
119}

◆ ncpalette_free()

API void ncpalette_free ( ncpalette p)

Definition at line 2586 of file notcurses.c.

2586 {
2587 free(p);
2588}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncpalette_new()

API ALLOC ncpalette * ncpalette_new ( struct notcurses nc)

Definition at line 2563 of file notcurses.c.

2563 {
2564 ncpalette* p = malloc(sizeof(*p));
2565 if(p){
2566 memcpy(p, &nc->palette, sizeof(*p));
2567 }
2568 return p;
2569}
ncpalette palette
Definition internal.h:366
Here is the caller graph for this function:

◆ ncpalette_use()

API int ncpalette_use ( struct notcurses nc,
const ncpalette p 
)

◆ ncpile_bottom()

API struct ncplane * ncpile_bottom ( struct ncplane n)

Definition at line 2544 of file notcurses.c.

2544 {
2545 return ncplane_pile(n)->bottom;
2546}
Here is the caller graph for this function:

◆ ncpile_create()

API ALLOC struct ncplane API ALLOC struct ncplane * ncpile_create ( struct notcurses nc,
const ncplane_options nopts 
)

◆ ncpile_rasterize()

API int ncpile_rasterize ( struct ncplane n)

Definition at line 1517 of file render.c.

1517 {
1518 struct timespec start, rasterdone, writedone;
1519 clock_gettime(CLOCK_MONOTONIC, &start);
1520 ncpile* pile = ncplane_pile(n);
1521 struct notcurses* nc = ncpile_notcurses(pile);
1522 const struct tinfo* ti = &ncplane_notcurses_const(n)->tcache;
1523 postpaint(nc, ti, nc->lastframe, pile->dimy, pile->dimx, pile->crender, &nc->pool);
1524 clock_gettime(CLOCK_MONOTONIC, &rasterdone);
1525 int bytes = notcurses_rasterize(nc, pile, &nc->rstate.f);
1526 clock_gettime(CLOCK_MONOTONIC, &writedone);
1527 pthread_mutex_lock(&nc->stats.lock);
1528 // accepts negative |bytes| as an indication of failure
1529 update_raster_bytes(&nc->stats.s, bytes);
1530 update_raster_stats(&rasterdone, &start, &nc->stats.s);
1531 update_write_stats(&writedone, &rasterdone, &nc->stats.s, bytes);
1532 pthread_mutex_unlock(&nc->stats.lock);
1533 // we want to refresh if the screen geometry changed (or if we were just
1534 // woken up from SIGSTOP), but we mustn't do so until after rasterizing
1535 // the solved rvec, since this might result in a geometry update.
1539 }
1540 if(bytes < 0){
1541 return -1;
1542 }
1543 return 0;
1544}
void update_write_stats(const struct timespec *time1, const struct timespec *time0, ncstats *stats, int bytes)
Definition stats.c:5
void update_raster_stats(const struct timespec *time1, const struct timespec *time0, ncstats *stats)
Definition stats.c:58
void update_raster_bytes(ncstats *stats, int bytes)
Definition stats.c:27
const notcurses * ncplane_notcurses_const(const ncplane *n)
Definition notcurses.c:2630
sig_atomic_t sigcont_seen_for_render
Definition render.c:7
int notcurses_refresh(notcurses *nc, unsigned *restrict dimy, unsigned *restrict dimx)
Definition render.c:1417
unsigned dimx
Definition internal.h:325
unsigned dimy
Definition internal.h:325
struct crender * crender
Definition internal.h:321
ncstats s
Definition internal.h:247
pthread_mutex_t lock
Definition internal.h:246
rasterstate rstate
Definition internal.h:336
nccell * lastframe
Definition internal.h:341
ncsharedstats stats
Definition internal.h:356
tinfo tcache
Definition internal.h:360
egcpool pool
Definition internal.h:348
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncpile_render()

API int ncpile_render ( struct ncplane n)

Definition at line 1569 of file render.c.

1569 {
1570 scroll_lastframe(ncplane_notcurses(n), ncplane_pile(n)->scrolls);
1571 struct timespec start, renderdone;
1572 clock_gettime(CLOCK_MONOTONIC, &start);
1574 ncpile* pile = ncplane_pile(n);
1575 // update our notion of screen geometry, and render against that
1576 unsigned pgeo_changed = 0;
1577 notcurses_resize_internal(n, NULL, NULL);
1578 if(pile->cellpxy != nc->tcache.cellpxy || pile->cellpxx != nc->tcache.cellpxx){
1579 pile->cellpxy = nc->tcache.cellpxy;
1580 pile->cellpxx = nc->tcache.cellpxx;
1581 pgeo_changed = 1;
1582 }
1583 if(engorge_crender_vector(pile)){
1584 return -1;
1585 }
1586 ncpile_render_internal(pile, pgeo_changed);
1587 clock_gettime(CLOCK_MONOTONIC, &renderdone);
1588 pthread_mutex_lock(&nc->stats.lock);
1589 update_render_stats(&renderdone, &start, &nc->stats.s);
1590 pthread_mutex_unlock(&nc->stats.lock);
1591 return 0;
1592}
void update_render_stats(const struct timespec *time1, const struct timespec *time0, ncstats *stats)
Definition stats.c:40
unsigned cellpxx
Definition internal.h:326
unsigned cellpxy
Definition internal.h:326
unsigned cellpxx
Definition termdesc.h:117
unsigned cellpxy
Definition termdesc.h:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncpile_render_to_buffer()

API int ncpile_render_to_buffer ( struct ncplane p,
char **  buf,
size_t *  buflen 
)

◆ ncpile_render_to_file()

API int API int ncpile_render_to_file ( struct ncplane p,
FILE *  fp 
)

◆ ncpile_top()

API struct ncplane * ncpile_top ( struct ncplane n)

Definition at line 2540 of file notcurses.c.

2540 {
2541 return ncplane_pile(n)->top;
2542}
Here is the caller graph for this function:

◆ ncplane_above()

API struct ncplane * ncplane_above ( struct ncplane n)

Definition at line 2552 of file notcurses.c.

2552 {
2553 return n->above;
2554}
Here is the caller graph for this function:

◆ ncplane_abs_x()

API int ncplane_abs_x ( const struct ncplane n)

◆ ncplane_abs_y()

API int ncplane_abs_y ( const struct ncplane n)

◆ ncplane_abs_yx()

API void ncplane_abs_yx ( const struct ncplane n,
int *RESTRICT  y,
int *RESTRICT  x 
)

◆ ncplane_as_rgba()

API ALLOC uint32_t * ncplane_as_rgba ( const struct ncplane n,
ncblitter_e  blit,
int  begy,
int  begx,
unsigned  leny,
unsigned  lenx,
unsigned *  pxdimy,
unsigned *  pxdimx 
)

◆ ncplane_at_cursor()

API char * ncplane_at_cursor ( const struct ncplane n,
uint16_t *  stylemask,
uint64_t *  channels 
)

◆ ncplane_at_cursor_cell()

API int ncplane_at_cursor_cell ( struct ncplane n,
nccell c 
)

◆ ncplane_at_yx()

API int API char * ncplane_at_yx ( const struct ncplane n,
int  y,
int  x,
uint16_t *  stylemask,
uint64_t *  channels 
)

◆ ncplane_at_yx_cell()

API int ncplane_at_yx_cell ( struct ncplane n,
int  y,
int  x,
nccell c 
)

◆ ncplane_autogrow_p()

API bool ncplane_autogrow_p ( const struct ncplane n)

◆ ncplane_base()

API int ncplane_base ( struct ncplane n,
nccell c 
)

Definition at line 1569 of file notcurses.c.

1569 {
1570 return nccell_duplicate(ncp, c, &ncp->basecell);
1571}
int nccell_duplicate(ncplane *n, nccell *targ, const nccell *c)
Definition render.c:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_below()

API struct ncplane * ncplane_below ( struct ncplane n)

Definition at line 2548 of file notcurses.c.

2548 {
2549 return n->below;
2550}
Here is the caller graph for this function:

◆ ncplane_box()

API int ncplane_box ( struct ncplane n,
const nccell ul,
const nccell ur,
const nccell ll,
const nccell lr,
const nccell hline,
const nccell vline,
unsigned  ystop,
unsigned  xstop,
unsigned  ctlword 
)

Definition at line 2271 of file notcurses.c.

2274 {
2275 unsigned yoff, xoff;
2276 ncplane_cursor_yx(n, &yoff, &xoff);
2277 // must be at least 2x2, with its upper-left corner at the current cursor
2278 if(ystop < yoff + 1){
2279 logerror("ystop (%u) insufficient for yoff (%d)", ystop, yoff);
2280 return -1;
2281 }
2282 if(xstop < xoff + 1){
2283 logerror("xstop (%u) insufficient for xoff (%d)", xstop, xoff);
2284 return -1;
2285 }
2286 unsigned ymax, xmax;
2287 ncplane_dim_yx(n, &ymax, &xmax);
2288 // must be within the ncplane
2289 if(xstop >= xmax || ystop >= ymax){
2290 logerror("boundary (%ux%u) beyond plane (%dx%d)", ystop, xstop, ymax, xmax);
2291 return -1;
2292 }
2293 unsigned edges;
2294 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_LEFT);
2295 if(edges >= box_corner_needs(ctlword)){
2296 if(ncplane_putc(n, ul) < 0){
2297 return -1;
2298 }
2299 }
2300 if(!(ctlword & NCBOXMASK_TOP)){ // draw top border, if called for
2301 if(xstop - xoff >= 2){
2302 if(ncplane_cursor_move_yx(n, yoff, xoff + 1)){
2303 return -1;
2304 }
2305 if(!(ctlword & NCBOXGRAD_TOP)){ // cell styling, hl
2306 if(ncplane_hline(n, hl, xstop - xoff - 1) < 0){
2307 return -1;
2308 }
2309 }else{ // gradient, ul -> ur
2310 if(ncplane_hline_interp(n, hl, xstop - xoff - 1, ul->channels, ur->channels) < 0){
2311 return -1;
2312 }
2313 }
2314 }
2315 }
2316 edges = !(ctlword & NCBOXMASK_TOP) + !(ctlword & NCBOXMASK_RIGHT);
2317 if(edges >= box_corner_needs(ctlword)){
2318 if(ncplane_cursor_move_yx(n, yoff, xstop)){
2319 return -1;
2320 }
2321 if(ncplane_putc(n, ur) < 0){
2322 return -1;
2323 }
2324 }
2325 ++yoff;
2326 // middle rows (vertical lines)
2327 if(yoff < ystop){
2328 if(!(ctlword & NCBOXMASK_LEFT)){
2329 if(ncplane_cursor_move_yx(n, yoff, xoff)){
2330 return -1;
2331 }
2332 if((ctlword & NCBOXGRAD_LEFT)){ // grad styling, ul->ll
2333 if(ncplane_vline_interp(n, vl, ystop - yoff, ul->channels, ll->channels) < 0){
2334 return -1;
2335 }
2336 }else{
2337 if(ncplane_vline(n, vl, ystop - yoff) < 0){
2338 return -1;
2339 }
2340 }
2341 }
2342 if(!(ctlword & NCBOXMASK_RIGHT)){
2343 if(ncplane_cursor_move_yx(n, yoff, xstop)){
2344 return -1;
2345 }
2346 if((ctlword & NCBOXGRAD_RIGHT)){ // grad styling, ur->lr
2347 if(ncplane_vline_interp(n, vl, ystop - yoff, ur->channels, lr->channels) < 0){
2348 return -1;
2349 }
2350 }else{
2351 if(ncplane_vline(n, vl, ystop - yoff) < 0){
2352 return -1;
2353 }
2354 }
2355 }
2356 }
2357 // bottom line
2358 yoff = ystop;
2359 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_LEFT);
2360 if(edges >= box_corner_needs(ctlword)){
2361 if(ncplane_cursor_move_yx(n, yoff, xoff)){
2362 return -1;
2363 }
2364 if(ncplane_putc(n, ll) < 0){
2365 return -1;
2366 }
2367 }
2368 if(!(ctlword & NCBOXMASK_BOTTOM)){
2369 if(xstop - xoff >= 2){
2370 if(ncplane_cursor_move_yx(n, yoff, xoff + 1)){
2371 return -1;
2372 }
2373 if(!(ctlword & NCBOXGRAD_BOTTOM)){ // cell styling, hl
2374 if(ncplane_hline(n, hl, xstop - xoff - 1) < 0){
2375 return -1;
2376 }
2377 }else{
2378 if(ncplane_hline_interp(n, hl, xstop - xoff - 1, ll->channels, lr->channels) < 0){
2379 return -1;
2380 }
2381 }
2382 }
2383 }
2384 edges = !(ctlword & NCBOXMASK_BOTTOM) + !(ctlword & NCBOXMASK_RIGHT);
2385 if(edges >= box_corner_needs(ctlword)){
2386 if(ncplane_cursor_move_yx(n, yoff, xstop)){
2387 return -1;
2388 }
2389 if(ncplane_putc(n, lr) < 0){
2390 return -1;
2391 }
2392 }
2393 return 0;
2394}
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 ul
Definition direct.h:215
API int API int API int uint64_t uint64_t ur
Definition direct.h:215
void ncplane_cursor_yx(const ncplane *n, unsigned *y, unsigned *x)
Definition notcurses.c:1741
int ncplane_hline_interp(ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2)
Definition notcurses.c:2153
int ncplane_vline_interp(ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2)
Definition notcurses.c:2209
#define NCBOXMASK_TOP
Definition notcurses.h:2601
#define NCBOXGRAD_RIGHT
Definition notcurses.h:2606
#define NCBOXMASK_LEFT
Definition notcurses.h:2604
#define NCBOXGRAD_BOTTOM
Definition notcurses.h:2607
#define NCBOXGRAD_LEFT
Definition notcurses.h:2608
#define NCBOXMASK_BOTTOM
Definition notcurses.h:2603
#define NCBOXMASK_RIGHT
Definition notcurses.h:2602
#define NCBOXGRAD_TOP
Definition notcurses.h:2605
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_center_abs()

API void ncplane_center_abs ( const struct ncplane n,
int *RESTRICT  y,
int *RESTRICT  x 
)

◆ ncplane_channels()

API uint64_t ncplane_channels ( const struct ncplane n)

◆ ncplane_contents()

API int API char * ncplane_contents ( struct ncplane n,
int  begy,
int  begx,
unsigned  leny,
unsigned  lenx 
)

Definition at line 3228 of file notcurses.c.

3228 {
3229 unsigned ystart, xstart;
3230 if(check_geometry_args(nc, begy, begx, &leny, &lenx, &ystart, &xstart)){
3231 return NULL;
3232 }
3233 size_t retlen = 1;
3234 char* ret = malloc(retlen);
3235 if(ret){
3236 for(unsigned y = ystart, targy = 0 ; y < ystart + leny ; ++y, targy += 2){
3237 for(unsigned x = xstart, targx = 0 ; x < xstart + lenx ; ++x, ++targx){
3239 // we need ncplane_at_yx_cell() here instead of ncplane_at_yx(),
3240 // because we should only have one copy of each wide EGC.
3241 int clen;
3242 if((clen = ncplane_at_yx_cell(nc, y, x, &ncl)) < 0){
3243 free(ret);
3244 return NULL;
3245 }
3246 const char* c = nccell_extended_gcluster(nc, &ncl);
3247 if(clen){
3248 char* tmp = realloc(ret, retlen + clen);
3249 if(!tmp){
3250 free(ret);
3251 return NULL;
3252 }
3253 ret = tmp;
3254 memcpy(ret + retlen - 1, c, clen);
3255 retlen += clen;
3256 }
3257 }
3258 }
3259 ret[retlen - 1] = '\0';
3260 }
3261 return ret;
3262}
const char * nccell_extended_gcluster(const ncplane *n, const nccell *c)
Definition notcurses.c:1573
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_create()

API ALLOC struct ncplane * ncplane_create ( struct ncplane n,
const ncplane_options nopts 
)
Here is the caller graph for this function:

◆ ncplane_cursor_move_rel()

API int ncplane_cursor_move_rel ( struct ncplane n,
int  y,
int  x 
)

Definition at line 750 of file notcurses.c.

750 {
751 if((int)n->y + y == -1){
752 logerror("invalid target y -1");
753 return -1;
754 }else if((int)n->x + x == -1){
755 logerror("invalid target x -1");
756 return -1;
757 }else return ncplane_cursor_move_yx(n, n->y + y, n->x + x);
758}
Here is the call graph for this function:

◆ ncplane_cursor_move_yx()

API int ncplane_cursor_move_yx ( struct ncplane n,
int  y,
int  x 
)

Definition at line 720 of file notcurses.c.

720 {
721 if(x < 0){
722 if(x < -1){
723 logerror("negative target x %d", x);
724 return -1;
725 }
726 }else if((unsigned)x >= n->lenx){
727 logerror("target x %d >= width %u", x, n->lenx);
728 return -1;
729 }else{
730 n->x = x;
731 }
732 if(y < 0){
733 if(y < -1){
734 logerror("negative target y %d", y);
735 return -1;
736 }
737 }else if((unsigned)y >= n->leny){
738 logerror("target y %d >= height %u", y, n->leny);
739 return -1;
740 }else{
741 n->y = y;
742 }
743 if(cursor_invalid_p(n)){
744 logerror("invalid cursor following move (%d/%d)", n->y, n->x);
745 return -1;
746 }
747 return 0;
748}
Here is the caller graph for this function:

◆ ncplane_cursor_yx()

API void ncplane_cursor_yx ( const struct ncplane n,
unsigned *RESTRICT  y,
unsigned *RESTRICT  x 
)

◆ ncplane_destroy()

API int ncplane_destroy ( struct ncplane n)

Definition at line 1018 of file notcurses.c.

1018 {
1019 if(ncp == NULL){
1020 return 0;
1021 }
1022 if(ncplane_notcurses(ncp)->stdplane == ncp){
1023 logerror("won't destroy standard plane");
1024 return -1;
1025 }
1026//notcurses_debug(ncplane_notcurses(ncp), stderr);
1027 loginfo("destroying %dx%d plane \"%s\" @ %dx%d",
1028 ncp->leny, ncp->lenx, ncp->name ? ncp->name : NULL, ncp->absy, ncp->absx);
1029 int ret = 0;
1030 // dissolve our binding from behind (->bprev is either NULL, or its
1031 // predecessor on the bound list's ->bnext, or &ncp->boundto->blist)
1032 if(ncp->bprev){
1033 if( (*ncp->bprev = ncp->bnext) ){
1034 ncp->bnext->bprev = ncp->bprev;
1035 }
1036 }else if(ncp->bnext){
1037 //assert(ncp->boundto->blist == ncp);
1038 ncp->bnext->bprev = NULL;
1039 }
1040 // recursively reparent our children to the plane to which we are bound.
1041 // this will extract each one from the sibling list.
1042 struct ncplane* bound = ncp->blist;
1043 while(bound){
1044 struct ncplane* tmp = bound->bnext;
1045 ncplane* bindto = ((ncp == ncp->boundto) ? bound : ncp->boundto);
1046 if(ncplane_reparent_family(bound, bindto) == NULL){
1047 ret = -1;
1048 }
1049 bound = tmp;
1050 }
1051 // extract ourselves from the z-axis. do this *after* reparenting, in case
1052 // reparenting shifts up the z-axis somehow (though i don't think it can,
1053 // at least not within a pile?).
1054 if(ncp->above){
1055 ncp->above->below = ncp->below;
1056 }else{
1057 ncplane_pile(ncp)->top = ncp->below;
1058 }
1059 if(ncp->below){
1060 ncp->below->above = ncp->above;
1061 }else{
1062 ncplane_pile(ncp)->bottom = ncp->above;
1063 }
1064 free_plane(ncp);
1065 return ret;
1066}
#define loginfo(fmt,...)
Definition logging.h:42
ncplane * ncplane_reparent_family(ncplane *n, ncplane *newparent)
Definition notcurses.c:2913
void free_plane(ncplane *p)
Definition notcurses.c:464
struct ncplane * below
Definition internal.h:94
struct ncplane * above
Definition internal.h:93
struct ncplane * blist
Definition internal.h:102
struct ncplane * boundto
Definition internal.h:103
struct ncplane * bnext
Definition internal.h:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_dim_yx()

API void ncplane_dim_yx ( const struct ncplane n,
unsigned *RESTRICT  y,
unsigned *RESTRICT  x 
)

◆ ncplane_dup()

API struct ncplane API struct ncplane API ALLOC struct ncplane * ncplane_dup ( const struct ncplane n,
void *  opaque 
)

◆ ncplane_erase()

API int API int API void ncplane_erase ( struct ncplane n)

Definition at line 2458 of file notcurses.c.

2458 {
2459 loginfo("erasing %dx%d plane", n->leny, n->lenx);
2460 if(n->sprite){
2461 sprixel_hide(n->sprite);
2462 destroy_tam(n);
2463 }
2464 // we must preserve the background, but a pure nccell_duplicate() would be
2465 // wiped out by the egcpool_dump(). do a duplication (to get the stylemask
2466 // and channels), and then reload.
2467 char* egc = nccell_strdup(n, &n->basecell);
2468 memset(n->fb, 0, sizeof(*n->fb) * n->leny * n->lenx);
2469 egcpool_dump(&n->pool);
2470 egcpool_init(&n->pool);
2471 // we need to zero out the EGC before handing this off to nccell_load, but
2472 // we don't want to lose the channels/attributes, so explicit gcluster load.
2473 n->basecell.gcluster = 0;
2474 nccell_load(n, &n->basecell, egc);
2475 free(egc);
2476 n->y = n->x = 0;
2477}
const char * egc
Definition egcpool.h:173
void sprixel_hide(sprixel *s)
Definition sprite.c:83
int nccell_load(ncplane *n, nccell *c, const char *gcluster)
Definition notcurses.c:1833
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_erase_region()

API int ncplane_erase_region ( struct ncplane n,
int  ystart,
int  xstart,
int  ylen,
int  xlen 
)

Definition at line 2479 of file notcurses.c.

2479 {
2480 if(ystart == -1){
2481 ystart = n->y;
2482 }
2483 if(xstart == -1){
2484 xstart = n->x;
2485 }
2486 if(ystart < 0 || xstart < 0){
2487 logerror("illegal start of erase (%d, %d)", ystart, xstart);
2488 return -1;
2489 }
2490 if(ystart >= (int)ncplane_dim_y(n) || xstart >= (int)ncplane_dim_x(n)){
2491 logerror("illegal start of erase (%d, %d)", ystart, xstart);
2492 return -1;
2493 }
2494 if(xlen < 0){
2495 if(xlen + 1 < -xstart){
2496 xlen = -xstart - 1;
2497 }
2498 xstart = xstart + xlen + 1;
2499 xlen = -xlen;
2500 }else if(xlen == 0){
2501 xstart = 0;
2502 xlen = ncplane_dim_x(n);
2503 }
2504 if(xlen > (int)ncplane_dim_x(n) || xstart + xlen > (int)ncplane_dim_x(n)){
2505 xlen = ncplane_dim_x(n) - xstart;
2506 }
2507 if(ylen < 0){
2508 if(ylen + 1 < -ystart){
2509 ylen = -ystart - 1;
2510 }
2511 ystart = ystart + ylen + 1;
2512 ylen = -ylen;
2513 }else if(ylen == 0){
2514 ystart = 0;
2515 ylen = ncplane_dim_y(n);
2516 }
2517 if(ylen > (int)ncplane_dim_y(n) || ystart + ylen > (int)ncplane_dim_y(n)){
2518 ylen = ncplane_dim_y(n) - ystart;
2519 }
2520 // special-case the full plane erasure, as it's powerfully optimized (O(1))
2521 if(ystart == 0 && xstart == 0 &&
2522 ylen == (int)ncplane_dim_y(n) && xlen == (int)ncplane_dim_x(n)){
2523 int tmpy = n->y; // preserve cursor location
2524 int tmpx = n->x;
2526 n->y = tmpy;
2527 n->x = tmpx;
2528 return 0;
2529 }
2530 loginfo("erasing %d/%d - %d/%d", ystart, xstart, ystart + ylen, xstart + xlen);
2531 for(int y = ystart ; y < ystart + ylen ; ++y){
2532 for(int x = xstart ; x < xstart + xlen ; ++x){
2533 nccell_release(n, &n->fb[nfbcellidx(n, y, x)]);
2534 nccell_init(&n->fb[nfbcellidx(n, y, x)]);
2535 }
2536 }
2537 return 0;
2538}
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
Here is the call graph for this function:

◆ ncplane_fadein()

API int ncplane_fadein ( struct ncplane n,
const struct timespec *  ts,
fadecb  fader,
void *  curry 
)

Definition at line 284 of file fade.c.

284 {
285 ncfadectx* nctx = ncfadectx_setup_internal(n, ts);
286 if(nctx == NULL){
287 struct timespec now;
288 clock_gettime(CLOCK_MONOTONIC, &now);
289 if(fader){
290 fader(ncplane_notcurses(n), n, &now, curry);
291 }else{
292 notcurses_render(ncplane_notcurses(n));
293 }
294 return -1;
295 }
296 int ret = ncplane_fadein_internal(n, fader, nctx, curry);
297 ncfadectx_free(nctx);
298 return ret;
299}
void ncfadectx_free(ncfadectx *nctx)
Definition fade.c:253
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_fadein_iteration()

API int API int ncplane_fadein_iteration ( struct ncplane n,
struct ncfadectx nctx,
int  iter,
fadecb  fader,
void *  curry 
)

◆ ncplane_fadeout()

API int ncplane_fadeout ( struct ncplane n,
const struct timespec *  ts,
fadecb  fader,
void *  curry 
)

Definition at line 260 of file fade.c.

260 {
261 ncfadectx* pp = ncfadectx_setup_internal(n, ts);
262 if(!pp){
263 return -1;
264 }
265 struct timespec times;
266 ns_to_timespec(pp->startns, &times);
267 do{
268 uint64_t curns = times.tv_sec * NANOSECS_IN_SEC + times.tv_nsec;
269 int iter = (curns - pp->startns) / pp->nanosecs_step + 1;
270 if(iter > pp->maxsteps){
271 break;
272 }
273 int r = ncplane_fadeout_iteration(n, pp, iter, fader, curry);
274 if(r){
275 ncfadectx_free(pp);
276 return r;
277 }
278 clock_gettime(CLOCK_MONOTONIC, &times);
279 }while(true);
280 ncfadectx_free(pp);
281 return 0;
282}
int ncplane_fadeout_iteration(ncplane *n, ncfadectx *nctx, int iter, fadecb fader, void *curry)
Definition fade.c:174
uint64_t nanosecs_step
Definition fade.c:11
int maxsteps
Definition fade.c:8
uint64_t startns
Definition fade.c:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_fadeout_iteration()

API int ncplane_fadeout_iteration ( struct ncplane n,
struct ncfadectx nctx,
int  iter,
fadecb  fader,
void *  curry 
)

◆ ncplane_format()

API int ncplane_format ( struct ncplane n,
int  y,
int  x,
unsigned  ylen,
unsigned  xlen,
uint16_t  stylemask 
)

Definition at line 296 of file fill.c.

297 {
298 unsigned ystart, xstart;
299 if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
300 return -1;
301 }
302 int total = 0;
303 for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
304 for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
305 nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
306 targc->stylemask = stylemask;
307 ++total;
308 }
309 }
310 return total;
311}
uint16_t stylemask
Definition notcurses.h:703
Here is the caller graph for this function:

◆ ncplane_gradient()

API int API int ncplane_gradient ( struct ncplane n,
int  y,
int  x,
unsigned  ylen,
unsigned  xlen,
const char *  egc,
uint16_t  styles,
uint64_t  ul,
uint64_t  ur,
uint64_t  ll,
uint64_t  lr 
)

◆ ncplane_gradient2x1()

API int API int API int ncplane_gradient2x1 ( struct ncplane n,
int  y,
int  x,
unsigned  ylen,
unsigned  xlen,
uint32_t  ul,
uint32_t  ur,
uint32_t  ll,
uint32_t  lr 
)

Definition at line 179 of file fill.c.

180 {
181 if(!notcurses_canutf8(ncplane_notcurses(n))){
182 logerror("highdef gradients require utf8");
183 return -1;
184 }
185 if(check_gradient_channel_args(ul, ur, ll, lr)){
186 return -1;
187 }
188 unsigned ystart, xstart;
189 if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
190 return -1;
191 }
192 if(xlen == 1){
193 if(ul != ur || ll != lr){
194 logerror("horizontal channel variation in single column");
195 return -1;
196 }
197 }
198 int total = 0;
199 for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
200 for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
201 nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
202 targc->channels = 0;
203 if(pool_blit_direct(&n->pool, targc, "▀", strlen("▀"), 1) <= 0){
204 return -1;
205 }
206 calc_highgradient(targc, ul, ur, ll, lr, yy - ystart, xx - xstart, ylen * 2, xlen);
207 ++total;
208 }
209 }
210 return total;
211}
uint64_t channels
Definition notcurses.h:723
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_greyscale()

API void ncplane_greyscale ( struct ncplane n)

Definition at line 3 of file fill.c.

3 {
4 for(unsigned y = 0 ; y < n->leny ; ++y){
5 for(unsigned x = 0 ; x < n->lenx ; ++x){
6 nccell* c = &n->fb[nfbcellidx(n, y, x)];
7 unsigned r, g, b;
8 nccell_fg_rgb8(c, &r, &g, &b);
9 int gy = rgb_greyscale(r, g, b);
10 nccell_set_fg_rgb8(c, gy, gy, gy);
11 nccell_bg_rgb8(c, &r, &g, &b);
12 gy = rgb_greyscale(r, g, b);
13 nccell_set_bg_rgb8(c, gy, gy, gy);
14 }
15 }
16}
Here is the caller graph for this function:

◆ ncplane_hline_interp()

API int API int ncplane_hline_interp ( struct ncplane n,
const nccell c,
unsigned  len,
uint64_t  c1,
uint64_t  c2 
)

◆ ncplane_home()

API void ncplane_home ( struct ncplane n)

Definition at line 715 of file notcurses.c.

715 {
716 n->x = 0;
717 n->y = 0;
718}
Here is the caller graph for this function:

◆ ncplane_mergedown()

API int API int ncplane_mergedown ( struct ncplane *RESTRICT  src,
struct ncplane *RESTRICT  dst,
int  begsrcy,
int  begsrcx,
unsigned  leny,
unsigned  lenx,
int  dsty,
int  dstx 
)

◆ ncplane_mergedown_simple()

API int ncplane_mergedown_simple ( struct ncplane *RESTRICT  src,
struct ncplane *RESTRICT  dst 
)

◆ ncplane_move_above()

API int ncplane_move_above ( struct ncplane *RESTRICT  n,
struct ncplane *RESTRICT  above 
)

◆ ncplane_move_below()

API int ncplane_move_below ( struct ncplane *RESTRICT  n,
struct ncplane *RESTRICT  below 
)

◆ ncplane_move_family_above()

API int ncplane_move_family_above ( struct ncplane n,
struct ncplane targ 
)

◆ ncplane_move_family_below()

API int ncplane_move_family_below ( struct ncplane n,
struct ncplane targ 
)

◆ ncplane_move_yx() [1/2]

return ncplane_move_yx ( n  ,
oy+  y,
ox+  x 
)

◆ ncplane_move_yx() [2/2]

API int ncplane_move_yx ( struct ncplane n,
int  y,
int  x 
)

Definition at line 2411 of file notcurses.c.

2411 {
2412 if(n == ncplane_notcurses(n)->stdplane){
2413 return -1;
2414 }
2415 int dy, dx; // amount moved
2416 if(n->boundto == n){
2417 dy = y - n->absy;
2418 dx = x - n->absx;
2419 }else{
2420 dy = (n->boundto->absy + y) - n->absy;
2421 dx = (n->boundto->absx + x) - n->absx;
2422 }
2423 if(dy || dx){ // don't want to trigger sprixel_movefrom() if unneeded
2424 if(n->sprite){
2425 sprixel_movefrom(n->sprite, n->absy, n->absx);
2426 }
2427 n->absx += dx;
2428 n->absy += dy;
2429 move_bound_planes(n->blist, dy, dx);
2430 }
2431 return 0;
2432}
void sprixel_movefrom(sprixel *s, int y, int x)
Definition sprite.c:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_name()

API ALLOC char * ncplane_name ( const struct ncplane n)

◆ ncplane_notcurses()

API struct notcurses * ncplane_notcurses ( const struct ncplane n)

◆ ncplane_notcurses_const()

API const struct notcurses * ncplane_notcurses_const ( const struct ncplane n)

◆ ncplane_off_styles()

API void ncplane_off_styles ( struct ncplane n,
unsigned  stylebits 
)

Definition at line 2081 of file notcurses.c.

2081 {
2082 n->stylemask &= ~(stylebits & NCSTYLE_MASK);
2083}
#define NCSTYLE_MASK
Definition notcurses.h:769
Here is the caller graph for this function:

◆ ncplane_on_styles()

API void ncplane_on_styles ( struct ncplane n,
unsigned  stylebits 
)

Definition at line 2076 of file notcurses.c.

2076 {
2077 n->stylemask |= (stylebits & NCSTYLE_MASK);
2078}
Here is the caller graph for this function:

◆ ncplane_parent()

API struct ncplane * ncplane_parent ( struct ncplane n)

Definition at line 2651 of file notcurses.c.

2651 {
2652 return n->boundto;
2653}
Here is the caller graph for this function:

◆ ncplane_parent_const()

API const struct ncplane * ncplane_parent_const ( const struct ncplane n)

◆ ncplane_pixel_geom()

API void ncplane_pixel_geom ( const struct ncplane n,
unsigned *RESTRICT  pxy,
unsigned *RESTRICT  pxx,
unsigned *RESTRICT  celldimy,
unsigned *RESTRICT  celldimx,
unsigned *RESTRICT  maxbmapy,
unsigned *RESTRICT  maxbmapx 
)

◆ ncplane_polyfill_yx()

API int ncplane_polyfill_yx ( struct ncplane n,
int  y,
int  x,
const nccell c 
)

◆ ncplane_pulse()

API int API int API int ncplane_pulse ( struct ncplane n,
const struct timespec *  ts,
fadecb  fader,
void *  curry 
)

Definition at line 301 of file fade.c.

301 {
302 ncfadectx pp;
303 int ret;
304 if(!notcurses_canfade(ncplane_notcurses(n))){
305 return -1;
306 }
307 if(alloc_ncplane_palette(n, &pp, ts)){
308 return -1;
309 }
310 for(;;){
311 ret = ncplane_fadein_internal(n, fader, &pp, curry);
312 if(ret){
313 break;
314 }
315 ret = ncplane_fadeout(n, ts, fader, curry);
316 if(ret){
317 break;
318 }
319 }
320 free(pp.channels);
321 return ret;
322}
int ncplane_fadeout(ncplane *n, const struct timespec *ts, fadecb fader, void *curry)
Definition fade.c:260
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_putc_yx()

API int ncplane_putc_yx ( struct ncplane n,
int  y,
int  x,
const nccell c 
)

◆ ncplane_putchar_stained()

API int ncplane_putchar_stained ( struct ncplane n,
char  c 
)

Definition at line 2008 of file notcurses.c.

2008 {
2009 uint64_t channels = n->channels;
2010 uint16_t stylemask = n->stylemask;
2011 const nccell* targ = &n->fb[nfbcellidx(n, n->y, n->x)];
2012 n->channels = targ->channels;
2013 n->stylemask = targ->stylemask;
2014 int ret = ncplane_putchar(n, c);
2015 n->channels = channels;
2016 n->stylemask = stylemask;
2017 return ret;
2018}
Here is the caller graph for this function:

◆ ncplane_putegc_stained()

API int ncplane_putegc_stained ( struct ncplane n,
const char *  gclust,
size_t *  sbytes 
)

◆ ncplane_putegc_yx()

API int ncplane_putegc_yx ( struct ncplane n,
int  y,
int  x,
const char *  gclust,
size_t *  sbytes 
)

◆ ncplane_putnstr_aligned()

API int ncplane_putnstr_aligned ( struct ncplane n,
int  y,
ncalign_e  align,
size_t  s,
const char *  str 
)

◆ ncplane_puttext()

API int ncplane_puttext ( struct ncplane n,
int  y,
ncalign_e  align,
const char *  text,
size_t *  bytes 
)

◆ ncplane_putwegc_stained()

API int ncplane_putwegc_stained ( struct ncplane n,
const wchar_t *  gclust,
size_t *  sbytes 
)

◆ ncplane_putwstr_stained()

API int ncplane_putwstr_stained ( struct ncplane n,
const wchar_t *  gclustarr 
)

◆ ncplane_qrcode()

API int ncplane_qrcode ( struct ncplane n,
unsigned *  ymax,
unsigned *  xmax,
const void *  data,
size_t  len 
)

◆ ncplane_reparent()

API struct ncplane * ncplane_reparent ( struct ncplane n,
struct ncplane newparent 
)

◆ ncplane_reparent_family()

API struct ncplane API struct ncplane * ncplane_reparent_family ( struct ncplane n,
struct ncplane newparent 
)

◆ ncplane_resize()

API int ncplane_resize ( struct ncplane n,
int  keepy,
int  keepx,
unsigned  keepleny,
unsigned  keeplenx,
int  yoff,
int  xoff,
unsigned  ylen,
unsigned  xlen 
)

Definition at line 1006 of file notcurses.c.

1009 {
1010 if(n == ncplane_notcurses(n)->stdplane){
1011//fprintf(stderr, "Can't resize standard plane\n");
1012 return -1;
1013 }
1014 return ncplane_resize_internal(n, keepy, keepx, keepleny, keeplenx,
1015 yoff, xoff, ylen, xlen);
1016}
int ncplane_resize_internal(ncplane *n, int keepy, int keepx, unsigned keepleny, unsigned keeplenx, int yoff, int xoff, unsigned ylen, unsigned xlen)
Definition notcurses.c:854
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_resize_marginalized()

API int ncplane_resize_marginalized ( struct ncplane n)

Definition at line 2723 of file notcurses.c.

2723 {
2724 const ncplane* parent = ncplane_parent_const(n);
2725 // a marginalized plane cannot be larger than its oppressor plane =]
2726 unsigned maxy, maxx;
2727 if(parent == n){ // root plane, need to use pile size
2728 ncpile* p = ncplane_pile(n);
2729 maxy = p->dimy;
2730 maxx = p->dimx;
2731 }else{
2732 ncplane_dim_yx(parent, &maxy, &maxx);
2733 }
2734 if((maxy -= (n->margin_b + (n->absy - n->boundto->absy))) < 1){
2735 maxy = 1;
2736 }
2737 if((maxx -= (n->margin_r + (n->absx - n->boundto->absx))) < 1){
2738 maxx = 1;
2739 }
2740 unsigned oldy, oldx;
2741 ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
2742 unsigned keepleny = oldy > maxy ? maxy : oldy;
2743 unsigned keeplenx = oldx > maxx ? maxx : oldx;
2744 if(ncplane_resize_internal(n, 0, 0, keepleny, keeplenx, 0, 0, maxy, maxx)){
2745 return -1;
2746 }
2747 int targy = maxy - n->margin_b;
2748 int targx = maxx - n->margin_b;
2749 loginfo("marg %d/%d, pdim %d/%d, move %d/%d", n->margin_b, n->margin_r, maxy, maxx, targy, targx);
2750 return ncplane_move_yx(n, targy, targx);
2751}
int ncplane_move_yx(ncplane *n, int y, int x)
Definition notcurses.c:2411
const ncplane * ncplane_parent_const(const ncplane *n)
Definition notcurses.c:2655
Here is the call graph for this function:

◆ ncplane_resize_maximize()

API ALLOC struct ncplane API ALLOC struct ncplane API int ncplane_resize_maximize ( struct ncplane n)

Definition at line 2753 of file notcurses.c.

2753 {
2754 const ncpile* pile = ncplane_pile(n); // FIXME should be taken against parent
2755 const unsigned rows = pile->dimy;
2756 const unsigned cols = pile->dimx;
2757 unsigned oldy, oldx;
2758 ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
2759 unsigned keepleny = oldy > rows ? rows : oldy;
2760 unsigned keeplenx = oldx > cols ? cols : oldx;
2761 return ncplane_resize_internal(n, 0, 0, keepleny, keeplenx, 0, 0, rows, cols);
2762}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_resize_placewithin()

API int ncplane_resize_placewithin ( struct ncplane n)

Definition at line 2681 of file notcurses.c.

2681 {
2682 if(n->boundto == n){
2683 return 0;
2684 }
2685 int absy = ncplane_abs_y(n);
2686 int absx = ncplane_abs_x(n);
2687 int ret = 0;
2688 if(absy + ncplane_dim_y(n) > ncplane_dim_y(n->boundto)){
2689 const int dy = (absy + ncplane_dim_y(n)) - ncplane_dim_y(n->boundto);
2690 logdebug("moving up %d", dy);
2691 if(ncplane_move_rel(n, -dy, 0)){
2692 ret = -1;
2693 }
2694 absy = ncplane_abs_y(n);
2695 }
2696 if(absx + ncplane_dim_x(n) > ncplane_dim_x(n->boundto)){
2697 const int dx = ncplane_dim_x(n->boundto) - (absx + ncplane_dim_x(n));
2698 logdebug("moving left %d", dx);
2699 if(ncplane_move_rel(n, 0, dx)){
2700 ret = -1;
2701 }
2702 absx = ncplane_abs_x(n);
2703 }
2704 // this will prefer upper-left material if the child plane is larger than
2705 // the parent. we might want a smarter rule, one based on origin?
2706 if(absy < 0){
2707 logdebug("moving down %d", -absy);
2708 // we're at least partially above our parent
2709 if(ncplane_move_rel(n, -absy, 0)){
2710 ret = -1;
2711 }
2712 }
2713 if(absx < 0){
2714 logdebug("moving right %d", -absx);
2715 // we're at least partially to the left of our parent
2716 if(ncplane_move_rel(n, 0, -absx)){
2717 ret = -1;
2718 }
2719 }
2720 return ret;
2721}
#define logdebug(fmt,...)
Definition logging.h:52
int ncplane_abs_x(const ncplane *n)
Definition notcurses.c:2638
int ncplane_abs_y(const ncplane *n)
Definition notcurses.c:2634
Here is the call graph for this function:

◆ ncplane_resize_realign()

API int ncplane_resize_realign ( struct ncplane n)

Definition at line 2764 of file notcurses.c.

2764 {
2765 const ncplane* parent = ncplane_parent_const(n);
2766 if(parent == n){
2767 logerror("can't realign a root plane");
2768 return 0;
2769 }
2770 if(n->halign == NCALIGN_UNALIGNED && n->valign == NCALIGN_UNALIGNED){
2771 logerror("passed a non-aligned plane");
2772 return -1;
2773 }
2774 int xpos = ncplane_x(n);
2775 if(n->halign != NCALIGN_UNALIGNED){
2776 xpos = ncplane_halign(parent, n->halign, ncplane_dim_x(n));
2777 }
2778 int ypos = ncplane_y(n);
2779 if(n->valign != NCALIGN_UNALIGNED){
2780 ypos = ncplane_valign(parent, n->valign, ncplane_dim_y(n));
2781 }
2782 return ncplane_move_yx(n, ypos, xpos);
2783}
int ncplane_x(const ncplane *n)
Definition notcurses.c:2441
int ncplane_y(const ncplane *n)
Definition notcurses.c:2434
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_rotate_ccw()

API int ncplane_rotate_ccw ( struct ncplane n)

Definition at line 515 of file fill.c.

515 {
516 ncplane* newp = rotate_plane(n);
517 if(newp == NULL){
518 return -1;
519 }
520 unsigned dimy, dimx, targdimy, targdimx;
521 ncplane_dim_yx(n, &dimy, &dimx);
522 ncplane_dim_yx(newp, &targdimy, &targdimx);
523 int x = (int)dimx - 2;
524 int y;
525 // Each row of the target plane is taken from a column of the source plane.
526 // As the target row grows (down), the source column shrinks (moves left).
527 for(unsigned targy = 0 ; targy < targdimy ; ++targy){
528 y = 0;
529 for(unsigned targx = 0 ; targx < targdimx ; targx += 2){
530 if(rotate_2x1_ccw(n, newp, y, x, targy, targx)){
531 ncplane_destroy(newp);
532 return -1;
533 }
534 ++y;
535 }
536 x -= 2;
537 }
538 int ret = rotate_merge(n, newp);
539 ret |= ncplane_destroy(newp);
540 return ret;
541}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_rotate_cw()

API int API int ncplane_rotate_cw ( struct ncplane n)

Definition at line 484 of file fill.c.

484 {
485 ncplane* newp = rotate_plane(n);
486 if(newp == NULL){
487 return -1;
488 }
489 unsigned dimy, dimx;
490 ncplane_dim_yx(n, &dimy, &dimx);
491 int centy, centx;
492 ncplane_center_abs(n, &centy, &centx);
493 // the topmost row consists of the leftmost two columns. the rightmost column
494 // of the topmost row consists of the top half of the top two leftmost cells.
495 // the penultimate column of the topmost row consists of the bottom half of
496 // the top two leftmost cells. work from the bottom up on the source, so we
497 // can copy to the top row from the left to the right.
498 int targx, targy = 0;
499 for(unsigned x = 0 ; x < dimx ; x += 2){
500 targx = 0;
501 for(int y = (int)dimy - 1 ; y >= 0 ; --y){
502 if(rotate_2x1_cw(n, newp, y, x, targy, targx)){
503 ncplane_destroy(newp);
504 return -1;
505 }
506 targx += 2;
507 }
508 ++targy;
509 }
510 int ret = rotate_merge(n, newp);
511 ret |= ncplane_destroy(newp);
512 return ret;
513}
void ncplane_center_abs(const ncplane *n, int *RESTRICT y, int *RESTRICT x)
Definition notcurses.c:3268
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_scrolling_p()

API bool ncplane_scrolling_p ( const struct ncplane n)

◆ ncplane_scrollup()

API int ncplane_scrollup ( struct ncplane n,
int  r 
)

Definition at line 1792 of file notcurses.c.

1792 {
1793 if(!ncplane_scrolling_p(n)){
1794 logerror("can't scroll %d on non-scrolling plane", r);
1795 return -1;
1796 }
1797 if(r < 0){
1798 logerror("can't scroll %d lines", r);
1799 return -1;
1800 }
1801 while(r-- > 0){
1802 scroll_down(n);
1803 }
1805 notcurses_render(ncplane_notcurses(n));
1806 }
1807 return 0;
1808}
bool ncplane_scrolling_p(const ncplane *n)
Definition notcurses.c:2999
void scroll_down(ncplane *n)
Definition notcurses.c:1758
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_scrollup_child()

API int ncplane_scrollup_child ( struct ncplane n,
const struct ncplane child 
)

◆ ncplane_set_autogrow()

API bool ncplane_set_autogrow ( struct ncplane n,
unsigned  growp 
)

Definition at line 3003 of file notcurses.c.

3003 {
3005 logerror("can't set the standard plane autogrow");
3006 return false;
3007 }
3008 bool old = n->autogrow;
3009 n->autogrow = growp;
3010 return old;
3011}
const ncplane * notcurses_stdplane_const(const notcurses *nc)
Definition notcurses.c:703
Here is the call graph for this function:

◆ ncplane_set_base()

API int ncplane_set_base ( struct ncplane n,
const char *  egc,
uint16_t  stylemask,
uint64_t  channels 
)

Definition at line 1565 of file notcurses.c.

1565 {
1566 return nccell_prime(ncp, &ncp->basecell, egc, stylemask, channels);
1567}
Here is the caller graph for this function:

◆ ncplane_set_base_cell()

API int ncplane_set_base_cell ( struct ncplane n,
const nccell c 
)

Definition at line 1558 of file notcurses.c.

1558 {
1559 if(nccell_wide_right_p(c)){
1560 return -1;
1561 }
1562 return nccell_duplicate(ncp, &ncp->basecell, c);
1563}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_set_bchannel()

API uint64_t ncplane_set_bchannel ( struct ncplane n,
uint32_t  channel 
)

Definition at line 1530 of file notcurses.c.

1530 {
1531 return ncchannels_set_bchannel(&n->channels, channel);
1532}

◆ ncplane_set_bg_alpha()

API int ncplane_set_bg_alpha ( struct ncplane n,
int  alpha 
)

Definition at line 1546 of file notcurses.c.

1546 {
1547 return ncchannels_set_bg_alpha(&n->channels, alpha);
1548}
Here is the caller graph for this function:

◆ ncplane_set_bg_default()

API void ncplane_set_bg_default ( struct ncplane n)

Definition at line 1506 of file notcurses.c.

1506 {
1507 ncchannels_set_bg_default(&n->channels);
1508}
Here is the caller graph for this function:

◆ ncplane_set_bg_palindex()

API int ncplane_set_bg_palindex ( struct ncplane n,
unsigned  idx 
)

Definition at line 1554 of file notcurses.c.

1554 {
1555 return ncchannels_set_bg_palindex(&n->channels, idx);
1556}
uint32_t idx
Definition egcpool.h:298

◆ ncplane_set_bg_rgb()

API int ncplane_set_bg_rgb ( struct ncplane n,
uint32_t  channel 
)

◆ ncplane_set_bg_rgb8()

API int ncplane_set_bg_rgb8 ( struct ncplane n,
unsigned  r,
unsigned  g,
unsigned  b 
)

Definition at line 1514 of file notcurses.c.

1514 {
1515 return ncchannels_set_bg_rgb8(&n->channels, r, g, b);
1516}
Here is the caller graph for this function:

◆ ncplane_set_bg_rgb8_clipped()

API void ncplane_set_bg_rgb8_clipped ( struct ncplane n,
int  r,
int  g,
int  b 
)

Definition at line 1510 of file notcurses.c.

1510 {
1511 ncchannels_set_bg_rgb8_clipped(&n->channels, r, g, b);
1512}
Here is the caller graph for this function:

◆ ncplane_set_channels()

API void ncplane_set_channels ( struct ncplane n,
uint64_t  channels 
)

Definition at line 1494 of file notcurses.c.

1494 {
1495 ncchannels_set_channels(&n->channels, channels);
1496}
Here is the caller graph for this function:

◆ ncplane_set_fchannel()

API uint64_t ncplane_set_fchannel ( struct ncplane n,
uint32_t  channel 
)

Definition at line 1534 of file notcurses.c.

1534 {
1535 return ncchannels_set_fchannel(&n->channels, channel);
1536}

◆ ncplane_set_fg_alpha()

API int ncplane_set_fg_alpha ( struct ncplane n,
int  alpha 
)

Definition at line 1542 of file notcurses.c.

1542 {
1543 return ncchannels_set_fg_alpha(&n->channels, alpha);
1544}
Here is the caller graph for this function:

◆ ncplane_set_fg_default()

API void ncplane_set_fg_default ( struct ncplane n)

Definition at line 1502 of file notcurses.c.

1502 {
1503 ncchannels_set_fg_default(&n->channels);
1504}
Here is the caller graph for this function:

◆ ncplane_set_fg_palindex()

API int ncplane_set_fg_palindex ( struct ncplane n,
unsigned  idx 
)

Definition at line 1550 of file notcurses.c.

1550 {
1551 return ncchannels_set_fg_palindex(&n->channels, idx);
1552}
Here is the caller graph for this function:

◆ ncplane_set_fg_rgb()

API int ncplane_set_fg_rgb ( struct ncplane n,
uint32_t  channel 
)

◆ ncplane_set_fg_rgb8()

API int ncplane_set_fg_rgb8 ( struct ncplane n,
unsigned  r,
unsigned  g,
unsigned  b 
)

Definition at line 1522 of file notcurses.c.

1522 {
1523 return ncchannels_set_fg_rgb8(&n->channels, r, g, b);
1524}
Here is the caller graph for this function:

◆ ncplane_set_fg_rgb8_clipped()

API void ncplane_set_fg_rgb8_clipped ( struct ncplane n,
int  r,
int  g,
int  b 
)

Definition at line 1518 of file notcurses.c.

1518 {
1519 ncchannels_set_fg_rgb8_clipped(&n->channels, r, g, b);
1520}
Here is the caller graph for this function:

◆ ncplane_set_name()

API int ncplane_set_name ( struct ncplane n,
const char *  name 
)

Definition at line 2659 of file notcurses.c.

2659 {
2660 char* copy = name ? strdup(name) : NULL;
2661 if(copy == NULL && name != NULL){
2662 return -1;
2663 }
2664 free(n->name);
2665 n->name = copy;
2666 return 0;
2667}
Here is the call graph for this function:

◆ ncplane_set_resizecb()

API void ncplane_set_resizecb ( struct ncplane n,
int(*)(struct ncplane *)  resizecb 
)

◆ ncplane_set_scrolling()

API bool ncplane_set_scrolling ( struct ncplane n,
unsigned  scrollp 
)

Definition at line 2993 of file notcurses.c.

2993 {
2994 bool old = n->scrolling;
2995 n->scrolling = scrollp;
2996 return old;
2997}
Here is the caller graph for this function:

◆ ncplane_set_styles()

API void ncplane_set_styles ( struct ncplane n,
unsigned  stylebits 
)

Definition at line 2071 of file notcurses.c.

2071 {
2072 n->stylemask = (stylebits & NCSTYLE_MASK);
2073}
Here is the caller graph for this function:

◆ ncplane_set_userptr()

API void * ncplane_set_userptr ( struct ncplane n,
void *  opaque 
)

Definition at line 186 of file notcurses.c.

186 {
187 void* ret = n->userptr;
188 n->userptr = opaque;
189 return ret;
190}
Here is the caller graph for this function:

◆ ncplane_stain()

API int ncplane_stain ( struct ncplane n,
int  y,
int  x,
unsigned  ylen,
unsigned  xlen,
uint64_t  ul,
uint64_t  ur,
uint64_t  ll,
uint64_t  lr 
)

Definition at line 272 of file fill.c.

273 {
274 // Can't use default or palette-indexed colors in a gradient
275 if(check_gradient_args(tl, tr, bl, br)){
276 return -1;
277 }
278 unsigned ystart, xstart;
279 if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
280 return -1;
281 }
282 int total = 0;
283 for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
284 for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
285 nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
286 if(targc->gcluster){
287 calc_gradient_channels(&targc->channels, tl, tr, bl, br,
288 yy - ystart, xx - xstart, ylen, xlen);
289 }
290 ++total;
291 }
292 }
293 return total;
294}
bool check_gradient_args(uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br)
Definition fill.c:150
uint32_t gcluster
Definition notcurses.h:693
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_styles()

API uint16_t ncplane_styles ( const struct ncplane n)

◆ ncplane_translate()

API void ncplane_translate ( const struct ncplane src,
const struct ncplane dst,
int *RESTRICT  y,
int *RESTRICT  x 
)

◆ ncplane_translate_abs()

API bool ncplane_translate_abs ( const struct ncplane n,
int *RESTRICT  y,
int *RESTRICT  x 
)

◆ ncplane_userptr()

API void * ncplane_userptr ( struct ncplane n)

Definition at line 192 of file notcurses.c.

192 {
193 return n->userptr;
194}
Here is the caller graph for this function:

◆ ncplane_vline_interp()

API int ncplane_vline_interp ( struct ncplane n,
const nccell c,
unsigned  len,
uint64_t  c1,
uint64_t  c2 
)

◆ ncplane_vprintf_aligned()

API int ncplane_vprintf_aligned ( struct ncplane n,
int  y,
ncalign_e  align,
const char *  format,
va_list  ap 
)

◆ ncplane_vprintf_stained()

API int ncplane_vprintf_stained ( struct ncplane n,
const char *  format,
va_list  ap 
)

◆ ncplane_vprintf_yx()

API int ncplane_vprintf_yx ( struct ncplane n,
int  y,
int  x,
const char *  format,
va_list  ap 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncplane_x()

API int ncplane_x ( const struct ncplane n)

◆ ncplane_y()

API int ncplane_y ( const struct ncplane n)

◆ ncplane_yx() [1/2]

API void ncplane_yx ( const struct ncplane n,
int *RESTRICT  y,
int *RESTRICT  x 
)

◆ ncplane_yx() [2/2]

ncplane_yx ( n  ,
oy,
ox 
)

◆ ncprogbar_create()

API ALLOC struct ncprogbar * ncprogbar_create ( struct ncplane n,
const ncprogbar_options opts 
)

Definition at line 4 of file progbar.c.

4 {
5 ncprogbar_options default_opts;
6 if(opts == NULL){
7 memset(&default_opts, 0, sizeof(default_opts));
8 opts = &default_opts;
9 }
11 logwarn("invalid flags %016" PRIx64, opts->flags);
12 }
13 ncprogbar* ret = malloc(sizeof(*ret));
14 if(ret == NULL){
16 return NULL;
17 }
18 ret->ncp = n;
19 ret->ulchannel = opts->ulchannel;
20 ret->urchannel = opts->urchannel;
21 ret->blchannel = opts->blchannel;
22 ret->brchannel = opts->brchannel;
24 if(ncplane_set_widget(n, ret, (void(*)(void*))ncprogbar_destroy)){
26 free(ret);
27 return NULL;
28 }
29 return ret;
30}
#define NCPROGBAR_OPTION_RETROGRADE
Definition notcurses.h:4203
void ncprogbar_destroy(ncprogbar *n)
Definition progbar.c:190
ncplane * ncp
Definition internal.h:225
uint32_t ulchannel
Definition internal.h:227
uint32_t blchannel
Definition internal.h:227
uint32_t urchannel
Definition internal.h:227
uint32_t brchannel
Definition internal.h:227
bool retrograde
Definition internal.h:228
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncprogbar_destroy()

API void ncprogbar_destroy ( struct ncprogbar n)

Definition at line 190 of file progbar.c.

190 {
191 if(n){
192 if(ncplane_set_widget(n->ncp, NULL, NULL) == 0){
193 ncplane_destroy(n->ncp);
194 }
195 free(n);
196 }
197}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncprogbar_plane()

API struct ncplane * ncprogbar_plane ( struct ncprogbar n)

Definition at line 32 of file progbar.c.

32 {
33 return n->ncp;
34}
Here is the caller graph for this function:

◆ ncprogbar_progress()

API double ncprogbar_progress ( const struct ncprogbar n)

◆ ncprogbar_set_progress()

API int ncprogbar_set_progress ( struct ncprogbar n,
double  p 
)

Definition at line 176 of file progbar.c.

176 {
177//fprintf(stderr, "PROGRESS: %g\n", p);
178 if(p < 0 || p > 1){
179 logerror("invalid progress %g", p);
180 return -1;
181 }
182 n->progress = p;
183 return progbar_redraw(n);
184}
Here is the caller graph for this function:

◆ ncreader_clear()

API int ncreader_clear ( struct ncreader n)

Definition at line 73 of file reader.c.

73 {
74 ncplane_erase(n->ncp);
75 ncplane_erase(n->textarea);
76 n->xproject = 0;
77 return 0;
78}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_contents()

API int API char * ncreader_contents ( const struct ncreader n)

◆ ncreader_create()

API ALLOC struct ncreader * ncreader_create ( struct ncplane n,
const ncreader_options opts 
)

Definition at line 26 of file reader.c.

26 {
27 ncreader_options zeroed = {0};
28 if(!opts){
29 opts = &zeroed;
30 }
32 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
33 }
34 ncreader* nr = malloc(sizeof(*nr));
35 if(nr == NULL){
37 return NULL;
38 }
39 nr->ncp = n;
40 // do *not* bind it to the visible plane; we always want it offscreen,
41 // to the upper left of the true origin
42 struct ncplane_options nopts = {
43 .y = -ncplane_dim_y(n),
44 .x = -ncplane_dim_x(n),
45 .rows = ncplane_dim_y(n),
46 .cols = ncplane_dim_x(n),
47 .name = "text",
48 };
51 free(nr);
52 return NULL;
53 }
54
56 nr->xproject = 0;
57 nr->tchannels = opts->tchannels;
58 nr->tattrs = opts->tattrword;
61 ncplane_set_channels(nr->ncp, opts->tchannels);
62 ncplane_set_styles(nr->ncp, opts->tattrword);
63 if(ncplane_set_widget(n, nr, (void(*)(void*))ncreader_destroy_internal)){
66 free(nr);
67 return NULL;
68 }
69 return nr;
70}
#define NCREADER_OPTION_NOCMDKEYS
Definition notcurses.h:4615
#define NCREADER_OPTION_HORSCROLL
Definition notcurses.h:4611
#define NCREADER_OPTION_CURSOR
Definition notcurses.h:4618
uint64_t tchannels
Definition internal.h:215
bool no_cmd_keys
Definition internal.h:220
bool horscroll
Definition internal.h:219
ncplane * ncp
Definition internal.h:214
ncplane * textarea
Definition internal.h:217
int xproject
Definition internal.h:218
uint32_t tattrs
Definition internal.h:216
bool manage_cursor
Definition internal.h:221
Here is the call graph for this function:

◆ ncreader_destroy()

API void ncreader_destroy ( struct ncreader n,
char **  contents 
)

Definition at line 17 of file reader.c.

17 {
18 if(n){
19 if(contents){
20 *contents = ncreader_contents(n);
21 }
22 ncreader_destroy_internal(n);
23 }
24}
char * ncreader_contents(const ncreader *n)
Definition reader.c:413
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_move_down()

API int ncreader_move_down ( struct ncreader n)

Definition at line 202 of file reader.c.

202 {
203 unsigned y = n->ncp->y;
204 if(y >= n->textarea->leny - 1){
205 // are we on the last row of the textarea? if so, we can't move.
206 return -1;
207 }
208 ++y;
209 ncplane_cursor_move_yx(n->textarea, y, -1);
210 ncplane_cursor_move_yx(n->ncp, y, -1);
211 ncreader_redraw(n);
212 return 0;
213}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_move_left()

API bool API int ncreader_move_left ( struct ncreader n)

Definition at line 115 of file reader.c.

115 {
116 int viewx = n->ncp->x;
117 int textx = n->textarea->x;
118 int y = n->ncp->y;
119//fprintf(stderr, "moving left: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", y, textx, y, viewx, n->xproject);
120 if(textx == 0){
121 // are we on the first column of the textarea? if so, we must also be on
122 // the first column of the viewarea. try to move up.
123 if(y == 0){
124 return -1; // no move possible
125 }
126 viewx = n->ncp->lenx - 1; // FIXME find end of particular row
127 --y;
128 textx = n->textarea->lenx - 1;
129 n->xproject = n->textarea->x - n->ncp->x;
130 }else{
131 // if we're on the first column of the viewarea, but not the first column
132 // of the textarea, we must be able to scroll to the left. do so.
133 // if we're not on the last column anywhere, move cursor right everywhere.
134 if(viewx == 0){
135 --n->xproject;
136 }else{
137 --viewx;
138 }
139 --textx;
140 }
141 ncplane_cursor_move_yx(n->textarea, y, textx);
142 ncplane_cursor_move_yx(n->ncp, y, viewx);
143//fprintf(stderr, "moved left: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", y, textx, y, viewx, n->xproject);
144 ncreader_redraw(n);
145 return 0;
146}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_move_right()

API int ncreader_move_right ( struct ncreader n)

Definition at line 152 of file reader.c.

152 {
153 unsigned textx = n->textarea->x;
154 unsigned y = n->ncp->y;
155 unsigned viewx = n->ncp->x;
156//fprintf(stderr, "moving right: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", y, textx, y, viewx, n->xproject);
157 if(textx >= n->textarea->lenx - 1){
158 // are we on the last column of the textarea? if so, we must also be on
159 // the first column of the viewarea. try to move down.
160 if(y >= n->textarea->leny - 1){
161 return -1; // no move possible
162 }
163 viewx = 0;
164 ++y;
165 textx = viewx;
166 n->xproject = 0;
167 }else{
168 // if we're on the first column of the viewarea, but not the first column
169 // of the textarea, we must be able to scroll to the left. do so.
170 // if we're not on the last column anywhere, move cursor right everywhere.
171 if(viewx >= n->ncp->lenx - 1){
172 ++n->xproject;
173 }else{
174 ++viewx;
175 }
176 ++textx;
177 }
178 ncplane_cursor_move_yx(n->textarea, y, textx);
179 ncplane_cursor_move_yx(n->ncp, y, viewx);
180//fprintf(stderr, "moved right: tcurs: %dx%d vcurs: %dx%d xproj: %d\n", y, textx, y, viewx, n->xproject);
181 ncreader_redraw(n);
182 return 0;
183}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_move_up()

API int ncreader_move_up ( struct ncreader n)

Definition at line 187 of file reader.c.

187 {
188 int y = n->ncp->y;
189 if(y == 0){
190 // are we on the last row of the textarea? if so, we can't move.
191 return -1;
192 }
193 --y;
194 ncplane_cursor_move_yx(n->textarea, y, -1);
195 ncplane_cursor_move_yx(n->ncp, y, -1);
196 ncreader_redraw(n);
197 return 0;
198}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreader_offer_input()

API bool ncreader_offer_input ( struct ncreader n,
const ncinput ni 
)

◆ ncreader_plane()

API struct ncplane * ncreader_plane ( struct ncreader n)

Definition at line 80 of file reader.c.

80 {
81 return n->ncp;
82}
Here is the caller graph for this function:

◆ ncreader_write_egc()

API int ncreader_write_egc ( struct ncreader n,
const char *  egc 
)

◆ ncreel_add()

API ALLOC struct nctablet * ncreel_add ( struct ncreel nr,
struct nctablet after,
struct nctablet before,
tabletcb  cb,
void *  opaque 
)

Definition at line 838 of file reel.c.

839 {
840 nctablet* t;
841 if(after && before){
842 if(after->next != before || before->prev != after){
843 logerror("bad before (%p) / after (%p) spec", before, after);
844 return NULL;
845 }
846 }else if(!after && !before){
847 // This way, without user interaction or any specification, new tablets are
848 // inserted at the "end" relative to the focus. The first one to be added
849 // gets and keeps the focus. New ones will go on the bottom, until we run
850 // out of space. New tablets are then created off-screen.
851 before = nr->tablets;
852 }
853 if((t = malloc(sizeof(*t))) == NULL){
854 return NULL;
855 }
856//fprintf(stderr, "--------->NEW TABLET %p\n", t);
857 if(after){
858 t->next = after->next;
859 after->next = t;
860 t->prev = after;
861 t->next->prev = t;
862 }else if(before){
863 t->prev = before->prev;
864 before->prev = t;
865 t->next = before;
866 t->prev->next = t;
867 }else{ // we're the first tablet
868 t->prev = t->next = t;
869 nr->tablets = t;
870 }
871 t->cbfxn = cbfxn;
872 t->curry = opaque;
873 ++nr->tabletcount;
874 t->p = NULL;
875 t->cbp = NULL;
876 ncreel_redraw(nr);
877 return t;
878}
int ncreel_redraw(ncreel *nr)
Definition reel.c:677
int tabletcount
Definition internal.h:189
nctablet * tablets
Definition internal.h:183
ncplane * cbp
Definition internal.h:171
struct nctablet * prev
Definition internal.h:173
void * curry
Definition internal.h:175
ncplane * p
Definition internal.h:170
tabletcb cbfxn
Definition internal.h:174
struct nctablet * next
Definition internal.h:172
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_create()

API ALLOC struct ncreel * ncreel_create ( struct ncplane n,
const ncreel_options popts 
)

Definition at line 807 of file reel.c.

807 {
808 ncreel_options zeroed = {0};
809 ncreel* nr;
810 if(!ropts){
811 ropts = &zeroed;
812 }
813 if(!validate_ncreel_opts(n, ropts)){
814 return NULL;
815 }
816 if((nr = malloc(sizeof(*nr))) == NULL){
817 return NULL;
818 }
819 nr->tablets = NULL;
820 nr->tabletcount = 0;
821 nr->direction = LASTDIRECTION_DOWN; // draw down after the initial tablet
822 memcpy(&nr->ropts, ropts, sizeof(*ropts));
823 nr->p = n;
824 nr->vft = NULL;
825 if(ncplane_set_widget(nr->p, nr, (void(*)(void*))ncreel_destroy)){
826 ncplane_destroy(nr->p);
827 free(nr);
828 return NULL;
829 }
830 if(ncreel_redraw(nr)){
831 ncplane_destroy(nr->p);
832 free(nr);
833 return NULL;
834 }
835 return nr;
836}
void ncreel_destroy(ncreel *nreel)
Definition reel.c:880
ncreel_options ropts
Definition internal.h:190
ncplane * p
Definition internal.h:179
nctablet * vft
Definition internal.h:184
enum ncreel::@1 direction
Here is the call graph for this function:

◆ ncreel_del()

API int ncreel_del ( struct ncreel nr,
struct nctablet t 
)

Definition at line 285 of file reel.c.

285 {
286 if(t == NULL){
287 return -1;
288 }
289 if(nr->tablets == t){
290 if((nr->tablets = t->next) == t){
291 nr->tablets = NULL;
292 }
293 // FIXME ought set direction based on actual location of replacement tablet
294 nr->direction = LASTDIRECTION_DOWN;
295 }
296 if(nr->vft == t){
297 clean_reel(nr); // maybe just make nr->tablets the vft?
298 }
299 nctablet_delete_internal(t);
300 --nr->tabletcount;
301 ncreel_redraw(nr);
302 return 0;
303}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_destroy()

API void ncreel_destroy ( struct ncreel nr)

Definition at line 880 of file reel.c.

880 {
881 if(nreel){
882 if(ncplane_set_widget(nreel->p, NULL, NULL) == 0){
883 nctablet* t;
884 while( (t = nreel->tablets) ){
885 ncreel_del(nreel, t);
886 }
887 ncplane_destroy(nreel->p);
888 }
889 free(nreel);
890 }
891}
int ncreel_del(ncreel *nr, struct nctablet *t)
Definition reel.c:285
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_focused()

API bool API struct nctablet * ncreel_focused ( struct ncreel nr)

Definition at line 901 of file reel.c.

901 {
902 return nr->tablets;
903}
Here is the caller graph for this function:

◆ ncreel_next()

API struct nctablet * ncreel_next ( struct ncreel nr)

Definition at line 905 of file reel.c.

905 {
906 if(nr->tablets){
907 nr->tablets = nr->tablets->next;
908//fprintf(stderr, "---------------> moved to next, %p to %p <----------\n", nr->tablets->prev, nr->tablets);
909 nr->direction = LASTDIRECTION_DOWN;
910 ncreel_redraw(nr);
911 }
912 return nr->tablets;
913}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_offer_input()

API bool ncreel_offer_input ( struct ncreel nr,
const ncinput ni 
)

◆ ncreel_plane()

API struct ncplane * ncreel_plane ( struct ncreel nr)

Definition at line 803 of file reel.c.

803 {
804 return nr->p;
805}

◆ ncreel_prev()

API struct nctablet * ncreel_prev ( struct ncreel nr)

Definition at line 915 of file reel.c.

915 {
916 if(nr->tablets){
917 nr->tablets = nr->tablets->prev;
918//fprintf(stderr, "----------------> moved to prev, %p to %p <----------\n", nr->tablets->next, nr->tablets);
919 nr->direction = LASTDIRECTION_UP;
920 ncreel_redraw(nr);
921 }
922 return nr->tablets;
923}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_redraw()

API int ncreel_redraw ( struct ncreel nr)

Definition at line 677 of file reel.c.

677 {
678//fprintf(stderr, "\n--------> BEGIN REDRAW <--------\n");
679 nctablet* focused = nr->tablets;
680 int fulcrum; // target line
681 if(nr->direction == LASTDIRECTION_UP){
682 // case i iff the last direction was UP, and either the focused tablet is
683 // not visible, or below the visibly-focused tablet, or there is no
684 // visibly-focused tablet.
685 if(!focused || !focused->p || !nr->vft){
686 fulcrum = 0;
687//fprintf(stderr, "case i fulcrum %d\n", fulcrum);
688 }else{
689 int focy, vfty;
690 ncplane_yx(focused->p, &focy, NULL);
691 ncplane_yx(nr->vft->p, &vfty, NULL);
692 if(focy > vfty){
693 fulcrum = 0;
694//fprintf(stderr, "case i fulcrum %d (%d %d) %p %p\n", fulcrum, focy, vfty, focused, nr->vft);
695 }else{
696 ncplane_yx(focused->p, &fulcrum, NULL); // case iii
697//fprintf(stderr, "case iii fulcrum %d (%d %d) %p %p lastdir: %d\n", fulcrum, focy, vfty, focused, nr->vft, nr->direction);
698 }
699 }
700 }else{
701 // case ii iff the last direction was DOWN, and either the focused tablet
702 // is not visible, or above the visibly-focused tablet, or there is no
703 // visibly-focused tablet.
704 if(!focused || !focused->p || !nr->vft){
705 fulcrum = ncplane_dim_y(nr->p) - 1;
706//fprintf(stderr, "case ii fulcrum %d\n", fulcrum);
707 }else{
708 int focy, vfty;
709//fprintf(stderr, "focused: %p\n", focused);
710 ncplane_yx(focused->p, &focy, NULL);
711 ncplane_yx(nr->vft->p, &vfty, NULL);
712 if(focy < vfty){
713 fulcrum = ncplane_dim_y(nr->p) - 1;
714//fprintf(stderr, "case ii fulcrum %d (%d %d) %p %p\n", fulcrum, focy, vfty, focused, nr->vft);
715 }else{
716 ncplane_yx(focused->p, &fulcrum, NULL); // case iii
717//fprintf(stderr, "case iiib fulcrum %d (%d %d) %p %p lastdir: %d\n", fulcrum, focy, vfty, focused, nr->vft, nr->direction);
718 }
719 }
720 }
721 clean_reel(nr);
722 if(focused){
723//fprintf(stderr, "drawing focused tablet %p dir: %d fulcrum: %d!\n", focused, nr->direction, fulcrum);
724 if(ncreel_draw_tablet(nr, focused, fulcrum, fulcrum, DIRECTION_DOWN)){
725 logerror("error drawing tablet");
726 return -1;
727 }
728//fprintf(stderr, "drew focused tablet %p -> %p lastdir: %d!\n", focused, focused->p, nr->direction);
729 nctablet* otherend = focused;
730 int frontiertop, frontierbottom;
731 ncplane_yx(nr->tablets->p, &frontiertop, NULL);
732 frontierbottom = frontiertop + ncplane_dim_y(nr->tablets->p) + 1;
733 frontiertop -= 2;
734 if(nr->direction == LASTDIRECTION_DOWN){
735 otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
736 if(otherend == NULL){
737 logerror("error drawing higher tablets");
738 return -1;
739 }
740 otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
741 }else{ // DIRECTION_UP
742 otherend = draw_previous_tablets(nr, otherend, &frontiertop, frontierbottom);
743 if(otherend == NULL){
744 logerror("error drawing higher tablets");
745 return -1;
746 }
747 otherend = draw_following_tablets(nr, otherend, frontiertop, &frontierbottom);
748 }
749 if(otherend == NULL){
750 logerror("error drawing following tablets");
751 return -1;
752 }
753//notcurses_debug(ncplane_notcurses(nr->p), stderr);
754 if(tighten_reel(nr)){
755 logerror("error tightening reel");
756 return -1;
757 }
758//notcurses_debug(ncplane_notcurses(nr->p), stderr);
759 }
760 nr->vft = nr->tablets; // update the visually-focused tablet pointer
761//fprintf(stderr, "DONE ARRANGING\n");
762 if(draw_ncreel_borders(nr)){
763 logerror("error drawing reel borders");
764 return -1; // enforces specified dimensional minima
765 }
766 return 0;
767}
void ncplane_yx(const ncplane *n, int *y, int *x)
Definition notcurses.c:2448
@ DIRECTION_DOWN
Definition reel.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncreel_tabletcount()

API int ncreel_tabletcount ( const struct ncreel nr)

◆ ncselector_additem()

API int ncselector_additem ( struct ncselector n,
const struct ncselector_item item 
)

Definition at line 392 of file selector.c.

392 {
393 unsigned origdimy, origdimx;
394 ncselector_dim_yx(n, &origdimy, &origdimx);
395 size_t newsize = sizeof(*n->items) * (n->itemcount + 1);
396 struct ncselector_int* items = realloc(n->items, newsize);
397 if(!items){
398 return -1;
399 }
400 n->items = items;
401 n->items[n->itemcount].option = strdup(item->option);
402 const char *desc = item->desc ? item->desc : "";
403 n->items[n->itemcount].desc = strdup(desc);
404 int usafecols = ncstrwidth(item->option, NULL, NULL);
405 if(usafecols < 0){
406 return -1;
407 }
408 unsigned cols = usafecols;
409 n->items[n->itemcount].opcolumns = cols;
410 if(cols > n->longop){
411 n->longop = cols;
412 }
413 cols = ncstrwidth(desc, NULL, NULL);
414 n->items[n->itemcount].desccolumns = cols;
415 if(cols > n->longdesc){
416 n->longdesc = cols;
417 }
418 ++n->itemcount;
419 unsigned dimy, dimx;
420 ncselector_dim_yx(n, &dimy, &dimx);
421 if(origdimx < dimx || origdimy < dimy){ // resize if too small
422 ncplane_resize_simple(n->ncp, dimy, dimx);
423 }
424 return ncselector_draw(n);
425}
char * desc
Definition selector.c:6
char * option
Definition selector.c:5
const char * option
Definition notcurses.h:3908
const char * desc
Definition notcurses.h:3909
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_create()

API ALLOC struct ncselector * ncselector_create ( struct ncplane n,
const ncselector_options opts 
)

Definition at line 280 of file selector.c.

280 {
282 logerror("won't use the standard plane"); // would fail later on resize
283 return NULL;
284 }
285 ncselector_options zeroed = {0};
286 if(!opts){
287 opts = &zeroed;
288 }
289 unsigned itemcount = 0;
290 if(opts->flags > 0){
291 logwarn("provided unsupported flags %016" PRIx64, opts->flags);
292 }
293 if(opts->items){
294 for(const struct ncselector_item* i = opts->items ; i->option ; ++i){
295 ++itemcount;
296 }
297 }
298 ncselector* ns = malloc(sizeof(*ns));
299 if(ns == NULL){
300 return NULL;
301 }
302 memset(ns, 0, sizeof(*ns));
303 if(opts->defidx && opts->defidx >= itemcount){
304 logerror("default index %u too large (%u items)", opts->defidx, itemcount);
305 goto freeitems;
306 }
307 ns->title = opts->title ? strdup(opts->title) : NULL;
308 ns->titlecols = opts->title ? ncstrwidth(opts->title, NULL, NULL) : 0;
309 ns->secondary = opts->secondary ? strdup(opts->secondary) : NULL;
310 ns->secondarycols = opts->secondary ? ncstrwidth(opts->secondary, NULL, NULL) : 0;
311 ns->footer = opts->footer ? strdup(opts->footer) : NULL;
312 ns->footercols = opts->footer ? ncstrwidth(opts->footer, NULL, NULL) : 0;
313 ns->selected = opts->defidx;
314 ns->longop = 0;
315 if( (ns->maxdisplay = opts->maxdisplay) ){
316 if(opts->defidx >= ns->maxdisplay){
317 ns->startdisp = opts->defidx - ns->maxdisplay + 1;
318 }else{
319 ns->startdisp = 0;
320 }
321 }else{
322 ns->startdisp = 0;
323 }
324 ns->longdesc = 0;
325 ns->opchannels = opts->opchannels;
326 ns->boxchannels = opts->boxchannels;
327 ns->descchannels = opts->descchannels;
328 ns->titlechannels = opts->titlechannels;
329 ns->footchannels = opts->footchannels;
330 ns->boxchannels = opts->boxchannels;
331 ns->darrowy = ns->uarrowy = ns->arrowx = -1;
332 if(itemcount){
333 if(!(ns->items = malloc(sizeof(*ns->items) * itemcount))){
334 goto freeitems;
335 }
336 }else{
337 ns->items = NULL;
338 }
339 for(ns->itemcount = 0 ; ns->itemcount < itemcount ; ++ns->itemcount){
340 const struct ncselector_item* src = &opts->items[ns->itemcount];
341 int unsafe = ncstrwidth(src->option, NULL, NULL);
342 if(unsafe < 0){
343 goto freeitems;
344 }
345 unsigned cols = unsafe;
346 ns->items[ns->itemcount].opcolumns = cols;
347 if(cols > ns->longop){
348 ns->longop = cols;
349 }
350 const char *desc = src->desc ? src->desc : "";
351 unsafe = ncstrwidth(desc, NULL, NULL);
352 if(unsafe < 0){
353 goto freeitems;
354 }
355 cols = unsafe;
356 ns->items[ns->itemcount].desccolumns = cols;
357 if(cols > ns->longdesc){
358 ns->longdesc = cols;
359 }
360 ns->items[ns->itemcount].option = strdup(src->option);
361 ns->items[ns->itemcount].desc = strdup(desc);
362 if(!(ns->items[ns->itemcount].desc && ns->items[ns->itemcount].option)){
363 free(ns->items[ns->itemcount].option);
364 free(ns->items[ns->itemcount].desc);
365 goto freeitems;
366 }
367 }
368 unsigned dimy, dimx;
369 ns->ncp = n;
370 ncselector_dim_yx(ns, &dimy, &dimx);
371 if(ncplane_resize_simple(n, dimy, dimx)){
372 goto freeitems;
373 }
374 if(ncplane_set_widget(ns->ncp, ns, (void(*)(void*))ncselector_destroy_internal)){
375 goto freeitems;
376 }
377 ncselector_draw(ns); // deal with error here?
378 return ns;
379
380freeitems:
381 while(ns->itemcount--){
382 free(ns->items[ns->itemcount].option);
383 free(ns->items[ns->itemcount].desc);
384 }
385 free(ns->items);
386 free(ns->title); free(ns->secondary); free(ns->footer);
387 free(ns);
389 return NULL;
390}
size_t desccolumns
Definition selector.c:8
size_t opcolumns
Definition selector.c:7
char * secondary
Definition selector.c:28
unsigned maxdisplay
Definition selector.c:21
ncplane * ncp
Definition selector.c:18
uint64_t footchannels
Definition selector.c:35
unsigned longdesc
Definition selector.c:23
int darrowy
Definition selector.c:37
unsigned startdisp
Definition selector.c:20
uint64_t descchannels
Definition selector.c:33
uint64_t titlechannels
Definition selector.c:34
unsigned itemcount
Definition selector.c:25
unsigned titlecols
Definition selector.c:27
uint64_t boxchannels
Definition selector.c:36
int arrowx
Definition selector.c:37
unsigned secondarycols
Definition selector.c:29
unsigned longop
Definition selector.c:22
int uarrowy
Definition selector.c:37
unsigned footercols
Definition selector.c:31
char * footer
Definition selector.c:30
struct ncselector_int * items
Definition selector.c:24
unsigned selected
Definition selector.c:19
char * title
Definition selector.c:26
uint64_t opchannels
Definition selector.c:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_delitem()

API int ncselector_delitem ( struct ncselector n,
const char *  item 
)

Definition at line 427 of file selector.c.

427 {
428 unsigned origdimy, origdimx;
429 ncselector_dim_yx(n, &origdimy, &origdimx);
430 bool found = false;
431 int maxop = 0, maxdesc = 0;
432 for(unsigned idx = 0 ; idx < n->itemcount ; ++idx){
433 if(strcmp(n->items[idx].option, item) == 0){ // found it
434 free(n->items[idx].option);
435 free(n->items[idx].desc);
436 if(idx < n->itemcount - 1){
437 memmove(n->items + idx, n->items + idx + 1, sizeof(*n->items) * (n->itemcount - idx - 1));
438 }else{
439 if(idx){
440 --n->selected;
441 }
442 }
443 --n->itemcount;
444 found = true;
445 --idx;
446 }else{
447 int cols = ncstrwidth(n->items[idx].option, NULL, NULL);
448 if(cols > maxop){
449 maxop = cols;
450 }
451 cols = ncstrwidth(n->items[idx].desc, NULL, NULL);
452 if(cols > maxdesc){
453 maxdesc = cols;
454 }
455 }
456 }
457 if(found){
458 n->longop = maxop;
459 n->longdesc = maxdesc;
460 unsigned dimy, dimx;
461 ncselector_dim_yx(n, &dimy, &dimx);
462 if(origdimx > dimx || origdimy > dimy){ // resize if too big
463 ncplane_resize_simple(n->ncp, dimy, dimx);
464 }
465 return ncselector_draw(n);
466 }
467 return -1; // wasn't found
468}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncselector_destroy()

API bool API void ncselector_destroy ( struct ncselector n,
char **  item 
)

Definition at line 270 of file selector.c.

270 {
271 if(n){
272 if(item){
273 *item = n->items[n->selected].option;
274 n->items[n->selected].option = NULL;
275 }
276 ncselector_destroy_internal(n);
277 }
278}
Here is the caller graph for this function:

◆ ncselector_nextitem()

API const char * ncselector_nextitem ( struct ncselector n)

Definition at line 500 of file selector.c.

500 {
501 const char* ret = NULL;
502 if(n->itemcount == 0){
503 return NULL;
504 }
505 unsigned lastdisp = n->startdisp;
506 lastdisp += n->maxdisplay && n->maxdisplay < n->itemcount ? n->maxdisplay : n->itemcount;
507 --lastdisp;
508 lastdisp %= n->itemcount;
509 if(lastdisp == n->selected){
510 if(++n->startdisp == n->itemcount){
511 n->startdisp = 0;
512 }
513 }
514 ++n->selected;
515 if(n->selected == n->itemcount){
516 n->selected = 0;
517 }
518 ret = n->items[n->selected].option;
519 ncselector_draw(n);
520 return ret;
521}
Here is the caller graph for this function:

◆ ncselector_offer_input()

API bool ncselector_offer_input ( struct ncselector n,
const ncinput nc 
)

◆ ncselector_plane()

API struct ncplane * ncselector_plane ( struct ncselector n)

Definition at line 470 of file selector.c.

470 {
471 return n->ncp;
472}

◆ ncselector_previtem()

API const char * ncselector_previtem ( struct ncselector n)

Definition at line 481 of file selector.c.

481 {
482 const char* ret = NULL;
483 if(n->itemcount == 0){
484 return ret;
485 }
486 if(n->selected == n->startdisp){
487 if(n->startdisp-- == 0){
488 n->startdisp = n->itemcount - 1;
489 }
490 }
491 if(n->selected == 0){
492 n->selected = n->itemcount;
493 }
494 --n->selected;
495 ret = n->items[n->selected].option;
496 ncselector_draw(n);
497 return ret;
498}
Here is the caller graph for this function:

◆ ncselector_selected()

API const char * ncselector_selected ( const struct ncselector n)

◆ ncstrwidth()

API int ncstrwidth ( const char *  egcs,
int *  validbytes,
int *  validwidth 
)

Definition at line 3309 of file notcurses.c.

3309 {
3310 int cols;
3311 if(validwidth == NULL){
3312 validwidth = &cols;
3313 }
3314 *validwidth = 0;
3315 int bytes;
3316 if(validbytes == NULL){
3317 validbytes = &bytes;
3318 }
3319 *validbytes = 0;
3320 do{
3321 int thesecols, thesebytes;
3322 thesebytes = utf8_egc_len(egcs, &thesecols);
3323 if(thesebytes < 0){
3324 return -1;
3325 }
3326 egcs += thesebytes;
3327 *validbytes += thesebytes;
3328 *validwidth += thesecols;
3329 }while(*egcs);
3330 return *validwidth;
3331}
Here is the caller graph for this function:

◆ ncsubproc_createv()

API ALLOC struct ncsubproc * ncsubproc_createv ( struct ncplane n,
const ncsubproc_options opts,
const char *  bin,
const char *const  arg[],
ncfdplane_callback  cbfxn,
ncfdplane_done_cb  donecbfxn 
)

Definition at line 383 of file fd.c.

385 {
386 return ncexecvpe(n, opts, 0, bin, (char* const *)arg, NULL, cbfxn, donecbfxn);
387}

◆ ncsubproc_createvp()

API ALLOC struct ncsubproc * ncsubproc_createvp ( struct ncplane n,
const ncsubproc_options opts,
const char *  bin,
const char *const  arg[],
ncfdplane_callback  cbfxn,
ncfdplane_done_cb  donecbfxn 
)

Definition at line 389 of file fd.c.

391 {
392 return ncexecvpe(n, opts, 1, bin, (char* const *)arg, NULL, cbfxn, donecbfxn);
393}

◆ ncsubproc_createvpe()

API ALLOC struct ncsubproc * ncsubproc_createvpe ( struct ncplane n,
const ncsubproc_options opts,
const char *  bin,
const char *const  arg[],
const char *const  env[],
ncfdplane_callback  cbfxn,
ncfdplane_done_cb  donecbfxn 
)

Definition at line 395 of file fd.c.

398 {
399 return ncexecvpe(n, opts, 1, bin, (char* const *)arg, (char* const*)env, cbfxn, donecbfxn);
400}

◆ ncsubproc_destroy()

API int ncsubproc_destroy ( struct ncsubproc n)

Definition at line 402 of file fd.c.

402 {
403 int ret = 0;
404 if(n){
405 void* vret = NULL;
406//fprintf(stderr, "pid: %u pidfd: %d waittid: %u\n", n->pid, n->pidfd, n->waittid);
407#ifndef __MINGW32__
408#ifdef USING_PIDFD
409 if(n->pidfd >= 0){
410 loginfo("sending SIGKILL to pidfd %d", n->pidfd);
411 if(syscall(__NR_pidfd_send_signal, n->pidfd, SIGKILL, NULL, 0)){
412 kill(n->pid, SIGKILL);
413 }
414 }
415#else
416 pthread_mutex_lock(&n->lock);
417 if(!n->waited){
418 loginfo("sending SIGKILL to PID %d", n->pid);
419 kill(n->pid, SIGKILL);
420 }
421 pthread_mutex_unlock(&n->lock);
422#endif
423#endif
424 // the thread waits on the subprocess via pidfd (iff pidfd >= 0), and
425 // then exits. don't try to cancel the thread in that case; rely instead on
426 // killing the subprocess.
427 if(n->pidfd < 0){
428 pthread_cancel(n->nfp->tid);
429 // shouldn't need a cancellation of waittid thanks to SIGKILL
430 pthread_join(n->waittid, &vret);
431 }
432 if(vret == NULL){
433 pthread_join(n->nfp->tid, &vret);
434 }else{
435 pthread_join(n->nfp->tid, NULL);
436 }
437 pthread_mutex_destroy(&n->lock);
438 free(n);
439 if(vret == NULL){
440 ret = -1;
441 }else if(vret != PTHREAD_CANCELED){
442 ret = *(int*)vret;
443 free(vret);
444 }
445 }
446 return ret;
447}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncsubproc_plane()

API struct ncplane * ncsubproc_plane ( struct ncsubproc n)

Definition at line 449 of file fd.c.

449 {
450 return n->nfp->ncp;
451}
Here is the caller graph for this function:

◆ nctab_cb()

API tabcb nctab_cb ( struct nctab t)

Definition at line 124 of file tabbed.c.

124 {
125 return t->cb;
126}
tabcb cb
Definition internal.h:233

◆ nctab_move()

API int nctab_move ( struct nctabbed nt,
struct nctab t,
struct nctab after,
struct nctab before 
)

◆ nctab_move_left()

API int API void API void nctab_move_left ( struct nctabbed nt,
struct nctab t 
)

◆ nctab_move_right()

API int API void nctab_move_right ( struct nctabbed nt,
struct nctab t 
)

◆ nctab_name()

API const char * nctab_name ( struct nctab t)

Definition at line 128 of file tabbed.c.

128 {
129 return t->name;
130}
char * name
Definition internal.h:234

◆ nctab_name_width()

API int nctab_name_width ( struct nctab t)

Definition at line 132 of file tabbed.c.

132 {
133 return t->namecols;
134}
int namecols
Definition internal.h:235

◆ nctab_next()

API struct nctab * nctab_next ( struct nctab t)

Definition at line 140 of file tabbed.c.

140 {
141 return t->next;
142}
struct nctab * next
Definition internal.h:238

◆ nctab_prev()

API struct nctab * nctab_prev ( struct nctab t)

Definition at line 144 of file tabbed.c.

144 {
145 return t->prev;
146}
struct nctab * prev
Definition internal.h:237

◆ nctab_set_cb()

API tabcb nctab_set_cb ( struct nctab t,
tabcb  newcb 
)

Definition at line 448 of file tabbed.c.

448 {
449 tabcb prevcb = t->cb;
450 t->cb = newcb;
451 return prevcb;
452}
void(* tabcb)(struct nctab *t, struct ncplane *ncp, void *curry)
Definition notcurses.h:4250

◆ nctab_set_name()

API int nctab_set_name ( struct nctab t,
const char *  newname 
)

◆ nctab_set_userptr()

API int API void * nctab_set_userptr ( struct nctab t,
void *  newopaque 
)

Definition at line 471 of file tabbed.c.

471 {
472 void* prevcurry = t->curry;
473 t->curry = newopaque;
474 return prevcurry;
475}
void * curry
Definition internal.h:236

◆ nctab_userptr()

API void * nctab_userptr ( struct nctab t)

Definition at line 136 of file tabbed.c.

136 {
137 return t->curry;
138}

◆ nctabbed_add()

API ALLOC struct nctab * nctabbed_add ( struct nctabbed nt,
struct nctab after,
struct nctab before,
tabcb  tcb,
const char *  name,
void *  opaque 
)

◆ nctabbed_channels()

API struct nctab API void nctabbed_channels ( struct nctabbed nt,
uint64_t *RESTRICT  hdrchan,
uint64_t *RESTRICT  selchan,
uint64_t *RESTRICT  sepchan 
)

Definition at line 390 of file tabbed.c.

391 {
392 if(hdrchan){
393 memcpy(hdrchan, &nt->opts.hdrchan, sizeof(*hdrchan));
394 }
395 if(selchan){
396 memcpy(selchan, &nt->opts.selchan, sizeof(*selchan));
397 }
398 if(sepchan){
399 memcpy(sepchan, &nt->opts.sepchan, sizeof(*sepchan));
400 }
401}
uint64_t sepchan
Definition tabbed.c:6
uint64_t selchan
Definition tabbed.c:4
uint64_t hdrchan
Definition tabbed.c:5
nctabbed_opsint opts
Definition tabbed.c:20

◆ nctabbed_content_plane()

API struct ncplane * nctabbed_content_plane ( struct nctabbed nt)

Definition at line 120 of file tabbed.c.

120 {
121 return nt->p;
122}
ncplane * p
Definition tabbed.c:13

◆ nctabbed_create()

API ALLOC struct nctabbed * nctabbed_create ( struct ncplane n,
const nctabbed_options opts 
)

Definition at line 148 of file tabbed.c.

148 {
149 nctabbed_options zeroed = {0};
150 ncplane_options nopts = {0};
151 unsigned nrows, ncols;
152 nctabbed* nt = NULL;
153 if(!topts){
154 topts = &zeroed;
155 }
156 if(!nctabbed_validate_opts(topts)){
157 goto err;
158 }
159 if((nt = malloc(sizeof(*nt))) == NULL){
160 logerror("Couldn't allocate nctabbed");
161 goto err;
162 }
163 nt->ncp = n;
164 nt->leftmost = nt->selected = NULL;
165 nt->tabcount = 0;
166 nt->sepcols = 0;
167 nt->opts.separator = NULL;
168 nt->opts.selchan = topts->selchan;
169 nt->opts.hdrchan = topts->hdrchan;
170 nt->opts.sepchan = topts->sepchan;
171 nt->opts.flags = topts->flags;
172 if(topts->separator){
173 if((nt->sepcols = ncstrwidth(topts->separator, NULL, NULL)) < 0){
174 logerror("Separator string contains illegal characters");
175 goto err;
176 }
177 if((nt->opts.separator = strdup(topts->separator)) == NULL){
178 logerror("Couldn't allocate nctabbed separator");
179 goto err;
180 }
181 }
182 ncplane_dim_yx(n, &nrows, &ncols);
183 if(topts->flags & NCTABBED_OPTION_BOTTOM){
184 nopts.y = nopts.x = 0;
185 nopts.cols = ncols;
186 nopts.rows = nrows - 1;
187 if((nt->p = ncplane_create(n, &nopts)) == NULL){
188 logerror("Couldn't create the tab content plane");
189 goto err;
190 }
191 nopts.y = nrows - 2;
192 nopts.rows = 1;
193 if((nt->hp = ncplane_create(n, &nopts)) == NULL){
194 logerror("Couldn't create the tab headers plane");
195 ncplane_destroy(nt->p);
196 goto err;
197 }
198 }else{
199 nopts.y = nopts.x = 0;
200 nopts.cols = ncols;
201 nopts.rows = 1;
202 if((nt->hp = ncplane_create(n, &nopts)) == NULL){
203 logerror("Couldn't create the tab headers plane");
204 goto err;
205 }
206 nopts.y = 1;
207 nopts.rows = nrows - 1;
208 if((nt->p = ncplane_create(n, &nopts)) == NULL){
209 logerror("Couldn't create the tab content plane");
210 ncplane_destroy(nt->hp);
211 goto err;
212 }
213 }
214 if(ncplane_set_widget(nt->ncp, nt, (void(*)(void*))nctabbed_destroy)){
215 ncplane_destroy(nt->hp);
216 ncplane_destroy(nt->p);
217 goto err;
218 }
219 nctabbed_redraw(nt);
220 return nt;
221
222err:
224 if(nt){
225 free(nt->opts.separator);
226 free(nt);
227 }
228 return NULL;
229}
int ncplane_destroy_family(ncplane *ncp)
Definition notcurses.c:1068
#define NCTABBED_OPTION_BOTTOM
Definition notcurses.h:4237
char * separator
Definition tabbed.c:7
uint64_t flags
Definition tabbed.c:8
ncplane * ncp
Definition tabbed.c:12
nctab * leftmost
Definition tabbed.c:16
ncplane * hp
Definition tabbed.c:14
nctab * selected
Definition tabbed.c:17
int sepcols
Definition tabbed.c:19
int tabcount
Definition tabbed.c:18
void nctabbed_destroy(nctabbed *nt)
Definition tabbed.c:411
void nctabbed_redraw(nctabbed *nt)
Definition tabbed.c:23
Here is the call graph for this function:

◆ nctabbed_del()

API ALLOC struct nctab API int nctabbed_del ( struct nctabbed nt,
struct nctab t 
)

Definition at line 280 of file tabbed.c.

280 {
281 if(!t){
282 logerror("Provided NULL nctab");
283 return -1;
284 }
285 if(nt->tabcount == 1){
286 nt->leftmost = nt->selected = NULL;
287 }else{
288 if(nt->selected == t){
289 nt->selected = t->next;
290 }
291 if(nt->leftmost == t){
292 nt->leftmost = t->next;
293 }
294 t->next->prev = t->prev;
295 t->prev->next = t->next;
296 }
297 free(t->name);
298 free(t);
299 --nt->tabcount;
300 return 0;
301}
Here is the call graph for this function:

◆ nctabbed_destroy()

API void nctabbed_destroy ( struct nctabbed nt)

Definition at line 411 of file tabbed.c.

411 {
412 if(!nt){
413 return;
414 }
415 if(ncplane_set_widget(nt->ncp, NULL, NULL) == 0){
416 nctab* t = nt->leftmost;
417 nctab* tmp;
418 if(t){
419 t->prev->next = NULL;
420 if(t->next){
421 t->next->prev = NULL;
422 }
423 }
424 while(t){
425 tmp = t->next;
426 free(t->name);
427 free(t);
428 t = tmp;
429 }
431 free(nt->opts.separator);
432 free(nt);
433 }
434}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nctabbed_ensure_selected_header_visible()

API void nctabbed_ensure_selected_header_visible ( struct nctabbed nt)

Definition at line 69 of file tabbed.c.

69 {
70 nctab* t = nt->leftmost;
71 int cols = ncplane_dim_x(nt->hp);
72 int takencols = 0;
73 if(!t){
74 return;
75 }
76//fprintf(stderr, "ensuring selected header visible\n");
77 do{
78 if(t == nt->selected){
79 break;
80 }
81 takencols += t->namecols + nt->sepcols;
82 if(takencols >= cols){
83//fprintf(stderr, "not enough space, rotating\n");
84 takencols -= nt->leftmost->namecols + nt->sepcols;
85 nctabbed_rotate(nt, -1);
86 }
87 t = t->next;
88//fprintf(stderr, "iteration over: takencols = %d, cols = %d\n", takencols, cols);
89 }while(t != nt->leftmost);
90//fprintf(stderr, "ensuring done\n");
91}
void nctabbed_rotate(nctabbed *nt, int amt)
Definition tabbed.c:356
Here is the call graph for this function:

◆ nctabbed_leftmost()

API struct nctab * nctabbed_leftmost ( struct nctabbed nt)

Definition at line 108 of file tabbed.c.

108 {
109 return nt->leftmost;
110}

◆ nctabbed_next()

API struct nctab * nctabbed_next ( struct nctabbed nt)

Definition at line 368 of file tabbed.c.

368 {
369 if(nt->tabcount == 0){
370 return NULL;
371 }
372 nt->selected = nt->selected->next;
373 return nt->selected;
374}

◆ nctabbed_plane()

API struct ncplane * nctabbed_plane ( struct nctabbed nt)

Definition at line 116 of file tabbed.c.

116 {
117 return nt->ncp;
118}

◆ nctabbed_prev()

API struct nctab * nctabbed_prev ( struct nctabbed nt)

Definition at line 376 of file tabbed.c.

376 {
377 if(nt->tabcount == 0){
378 return NULL;
379 }
380 nt->selected = nt->selected->prev;
381 return nt->selected;
382}

◆ nctabbed_redraw()

API void nctabbed_redraw ( struct nctabbed nt)

Definition at line 23 of file tabbed.c.

23 {
24 nctab* t;
25 unsigned drawn_cols = 0;
26 unsigned rows, cols;
27 if(nt->tabcount == 0){
28 // no tabs = nothing to draw
29 ncplane_erase(nt->hp);
30 return;
31 }
32 // update sizes for planes
33 ncplane_dim_yx(nt->ncp, &rows, &cols);
35 ncplane_resize_simple(nt->hp, -1, cols);
36 ncplane_resize_simple(nt->p, rows - 1, cols);
37 ncplane_move_yx(nt->hp, rows - 2, 0);
38 }else{
39 ncplane_resize_simple(nt->hp, -1, cols);
40 ncplane_resize_simple(nt->p, rows - 1, cols);
41 }
42 // the callback draws the tab contents
43 if(nt->selected->cb){
44 nt->selected->cb(nt->selected, nt->p, nt->selected->curry);
45 }
46 // now we draw the headers
47 t = nt->leftmost;
48 ncplane_erase(nt->hp);
50 do{
51 if(t == nt->selected){
53 drawn_cols += ncplane_putstr(nt->hp, t->name);
55 }else{
56 drawn_cols += ncplane_putstr(nt->hp, t->name);
57 }
58 // avoid drawing the separator after the last tab, or when we
59 // ran out of space, or when it's not set
60 if((t->next != nt->leftmost || drawn_cols >= cols) && nt->opts.separator){
62 drawn_cols += ncplane_putstr(nt->hp, nt->opts.separator);
64 }
65 t = t->next;
66 }while(t != nt->leftmost && drawn_cols < cols);
67}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nctabbed_rotate()

API int API void API void API void nctabbed_rotate ( struct nctabbed nt,
int  amt 
)

Definition at line 356 of file tabbed.c.

356 {
357 if(amt > 0){
358 for(int i = 0 ; i < amt ; ++i){
359 nt->leftmost = nt->leftmost->prev;
360 }
361 }else{
362 for(int i = 0 ; i < -amt ; ++i){
363 nt->leftmost = nt->leftmost->next;
364 }
365 }
366}
Here is the caller graph for this function:

◆ nctabbed_select()

API struct nctab * nctabbed_select ( struct nctabbed nt,
struct nctab t 
)

◆ nctabbed_selected()

API struct nctab * nctabbed_selected ( struct nctabbed nt)

Definition at line 104 of file tabbed.c.

104 {
105 return nt->selected;
106}

◆ nctabbed_separator()

API const char * nctabbed_separator ( struct nctabbed nt)

Definition at line 403 of file tabbed.c.

403 {
404 return nt->opts.separator;
405}

◆ nctabbed_separator_width()

API int nctabbed_separator_width ( struct nctabbed nt)

Definition at line 407 of file tabbed.c.

407 {
408 return nt->sepcols;
409}

◆ nctabbed_set_hdrchan()

API void nctabbed_set_hdrchan ( struct nctabbed nt,
uint64_t  chan 
)

Definition at line 436 of file tabbed.c.

436 {
437 nt->opts.hdrchan = chan;
438}

◆ nctabbed_set_selchan()

API void nctabbed_set_selchan ( struct nctabbed nt,
uint64_t  chan 
)

Definition at line 440 of file tabbed.c.

440 {
441 nt->opts.selchan = chan;
442}

◆ nctabbed_set_separator()

API int nctabbed_set_separator ( struct nctabbed nt,
const char *  separator 
)

◆ nctabbed_set_sepchan()

API void nctabbed_set_sepchan ( struct nctabbed nt,
uint64_t  chan 
)

Definition at line 444 of file tabbed.c.

444 {
445 nt->opts.sepchan = chan;
446}

◆ nctabbed_tabcount()

API int nctabbed_tabcount ( struct nctabbed nt)

Definition at line 112 of file tabbed.c.

112 {
113 return nt->tabcount;
114}

◆ nctablet_plane()

API struct ncplane * nctablet_plane ( struct nctablet t)

Definition at line 799 of file reel.c.

799 {
800 return t->cbp;
801}

◆ nctablet_userptr()

API void * nctablet_userptr ( struct nctablet t)

Definition at line 893 of file reel.c.

893 {
894 return t->curry;
895}
Here is the caller graph for this function:

◆ nctree_add()

API int nctree_add ( struct nctree n,
const unsigned *  spec,
const struct nctree_item add 
)

◆ nctree_create()

API ALLOC struct nctree * nctree_create ( struct ncplane n,
const nctree_options opts 
)

◆ nctree_del()

API int API int nctree_del ( struct nctree n,
const unsigned *  spec 
)

◆ nctree_destroy()

API int API int API void nctree_destroy ( struct nctree n)

Definition at line 294 of file tree.c.

294 {
295 if(n){
296 free_tree_items(&n->items);
297 free(n->currentpath);
298 free(n);
299 }
300}
Here is the call graph for this function:

◆ nctree_focused()

API bool API void * nctree_focused ( struct nctree n)

Definition at line 606 of file tree.c.

606 {
607 return n->curitem->curry;
608}

◆ nctree_goto()

API void * nctree_goto ( struct nctree n,
const unsigned *  spec,
int *  failspec 
)

Definition at line 610 of file tree.c.

610 {
611 n->activerow = 0;
612 (void)spec;
613 (void)failspec;
614 // FIXME
615 return NULL;
616}

◆ nctree_next()

API void * nctree_next ( struct nctree n)

Definition at line 396 of file tree.c.

396 {
397 int rows = 0;
398 if(n->curitem->ncp){
399 rows = ncplane_dim_y(n->curitem->ncp);
400 }
401 nctree_int_item* tmp = nctree_next_internal(n, n->currentpath);
402 if(tmp != n->curitem){
403 n->curitem = tmp;
404 n->activerow += rows;
405 if(n->activerow >= (int)ncplane_dim_y(n->items.ncp)){
406 n->activerow = ncplane_dim_y(n->items.ncp) - 1;
407 }
408 }
409 return n->curitem->curry;
410}
void * curry
Definition tree.c:5
Here is the caller graph for this function:

◆ nctree_offer_input()

API bool nctree_offer_input ( struct nctree n,
const ncinput ni 
)

◆ nctree_plane()

API ALLOC struct nctree API struct ncplane * nctree_plane ( struct nctree n)

Definition at line 303 of file tree.c.

303 {
304 return n->items.ncp;
305}

◆ nctree_prev()

API void * nctree_prev ( struct nctree n)

Definition at line 349 of file tree.c.

349 {
350 int rows = 0;
351 if(n->curitem->ncp){
352 rows = ncplane_dim_y(n->curitem->ncp);
353 }
354 nctree_int_item* tmp = nctree_prev_internal(n, n->currentpath);
355 if(tmp != n->curitem){
356 n->curitem = tmp;
357 n->activerow -= rows;
358 if(n->activerow < 0){
359 n->activerow = 0;
360 }
361 }
362 return n->curitem->curry;
363}
Here is the caller graph for this function:

◆ nctree_redraw()

API int nctree_redraw ( struct nctree n)

Definition at line 568 of file tree.c.

568 {
569 unsigned* tmppath = malloc(sizeof(*tmppath) * (n->maxdepth + 2));
570 if(tmppath == NULL){
571 return -1;
572 }
573 memcpy(tmppath, n->currentpath, sizeof(*tmppath) * (n->maxdepth + 1));
574 int ret = nctree_inner_redraw(n, tmppath);
575 free(tmppath);
576 return ret;
577}
Here is the call graph for this function:

◆ ncuplot_add_sample()

API int ncuplot_add_sample ( struct ncuplot *  n,
uint64_t  x,
uint64_t  y 
)

Definition at line 666 of file plot.c.

667 {
668 const int64_t diff = ncp->plot.slotx - x; /* amount behind */

◆ ncuplot_create()

API ALLOC struct ncuplot * ncuplot_create ( struct ncplane n,
const ncplot_options opts,
uint64_t  miny,
uint64_t  maxy 
)

Definition at line 647 of file plot.c.

647 {
648 return -1;
649 }
650 return 0;
651}
652
653/* x must be within n's window at this point */
654static void
655update_sample_uint64_t(ncuplot* ncp, int64_t x, uint64_t y, bool reset){
656 const int64_t diff = ncp->plot.slotx - x; /* amount behind */
657 const int idx = (ncp->plot.slotstart + ncp->plot.slotcount - diff) % ncp->plot.slotcount;
658 if(reset){
659 ncp->slots[idx] = y;
660 }else{
Here is the caller graph for this function:

◆ ncuplot_destroy()

API void ncuplot_destroy ( struct ncuplot *  n)

Definition at line 681 of file plot.c.

686 { // create_uint64_t() destroys n on error
687 ncuplot_destroy(ret);
void ncuplot_destroy(ncuplot *n)
Definition plot.c:681
Here is the caller graph for this function:

◆ ncuplot_plane()

API struct ncplane * ncuplot_plane ( struct ncuplot *  n)

Definition at line 662 of file plot.c.

◆ ncuplot_sample()

API int ncuplot_sample ( const struct ncuplot *  n,
uint64_t  x,
uint64_t *  y 
)

◆ ncuplot_set_sample()

API int ncuplot_set_sample ( struct ncuplot *  n,
uint64_t  x,
uint64_t  y 
)

Definition at line 670 of file plot.c.

670 {
671 ncp->slots[idx] = y;
672 }else{
673 ncp->slots[idx] += y;
674 }
675}
676
677// takes ownership of n on all paths
678ncuplot* ncuplot_create(ncplane* n, const ncplot_options* opts, uint64_t miny, uint64_t maxy){
679 ncuplot* ret = malloc(sizeof(*ret));
ncuplot * ncuplot_create(ncplane *n, const ncplot_options *opts, uint64_t miny, uint64_t maxy)
Definition plot.c:647

◆ ncvisual_at_yx()

API int ncvisual_at_yx ( const struct ncvisual n,
unsigned  y,
unsigned  x,
uint32_t *  pixel 
)

◆ ncvisual_blit()

API struct ncplane * ncvisual_blit ( struct notcurses nc,
struct ncvisual ncv,
const struct ncvisual_options vopts 
)

Definition at line 1136 of file visual.c.

1136 {
1137//fprintf(stderr, "%p tacache: %p\n", n, n->tacache);
1138 struct ncvisual_options fakevopts;
1139 if(vopts == NULL){
1140 memset(&fakevopts, 0, sizeof(fakevopts));
1141 vopts = &fakevopts;
1142 }
1143 loginfo("inblit %dx%d %d@%d %dx%d @ %dx%d %p", ncv->pixy, ncv->pixx, vopts->y, vopts->x,
1144 vopts->leny, vopts->lenx, vopts->begy, vopts->begx, vopts->n);
1145 ncvgeom geom;
1146 const struct blitset* bset;
1147 unsigned disppxy, disppxx, outy, outx;
1148 int placey, placex;
1149 if(ncvisual_geom_inner(&nc->tcache, ncv, vopts, &geom, &bset,
1150 &disppxy, &disppxx, &outy, &outx,
1151 &placey, &placex)){
1152 // ncvisual_blitset_geom() emits its own diagnostics, no need for an error here
1153 return NULL;
1154 }
1155 ncplane* n = vopts->n;
1156 uint32_t transcolor = 0;
1158 transcolor = 0x1000000ull | vopts->transcolor;
1159 }
1160 ncplane* createdn = NULL; // to destroy on error
1161 if(n == NULL || (vopts->flags & NCVISUAL_OPTION_CHILDPLANE)){ // create plane
1162 struct ncplane_options nopts = {
1163 .y = placey,
1164 .x = placex,
1165 .rows = geom.rcelly,
1166 .cols = geom.rcellx,
1167 .userptr = NULL,
1168 .name = geom.blitter == NCBLIT_PIXEL ? "bmap" : "cvis",
1169 .resizecb = NULL,
1170 .flags = 0,
1171 };
1174 nopts.x = vopts->x;
1175 }
1178 nopts.y = vopts->y;
1179 }
1180 loginfo("placing new plane: %d/%d @ %d/%d 0x%016" PRIx64, nopts.rows, nopts.cols, nopts.y, nopts.x, nopts.flags);
1181 if(n == NULL){
1182 n = ncpile_create(nc, &nopts);
1183 }else{
1184 n = ncplane_create(n, &nopts);
1185 }
1186 if((createdn = n) == NULL){
1187 return NULL;
1188 }
1189 placey = 0;
1190 placex = 0;
1191 }
1192 logdebug("blit to plane %p at %d/%d geom %dx%d", n, ncplane_abs_y(n), ncplane_abs_x(n), ncplane_dim_y(n), ncplane_dim_x(n));
1193 if(geom.blitter != NCBLIT_PIXEL){
1194 n = ncvisual_render_cells(ncv, bset, placey, placex,
1195 &geom, n, vopts->flags, transcolor);
1196 }else{
1197 n = ncvisual_render_pixels(nc, ncv, bset, placey, placex,
1198 &geom, n,
1199 vopts->flags, transcolor,
1200 vopts->pxoffy, vopts->pxoffx);
1201 }
1202 if(n == NULL){
1203 ncplane_destroy(createdn);
1204 }
1205 return n;
1206}
ncplane * ncpile_create(notcurses *nc, const struct ncplane_options *nopts)
Definition notcurses.c:711
#define NCPLANE_OPTION_HORALIGNED
Definition notcurses.h:1441
#define NCPLANE_OPTION_VERALIGNED
Definition notcurses.h:1443
#define NCVISUAL_OPTION_ADDALPHA
Definition notcurses.h:3341
#define NCVISUAL_OPTION_VERALIGNED
Definition notcurses.h:3340
#define NCVISUAL_OPTION_HORALIGNED
Definition notcurses.h:3339
ncblitter_e geom
Definition internal.h:399
ncblitter_e blitter
Definition notcurses.h:3406
unsigned rcellx
Definition notcurses.h:3401
unsigned rcelly
Definition notcurses.h:3401
ncplane * ncvisual_render_pixels(notcurses *nc, ncvisual *ncv, const struct blitset *bset, int placey, int placex, const ncvgeom *geom, ncplane *n, uint64_t flags, uint32_t transcolor, int pxoffy, int pxoffx)
Definition visual.c:1050
int ncvisual_geom_inner(const tinfo *ti, const ncvisual *n, const struct ncvisual_options *vopts, ncvgeom *geom, const struct blitset **bset, unsigned *disppixy, unsigned *disppixx, unsigned *outy, unsigned *outx, int *placey, int *placex)
Definition visual.c:208
ncplane * ncvisual_render_cells(ncvisual *ncv, const struct blitset *bset, int placey, int placex, ncvgeom *geom, ncplane *n, uint64_t flags, uint32_t transcolor)
Definition visual.c:1013
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_decode()

API int ncvisual_decode ( struct ncvisual nc)

Definition at line 39 of file visual.c.

39 {
41 return -1;
42 }
44}
int(* visual_decode)(struct ncvisual *nc)
Definition internal.h:1805
ncvisual_implementation * visual_implementation
Definition visual.c:20
Here is the caller graph for this function:

◆ ncvisual_decode_loop()

API int ncvisual_decode_loop ( struct ncvisual nc)

Definition at line 46 of file visual.c.

46 {
48 return -1;
49 }
51}
int(* visual_decode_loop)(struct ncvisual *nc)
Definition internal.h:1806
Here is the caller graph for this function:

◆ ncvisual_destroy()

API void ncvisual_destroy ( struct ncvisual ncv)

Definition at line 1225 of file visual.c.

1225 {
1226 if(ncv){
1228 if(ncv->owndata){
1229 free(ncv->data);
1230 }
1231 free(ncv);
1232 }else{
1234 }
1235 }
1236}
void(* visual_destroy)(struct ncvisual *ncv)
Definition internal.h:1813
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_from_bgra()

API ALLOC struct ncvisual * ncvisual_from_bgra ( const void *  bgra,
int  rows,
int  rowstride,
int  cols 
)

Definition at line 891 of file visual.c.

891 {
892 if(rowstride % 4){
893 logerror("rowstride %d not a multiple of 4", rowstride);
894 return NULL;
895 }
896 if(rows <= 0 || cols <= 0 || rowstride < cols * 4){
897 logerror("illegal bgra geometry");
898 return NULL;
899 }
901 if(ncv){
902 ncv->rowstride = pad_for_image(rowstride, cols);
903 ncv->pixx = cols;
904 ncv->pixy = rows;
905 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
906 if(data == NULL){
908 return NULL;
909 }
910 for(int y = 0 ; y < rows ; ++y){
911 for(int x = 0 ; x < cols ; ++x){
912 uint32_t src;
913 memcpy(&src, (const char*)bgra + y * rowstride + x * 4, 4);
914 uint32_t* dst = &data[ncv->rowstride * y / 4 + x];
915 ncpixel_set_a(dst, ncpixel_a(src));
916 ncpixel_set_r(dst, ncpixel_b(src));
917 ncpixel_set_g(dst, ncpixel_g(src));
918 ncpixel_set_b(dst, ncpixel_r(src));
919//fprintf(stderr, "BGRA PIXEL: %02x%02x%02x%02x RGBA result: %02x%02x%02x%02x\n", ((const char*)&src)[0], ((const char*)&src)[1], ((const char*)&src)[2], ((const char*)&src)[3], ((const char*)dst)[0], ((const char*)dst)[1], ((const char*)dst)[2], ((const char*)dst)[3]);
920 }
921 }
922 ncvisual_set_data(ncv, data, true);
924 }
925 return ncv;
926}
void ncvisual_details_seed(struct ncvisual *ncv)
Definition visual.c:114
ncvisual * ncvisual_create(void)
Definition visual.c:120
Here is the call graph for this function:

◆ ncvisual_from_file()

API ALLOC struct ncvisual * ncvisual_from_file ( const char *  file)

Definition at line 53 of file visual.c.

53 {
55 return NULL;
56 }
58 if(n == NULL){
59 logerror("error loading %s", filename);
60 }
61 return n;
62}
struct ncvisual *(* visual_from_file)(const char *fname)
Definition internal.h:1800
Here is the caller graph for this function:

◆ ncvisual_from_palidx()

API ALLOC struct ncvisual * ncvisual_from_palidx ( const void *  data,
int  rows,
int  rowstride,
int  cols,
int  palsize,
int  pstride,
const uint32_t *  palette 
)

◆ ncvisual_from_plane()

API ALLOC struct ncvisual API ALLOC struct ncvisual * ncvisual_from_plane ( const struct ncplane n,
ncblitter_e  blit,
int  begy,
int  begx,
unsigned  leny,
unsigned  lenx 
)

◆ ncvisual_from_rgb_loose()

API ALLOC struct ncvisual * ncvisual_from_rgb_loose ( const void *  rgba,
int  rows,
int  rowstride,
int  cols,
int  alpha 
)

Definition at line 858 of file visual.c.

859 {
860 if(rowstride % 4){
861 logerror("rowstride %d not a multiple of 4", rowstride);
862 return NULL;
863 }
864 if(rows <= 0 || cols <= 0 || rowstride < cols * 4){
865 logerror("illegal packed rgb geometry");
866 return NULL;
867 }
869 if(ncv){
870 ncv->rowstride = pad_for_image(cols * 4, cols);
871 ncv->pixx = cols;
872 ncv->pixy = rows;
873 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
874 if(data == NULL){
876 return NULL;
877 }
878 for(int y = 0 ; y < rows ; ++y){
879//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, ncv->rowstride / 4, cols, data[ncv->rowstride * y / 4]);
880 memcpy(data + (ncv->rowstride * y) / 4, (const char*)rgba + rowstride * y, rowstride);
881 for(int x = 0 ; x < cols ; ++x){
882 ncpixel_set_a(&data[y * ncv->rowstride / 4 + x], alpha);
883 }
884 }
885 ncvisual_set_data(ncv, data, true);
887 }
888 return ncv;
889}
Here is the call graph for this function:

◆ ncvisual_from_rgb_packed()

API ALLOC struct ncvisual * ncvisual_from_rgb_packed ( const void *  rgba,
int  rows,
int  rowstride,
int  cols,
int  alpha 
)

Definition at line 817 of file visual.c.

818 {
819 if(rowstride % 3){
820 logerror("rowstride %d not a multiple of 3", rowstride);
821 return NULL;
822 }
823 if(rows <= 0 || cols <= 0 || rowstride < cols * 3){
824 logerror("illegal packed rgb geometry");
825 return NULL;
826 }
828 if(ncv){
829 ncv->rowstride = pad_for_image(cols * 4, cols);
830 ncv->pixx = cols;
831 ncv->pixy = rows;
832 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
833 if(data == NULL){
835 return NULL;
836 }
837 const unsigned char* src = rgba;
838 for(int y = 0 ; y < rows ; ++y){
839//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, ncv->rowstride / 4, cols, data[ncv->rowstride * y / 4]);
840 for(int x = 0 ; x < cols ; ++x){
841 unsigned char r, g, b;
842 memcpy(&r, src + rowstride * y + 3 * x, 1);
843 memcpy(&g, src + rowstride * y + 3 * x + 1, 1);
844 memcpy(&b, src + rowstride * y + 3 * x + 2, 1);
845 ncpixel_set_a(&data[y * ncv->rowstride / 4 + x], alpha);
846 ncpixel_set_r(&data[y * ncv->rowstride / 4 + x], r);
847 ncpixel_set_g(&data[y * ncv->rowstride / 4 + x], g);
848 ncpixel_set_b(&data[y * ncv->rowstride / 4 + x], b);
849//fprintf(stderr, "RGBA: 0x%02x 0x%02x 0x%02x 0x%02x\n", r, g, b, alpha);
850 }
851 }
852 ncvisual_set_data(ncv, data, true);
854 }
855 return ncv;
856}
Here is the call graph for this function:

◆ ncvisual_from_rgba()

API ALLOC struct ncvisual * ncvisual_from_rgba ( const void *  rgba,
int  rows,
int  rowstride,
int  cols 
)

Definition at line 776 of file visual.c.

776 {
777 if(rowstride % 4){
778 logerror("rowstride %d not a multiple of 4", rowstride);
779 return NULL;
780 }
781 if(rowstride * 4 < cols || cols <= 0 || rows <= 0){
782 logerror("invalid rowstride or geometry");
783 return NULL;
784 }
786 if(ncv){
787 // ffmpeg needs inputs with rows aligned on 192-byte boundaries
788 ncv->rowstride = pad_for_image(rowstride, cols);
789 ncv->pixx = cols;
790 ncv->pixy = rows;
791 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
792 if(data == NULL){
794 return NULL;
795 }
796 for(int y = 0 ; y < rows ; ++y){
797//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, rowstride, cols, data[ncv->rowstride * y / 4]);
798 memcpy(data + (ncv->rowstride * y) / 4, (const char*)rgba + rowstride * y, rowstride);
799 }
800 ncvisual_set_data(ncv, data, true);
802 }
803 return ncv;
804}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_from_sixel()

API ALLOC struct ncvisual * ncvisual_from_sixel ( const char *  s,
unsigned  leny,
unsigned  lenx 
)

Definition at line 806 of file visual.c.

806 {
807 uint32_t* rgba = ncsixel_as_rgba(s, leny, lenx);
808 if(rgba == NULL){
809 logerror("failed converting sixel to rgba");
810 return NULL;
811 }
812 ncvisual* ncv = ncvisual_from_rgba(rgba, leny, lenx * sizeof(*rgba), lenx);
813 free(rgba);
814 return ncv;
815}
uint32_t * ncsixel_as_rgba(const char *sx, unsigned leny, unsigned lenx)
Definition sixel.h:12
Here is the call graph for this function:

◆ ncvisual_geom()

API int ncvisual_geom ( const struct notcurses nc,
const struct ncvisual n,
const struct ncvisual_options vopts,
ncvgeom geom 
)

◆ ncvisual_media_defblitter()

API ALLOC struct ncplane API ncblitter_e ncvisual_media_defblitter ( const struct notcurses nc,
ncscale_e  scale 
)

◆ ncvisual_polyfill_yx()

API int ncvisual_polyfill_yx ( struct ncvisual n,
unsigned  y,
unsigned  x,
uint32_t  rgba 
)

Definition at line 1344 of file visual.c.

1344 {
1345 if(y >= n->pixy){
1346 logerror("invalid coordinates %u/%u", y, x);
1347 return -1;
1348 }
1349 if(x >= n->pixx){
1350 logerror("invalid coordinates %u/%u", y, x);
1351 return -1;
1352 }
1353 uint32_t* pixel = &n->data[y * (n->rowstride / 4) + x];
1354 return ncvisual_polyfill_core(n, y, x, rgba, *pixel);
1355}
Here is the caller graph for this function:

◆ ncvisual_resize()

API int ncvisual_resize ( struct ncvisual n,
int  rows,
int  cols 
)

Definition at line 982 of file visual.c.

982 {
984 return ncvisual_resize_noninterpolative(n, rows, cols);
985 }
986 if(visual_implementation->visual_resize(n, rows, cols)){
987 return -1;
988 }
989 return 0;
990}
int(* visual_resize)(struct ncvisual *ncv, unsigned rows, unsigned cols)
Definition internal.h:1812
int ncvisual_resize_noninterpolative(ncvisual *n, int rows, int cols)
Definition visual.c:992
Here is the call graph for this function:

◆ ncvisual_resize_noninterpolative()

API int ncvisual_resize_noninterpolative ( struct ncvisual n,
int  rows,
int  cols 
)

Definition at line 992 of file visual.c.

992 {
993 size_t dstride = pad_for_image(cols * 4, cols);
994 uint32_t* r = resize_bitmap(n->data, n->pixy, n->pixx, n->rowstride,
995 rows, cols, dstride);
996 if(r == NULL){
997 return -1;
998 }
999 ncvisual_set_data(n, r, true);
1000 n->rowstride = dstride;
1001 n->pixy = rows;
1002 n->pixx = cols;
1004 return 0;
1005}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_rotate()

API int ncvisual_rotate ( struct ncvisual n,
double  rads 
)

Definition at line 704 of file visual.c.

704 {
705 assert(ncv->rowstride / 4 >= ncv->pixx);
706 rads = -rads; // we're a left-handed Cartesian
707 int centy, centx;
708 ncvisual_center(ncv, &centy, &centx); // pixel center (center of 'data')
709 double stheta, ctheta; // sine, cosine
710 stheta = sin(rads);
711 ctheta = cos(rads);
712 // bounding box for real data within the ncvisual. we must only resize to
713 // accommodate real data, lest we grow without band as we rotate.
714 // see https://github.com/dankamongmen/notcurses/issues/599.
715 int bby = ncv->pixy;
716 int bbx = ncv->pixx;
717 int bboffy = 0;
718 int bboffx = 0;
719 if(ncvisual_bounding_box(ncv, &bby, &bbx, &bboffy, &bboffx) <= 0){
720 logerror("couldn't find a bounding box");
721 return -1;
722 }
723 int bbarea;
724 bbarea = rotate_bounding_box(stheta, ctheta, &bby, &bbx, &bboffy, &bboffx);
725 if(bbarea <= 0){
726 logerror("couldn't rotate the visual (%d, %d, %d, %d)", bby, bbx, bboffy, bboffx);
727 return -1;
728 }
729 int bbcentx = bbx, bbcenty = bby;
730 center_box(&bbcenty, &bbcentx);
731//fprintf(stderr, "stride: %d height: %d width: %d\n", ncv->rowstride, ncv->pixy, ncv->pixx);
732 assert(ncv->rowstride / 4 >= ncv->pixx);
733 uint32_t* data = malloc(bbarea * 4);
734 if(data == NULL){
735 return -1;
736 }
737 memset(data, 0, bbarea * 4);
738//fprintf(stderr, "bbarea: %d bby: %d bbx: %d centy: %d centx: %d bbcenty: %d bbcentx: %d\n", bbarea, bby, bbx, centy, centx, bbcenty, bbcentx);
739 for(unsigned y = 0 ; y < ncv->pixy ; ++y){
740 for(unsigned x = 0 ; x < ncv->pixx ; ++x){
741 int targx = x, targy = y;
742 rotate_point(&targy, &targx, stheta, ctheta, centy, centx);
743 if(targx > bboffx && targy > bboffy){
744 const int deconvx = targx - bboffx;
745 const int deconvy = targy - bboffy;
746 if(deconvy < bby && deconvx < bbx){
747 data[deconvy * bbx + deconvx] = ncv->data[y * (ncv->rowstride / 4) + x];
748 }
749 }
750//fprintf(stderr, "CW: %d/%d (%08x) -> %d/%d (stride: %d)\n", y, x, ncv->data[y * (ncv->rowstride / 4) + x], targy, targx, ncv->rowstride);
751//fprintf(stderr, "wrote %08x to %d (%d)\n", data[targy * ncv->pixy + targx], targy * ncv->pixy + targx, (targy * ncv->pixy + targx) * 4);
752 }
753 }
754 ncvisual_set_data(ncv, data, true);
755 ncv->pixx = bbx;
756 ncv->pixy = bby;
757 ncv->rowstride = bbx * 4;
759 return 0;
760}
assert(false)
int ncvisual_bounding_box(const ncvisual *ncv, int *leny, int *lenx, int *offy, int *offx)
Definition visual.c:534
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_set_yx()

API int API int ncvisual_set_yx ( const struct ncvisual n,
unsigned  y,
unsigned  x,
uint32_t  pixel 
)

Definition at line 1259 of file visual.c.

1259 {
1260 if(y >= n->pixy){
1261 logerror("invalid coordinates %u/%u", y, x);
1262 return -1;
1263 }
1264 if(x >= n->pixx){
1265 logerror("invalid coordinates %u/%u", y, x);
1266 return -1;
1267 }
1268 n->data[y * (n->rowstride / 4) + x] = pixel;
1269 return 0;
1270}
Here is the caller graph for this function:

◆ ncvisual_simple_streamer()

API int ncvisual_simple_streamer ( struct ncvisual ncv,
struct ncvisual_options vopts,
const struct timespec *  tspec,
void *  curry 
)

Definition at line 1238 of file visual.c.

1239 {
1240 struct ncplane* subtitle = NULL;
1241 int ret = 0;
1242 if(curry){
1243 // FIXME improve this hrmmmmm
1244 ncplane* subncp = curry;
1245 if(subncp->blist){
1246 ncplane_destroy(subncp->blist);
1247 subncp->blist = NULL;
1248 }
1249 subtitle = ncvisual_subtitle_plane(subncp, ncv);
1250 }
1251 if(notcurses_render(ncplane_notcurses(vopts->n))){
1252 return -1;
1253 }
1254 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, tspec, NULL);
1255 ncplane_destroy(subtitle);
1256 return ret;
1257}
ncplane * ncvisual_subtitle_plane(ncplane *parent, const ncvisual *ncv)
Definition visual.c:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvisual_stream()

API int ncvisual_stream ( struct notcurses nc,
struct ncvisual ncv,
float  timescale,
ncstreamcb  streamer,
const struct ncvisual_options vopts,
void *  curry 
)

◆ ncvisual_subtitle_plane()

API ALLOC struct ncplane * ncvisual_subtitle_plane ( struct ncplane parent,
const struct ncvisual ncv 
)

◆ notcurses_accountname()

API ALLOC char * notcurses_accountname ( void  )

Definition at line 35 of file util.c.

35 {
36#ifndef __MINGW32__
37 const char* un;
38 if( (un = getenv("LOGNAME")) ){
39 return strdup(un);
40 }
41 uid_t uid = getuid();
42 struct passwd* p = getpwuid(uid);
43 if(p == NULL){
44 return NULL;
45 }
46 return strdup(p->pw_name);
47#else
48 DWORD unlen = UNLEN + 1;
49 char* un = malloc(unlen);
50 if(un == NULL){
51 return NULL;
52 }
53 if(!GetUserNameExA(NameSamCompatible, un, &unlen)){
54 logerror("couldn't get user name");
55 free(un);
56 return NULL;
57 }
58 return un;
59#endif
60}
Here is the call graph for this function:

◆ notcurses_at_yx()

API char * notcurses_at_yx ( struct notcurses nc,
unsigned  yoff,
unsigned  xoff,
uint16_t *  stylemask,
uint64_t *  channels 
)

Definition at line 1625 of file render.c.

1625 {
1626 if(nc->lastframe == NULL){
1627 logerror("haven't yet rendered");
1628 return NULL;
1629 }
1630 if(yoff >= nc->lfdimy){
1631 logerror("invalid coordinates: %u/%u", yoff, xoff);
1632 return NULL;
1633 }
1634 if(xoff >= nc->lfdimx){
1635 logerror("invalid coordinates: %u/%u", yoff, xoff);
1636 return NULL;
1637 }
1638 const nccell* srccell = &nc->lastframe[yoff * nc->lfdimx + xoff];
1639 if(nccell_wide_right_p(srccell)){
1640 return notcurses_at_yx(nc, yoff, xoff - 1, stylemask, channels);
1641 }
1642 if(stylemask){
1643 *stylemask = srccell->stylemask;
1644 }
1645 if(channels){
1646 *channels = srccell->channels;
1647 }
1648//fprintf(stderr, "COPYING: %d from %p\n", srccell->gcluster, &nc->pool);
1649 return pool_egc_copy(&nc->pool, srccell);
1650}
char * notcurses_at_yx(notcurses *nc, unsigned yoff, unsigned xoff, uint16_t *stylemask, uint64_t *channels)
Definition render.c:1625
unsigned lfdimx
Definition internal.h:350
unsigned lfdimy
Definition internal.h:351
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notcurses_canopen_images()

API bool notcurses_canopen_images ( const struct notcurses nc)

◆ notcurses_canopen_videos()

API bool notcurses_canopen_videos ( const struct notcurses nc)

◆ notcurses_capabilities()

API const nccapabilities * notcurses_capabilities ( const struct notcurses n)

◆ notcurses_check_pixel_support()

API ncpixelimpl_e notcurses_check_pixel_support ( const struct notcurses nc)

◆ notcurses_core_init()

API ALLOC struct notcurses * notcurses_core_init ( const notcurses_options opts,
FILE *  fp 
)

Definition at line 1242 of file notcurses.c.

1242 {
1243 if(outfp == NULL){
1244 outfp = stdout;
1245 }
1246 unsigned utf8;
1247 // ret comes out entirely zero-initialized
1248 notcurses* ret = notcurses_early_init(opts, outfp, &utf8);
1249 if(ret == NULL){
1250 return NULL;
1251 }
1252 // the fbuf is needed by notcurses_stop_minimal, so this must be done
1253 // before registering fatal signal handlers.
1254 if(fbuf_init(&ret->rstate.f)){
1255 pthread_mutex_destroy(&ret->pilelock);
1256 pthread_mutex_destroy(&ret->stats.lock);
1257 free(ret);
1258 return NULL;
1259 }
1262 notcurses_stop_minimal)){
1263 fbuf_free(&ret->rstate.f);
1264 pthread_mutex_destroy(&ret->pilelock);
1265 pthread_mutex_destroy(&ret->stats.lock);
1266 free(ret);
1267 return NULL;
1268 }
1269 // don't set loglevel until we've acquired the signal handler, lest we
1270 // change the loglevel out from under a running instance
1271 loglevel = ret->loglevel;
1272 ret->rstate.logendy = -1;
1273 ret->rstate.logendx = -1;
1274 ret->rstate.x = ret->rstate.y = -1;
1275 int fakecursory = ret->rstate.logendy;
1276 int fakecursorx = ret->rstate.logendx;
1277 int* cursory = ret->flags & NCOPTION_PRESERVE_CURSOR ?
1278 &ret->rstate.logendy : &fakecursory;
1279 int* cursorx = ret->flags & NCOPTION_PRESERVE_CURSOR ?
1280 &ret->rstate.logendx : &fakecursorx;
1281 if(interrogate_terminfo(&ret->tcache, ret->ttyfp, utf8,
1284 cursory, cursorx, &ret->stats,
1285 ret->margin_l, ret->margin_t,
1286 ret->margin_r, ret->margin_b,
1287 ret->flags & NCOPTION_DRAIN_INPUT)){
1288 void* altstack;
1289 fbuf_free(&ret->rstate.f);
1290 pthread_mutex_destroy(&ret->pilelock);
1291 pthread_mutex_destroy(&ret->stats.lock);
1292 drop_signals(ret, &altstack);
1293 free(ret);
1294 free(altstack);
1295 return NULL;
1296 }
1297 if(ret->tcache.maxpaletteread > -1){
1298 memcpy(ret->palette.chans, ret->tcache.originalpalette.chans,
1299 sizeof(*ret->palette.chans) * (ret->tcache.maxpaletteread + 1));
1300 }
1301 if((ret->flags & NCOPTION_PRESERVE_CURSOR) ||
1302 (!(ret->flags & NCOPTION_SUPPRESS_BANNERS))){
1303 // the u7 led the queries so that we would get a cursor position
1304 // unaffected by any query spill (unconsumed control sequences). move
1305 // us back to that location, in case there was any such spillage.
1306 if(*cursory < 0 || *cursorx < 0){
1307 unsigned cy, cx;
1308 if(locate_cursor(&ret->tcache, &cy, &cx)){
1309 logwarn("couldn't preserve cursor");
1310 }else{
1311 *cursory = cy;
1312 *cursorx = cx;
1313 }
1314 }
1315 if(*cursory >= 0 && *cursorx >= 0){
1316 if(goto_location(ret, &ret->rstate.f, *cursory, *cursorx, NULL)){
1317 goto err;
1318 }
1319 }
1320 }
1321 unsigned dimy, dimx, cgeo, pgeo; // latter two are don't-cares
1322 if(update_term_dimensions(&dimy, &dimx, &ret->tcache, ret->margin_b, &cgeo, &pgeo)){
1323 goto err;
1324 }
1325 if(ncvisual_init(ret->loglevel)){
1326 goto err;
1327 }
1328 ret->stdplane = NULL;
1329 if((ret->stdplane = create_initial_ncplane(ret, dimy, dimx)) == NULL){
1330 logpanic("couldn't create the initial plane (bad margins?)");
1331 goto err;
1332 }
1333 if(ret->flags & NCOPTION_SCROLLING){
1334 ncplane_set_scrolling(ret->stdplane, true);
1335 }
1336 reset_term_attributes(&ret->tcache, &ret->rstate.f);
1337 const char* cinvis = get_escape(&ret->tcache, ESCAPE_CIVIS);
1338 if(cinvis && fbuf_emit(&ret->rstate.f, cinvis) < 0){
1339 free_plane(ret->stdplane);
1340 goto err;
1341 }
1342 const char* pushcolors = get_escape(&ret->tcache, ESCAPE_SAVECOLORS);
1343 if(pushcolors && fbuf_emit(&ret->rstate.f, pushcolors)){
1344 free_plane(ret->stdplane);
1345 goto err;
1346 }
1347 init_banner(ret, &ret->rstate.f);
1348 if(fbuf_flush(&ret->rstate.f, ret->ttyfp) < 0){
1349 free_plane(ret->stdplane);
1350 goto err;
1351 }
1352 if(ret->rstate.logendy >= 0){ // if either is set, both are
1353 if(!(ret->flags & NCOPTION_SUPPRESS_BANNERS) && ret->tcache.ttyfd >= 0){
1354 unsigned uendy, uendx;
1355 if(locate_cursor(&ret->tcache, &uendy, &uendx)){
1356 free_plane(ret->stdplane);
1357 goto err;
1358 }
1359 ret->rstate.logendy = uendy;
1360 ret->rstate.logendx = uendx;
1361 }
1364 }
1365 }
1366 if(!(ret->flags & NCOPTION_NO_ALTERNATE_SCREEN)){
1367 // perform an explicit clear since the alternate screen was requested
1368 // (smcup *might* clear, but who knows? and it might not have been
1369 // available in any case).
1370 if(clear_and_home(ret, &ret->tcache, &ret->rstate.f)){
1371 goto err;
1372 }
1373 // no need to reestablish a preserved cursor -- that only affects the
1374 // standard plane, not the physical cursor that was just disrupted.
1375 }
1376 // the sprite clear ought take place within the alternate screen, if it's
1377 // being used.
1378 if(!(ret->flags & NCOPTION_NO_CLEAR_BITMAPS)){
1379 if(sprite_clear_all(&ret->tcache, &ret->rstate.f)){
1380 goto err;
1381 }
1382 }
1383 if(ret->rstate.f.used){
1384 if(fbuf_flush(&ret->rstate.f, ret->ttyfp) < 0){
1385 goto err;
1386 }
1387 }
1388 return ret;
1389
1390err:{
1391 void* altstack;
1392 logpanic("alas, you will not be going to space today.");
1393 notcurses_stop_minimal(ret, &altstack);
1394 fbuf_free(&ret->rstate.f);
1395 if(ret->tcache.ttyfd >= 0 && ret->tcache.tpreserved){
1396 (void)tcsetattr(ret->tcache.ttyfd, TCSAFLUSH, ret->tcache.tpreserved);
1397 free(ret->tcache.tpreserved);
1398 }
1399 del_curterm(cur_term);
1400 pthread_mutex_destroy(&ret->stats.lock);
1401 pthread_mutex_destroy(&ret->pilelock);
1402 free(ret);
1403 free(altstack);
1404 return NULL;
1405 }
1406}
int init_banner(const notcurses *nc, fbuf *f)
Definition banner.c:27
ncloglevel_e loglevel
Definition debug.c:3
int ncvisual_init(int loglevel)
Definition visual.c:23
int sprite_clear_all(const tinfo *t, fbuf *f)
Definition sprite.c:204
int clear_and_home(notcurses *nc, tinfo *ti, fbuf *f)
Definition render.c:1399
#define logpanic(fmt,...)
Definition logging.h:22
int update_term_dimensions(unsigned *rows, unsigned *cols, tinfo *tcache, int margin_b, unsigned *cgeo_changed, unsigned *pgeo_changed)
Definition notcurses.c:316
bool ncplane_set_scrolling(ncplane *n, unsigned scrollp)
Definition notcurses.c:2993
int reset_term_attributes(const tinfo *ti, fbuf *f)
Definition notcurses.c:60
#define NCOPTION_SUPPRESS_BANNERS
Definition notcurses.h:1015
#define NCOPTION_DRAIN_INPUT
Definition notcurses.h:1030
#define NCOPTION_NO_QUIT_SIGHANDLERS
Definition notcurses.h:1005
#define NCOPTION_NO_WINCH_SIGHANDLER
Definition notcurses.h:1000
#define NCOPTION_NO_FONT_CHANGES
Definition notcurses.h:1025
uint64_t used
Definition fbuf.h:27
uint32_t chans[NCPALETTESIZE]
Definition notcurses.h:1585
pthread_mutex_t pilelock
Definition internal.h:361
uint64_t flags
Definition internal.h:369
int margin_l
Definition internal.h:364
FILE * ttyfp
Definition internal.h:359
ncplane * stdplane
Definition internal.h:333
int margin_t
Definition internal.h:364
int margin_b
Definition internal.h:364
int margin_r
Definition internal.h:364
int loglevel
Definition internal.h:365
int maxpaletteread
Definition termdesc.h:193
ncpalette originalpalette
Definition termdesc.h:192
struct termios * tpreserved
Definition termdesc.h:180
int ttyfd
Definition termdesc.h:109
int locate_cursor(tinfo *ti, unsigned *cursor_y, unsigned *cursor_x)
Definition termdesc.c:1558
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
@ ESCAPE_CIVIS
Definition termdesc.h:54
@ ESCAPE_SAVECOLORS
Definition termdesc.h:87
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:

◆ notcurses_cursor_disable()

API int notcurses_cursor_disable ( struct notcurses nc)

Definition at line 1772 of file render.c.

1772 {
1773 if(nc->cursorx < 0 || nc->cursory < 0){
1774 logerror("cursor is not enabled");
1775 return -1;
1776 }
1777 const char* cinvis = get_escape(&nc->tcache, ESCAPE_CIVIS);
1778 if(cinvis){
1779 if(!tty_emit(cinvis, nc->tcache.ttyfd) && !ncflush(nc->ttyfp)){
1780 nc->cursory = -1;
1781 nc->cursorx = -1;
1782 return 0;
1783 }
1784 }
1785 return -1;
1786}
int cursorx
Definition internal.h:354
int cursory
Definition internal.h:353
Here is the caller graph for this function:

◆ notcurses_cursor_enable()

API int notcurses_cursor_enable ( struct notcurses nc,
int  y,
int  x 
)

Definition at line 1738 of file render.c.

1738 {
1739 if(y < 0 || x < 0){
1740 logerror("illegal cursor placement: %d, %d", y, x);
1741 return -1;
1742 }
1743 // if we're already at the demanded location, we must already be visible, and
1744 // we needn't move the cursor -- return success immediately.
1745 if(nc->cursory == y && nc->cursorx == x){
1746 return 0;
1747 }
1748 fbuf f = {0};
1749 if(fbuf_init_small(&f)){
1750 return -1;
1751 }
1752 // updates nc->rstate.cursor{y,x}
1753 if(goto_location(nc, &f, y + nc->margin_t, x + nc->margin_l, nc->rstate.lastsrcp)){
1754 fbuf_free(&f);
1755 return -1;
1756 }
1757 if(nc->cursory < 0){ // we weren't visible before, need cnorm
1758 const char* cnorm = get_escape(&nc->tcache, ESCAPE_CNORM);
1759 if(!cnorm || fbuf_emit(&f, cnorm)){
1760 fbuf_free(&f);
1761 return -1;
1762 }
1763 }
1764 if(fbuf_finalize(&f, nc->ttyfp)){
1765 return -1;
1766 }
1767 nc->cursory = y;
1768 nc->cursorx = x;
1769 return 0;
1770}
Definition fbuf.h:25
const ncplane * lastsrcp
Definition internal.h:140
@ ESCAPE_CNORM
Definition termdesc.h:55
Here is the caller graph for this function:

◆ notcurses_cursor_yx()

API int notcurses_cursor_yx ( const struct notcurses nc,
int *  y,
int *  x 
)

◆ notcurses_debug()

API void notcurses_debug ( const struct notcurses nc,
FILE *  debugfp 
)

◆ notcurses_default_background()

API int notcurses_default_background ( const struct notcurses nc,
uint32_t *  bg 
)

Definition at line 1722 of file render.c.

1722 {
1723 const tinfo* ti = &nc->tcache;
1724 if(ti->bg_collides_default & 0x80000000){
1725 logerror("default background could not be determined");
1726 return -1;
1727 }
1729 return 0;
1730}
#define NC_BG_RGB_MASK
Definition notcurses.h:120
uint32_t bg_collides_default
Definition termdesc.h:127

◆ notcurses_default_foreground()

API int notcurses_default_foreground ( const struct notcurses nc,
uint32_t *  fg 
)

Definition at line 1712 of file render.c.

1712 {
1713 const tinfo* ti = &nc->tcache;
1714 if(ti->fg_default & 0x80000000){
1715 logerror("default foreground could not be determined");
1716 return -1;
1717 }
1718 *fg = ti->fg_default & NC_BG_RGB_MASK;
1719 return 0;
1720}
uint32_t fg_default
Definition termdesc.h:130

◆ notcurses_detected_terminal()

ALLOC API char * notcurses_detected_terminal ( const struct notcurses nc)

◆ notcurses_drop_planes()

API int API int API void notcurses_drop_planes ( struct notcurses nc)

Definition at line 1434 of file notcurses.c.

1434 {
1435 logdebug("we have some planes");
1436 pthread_mutex_lock(&nc->pilelock);
1437 ncpile* p = ncplane_pile(nc->stdplane);
1438 ncpile* p0 = p;
1439 do{
1440 ncpile_drop(nc, &p);
1441 }while(p0 != p);
1442 pthread_mutex_unlock(&nc->pilelock);
1443 logdebug("all planes dropped");
1444}
Here is the caller graph for this function:

◆ notcurses_enter_alternate_screen()

API int notcurses_enter_alternate_screen ( struct notcurses nc)

Definition at line 31 of file notcurses.c.

31 {
32 if(nc->tcache.ttyfd < 0){
33 return -1;
34 }
36 return -1;
37 }
39 return 0;
40}
int enter_alternate_screen(int fd, FILE *ttyfp, tinfo *ti, unsigned drain)
Definition termdesc.c:559
Here is the call graph for this function:

◆ notcurses_get()

API uint32_t notcurses_get ( struct notcurses n,
const struct timespec *  ts,
ncinput ni 
)

Definition at line 2751 of file in.c.

2751 {
2752 uint32_t ret = internal_get(nc->tcache.ictx, absdl, ni);
2753 return ret;
2754}
Here is the caller graph for this function:

◆ notcurses_getvec()

API int notcurses_getvec ( struct notcurses n,
const struct timespec *  ts,
ncinput ni,
int  vcount 
)

◆ notcurses_hostname()

API ALLOC char * notcurses_hostname ( void  )

Definition at line 62 of file util.c.

62 {
63#ifndef __MINGW32__
64 char hostname[_POSIX_HOST_NAME_MAX + 1];
65 if(gethostname(hostname, sizeof(hostname)) == 0){
66 char* fqdn = strchr(hostname, '.');
67 if(fqdn){
68 *fqdn = '\0';
69 }
70 return strdup(hostname);
71 }
72#else // windows
73 char lp[MAX_COMPUTERNAME_LENGTH + 1];
74 DWORD s = sizeof(lp);
75 if(GetComputerNameA(lp, &s)){
76 return strdup(lp);
77 }
78#endif
79 return NULL;
80}

◆ notcurses_init()

API ALLOC struct notcurses * notcurses_init ( const notcurses_options opts,
FILE *  fp 
)

◆ notcurses_inputready_fd()

API int API int notcurses_inputready_fd ( struct notcurses n)

Definition at line 3091 of file notcurses.c.

3091 {
3092 return inputready_fd(n->tcache.ictx);
3093}
int inputready_fd(const inputctx *ictx)
Definition in.c:2661
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notcurses_leave_alternate_screen()

API int notcurses_leave_alternate_screen ( struct notcurses nc)

Definition at line 42 of file notcurses.c.

42 {
43 if(nc->tcache.ttyfd < 0){
44 return -1;
45 }
47 &nc->tcache, nc->flags & NCOPTION_DRAIN_INPUT)){
48 return -1;
49 }
50 // move to the end of our output
51 if(nc->rstate.logendy < 0){
52 return 0;
53 }
55 return 0;
56}
int leave_alternate_screen(int fd, FILE *fp, tinfo *ti, unsigned drain)
Definition termdesc.c:611
Here is the call graph for this function:

◆ notcurses_lex_blitter()

API int notcurses_lex_blitter ( const char *  op,
ncblitter_e blitter 
)

Definition at line 1378 of file blit.c.

1378 {
1379 const struct blitset* bset = notcurses_blitters;
1380 while(bset->name){
1381 if(strcasecmp(bset->name, op) == 0){
1382 *blitfxn = bset->geom;
1383 return 0;
1384 }
1385 ++bset;
1386 }
1387 if(strcasecmp("default", op) == 0){
1388 *blitfxn = NCBLIT_DEFAULT;
1389 return 0;
1390 }
1391 return -1;
1392}
const char * name
Definition internal.h:411
Here is the caller graph for this function:

◆ notcurses_lex_margins()

API int notcurses_lex_margins ( const char *  op,
notcurses_options opts 
)

Definition at line 3067 of file notcurses.c.

3067 {
3068 char* eptr;
3069 if(lex_ulong(op, &opts->margin_t, &eptr)){
3070 return -1;
3071 }
3072 if(!*eptr){ // allow a single value to be specified for all four margins
3073 opts->margin_r = opts->margin_l = opts->margin_b = opts->margin_t;
3074 return 0;
3075 }
3076 op = ++eptr; // once here, we require four values
3077 if(lex_ulong(op, &opts->margin_r, &eptr) || !*eptr){
3078 return -1;
3079 }
3080 op = ++eptr;
3081 if(lex_ulong(op, &opts->margin_b, &eptr) || !*eptr){
3082 return -1;
3083 }
3084 op = ++eptr;
3085 if(lex_ulong(op, &opts->margin_l, &eptr) || *eptr){ // must end in NUL
3086 return -1;
3087 }
3088 return 0;
3089}
unsigned margin_r
Definition notcurses.h:1473
unsigned margin_b
Definition notcurses.h:1473
Here is the caller graph for this function:

◆ notcurses_lex_scalemode()

API int notcurses_lex_scalemode ( const char *  op,
ncscale_e scalemode 
)

Definition at line 3035 of file notcurses.c.

3035 {
3036 if(strcasecmp(op, "stretch") == 0){
3037 *scalemode = NCSCALE_STRETCH;
3038 }else if(strcasecmp(op, "scalehi") == 0){
3039 *scalemode = NCSCALE_SCALE_HIRES;
3040 }else if(strcasecmp(op, "hires") == 0){
3041 *scalemode = NCSCALE_NONE_HIRES;
3042 }else if(strcasecmp(op, "scale") == 0){
3043 *scalemode = NCSCALE_SCALE;
3044 }else if(strcasecmp(op, "none") == 0){
3045 *scalemode = NCSCALE_NONE;
3046 }else{
3047 return -1;
3048 }
3049 return 0;
3050}
Here is the caller graph for this function:

◆ notcurses_linesigs_disable()

API int notcurses_linesigs_disable ( struct notcurses n)

Definition at line 2850 of file in.c.

2850 {
2851 return linesigs_disable(&nc->tcache);
2852}
Here is the caller graph for this function:

◆ notcurses_linesigs_enable()

API int notcurses_linesigs_enable ( struct notcurses n)

Definition at line 2892 of file in.c.

2892 {
2893 return linesigs_enable(&n->tcache);
2894}
Here is the caller graph for this function:

◆ notcurses_mice_enable()

API int notcurses_mice_enable ( struct notcurses n,
unsigned  eventmask 
)

Definition at line 2556 of file notcurses.c.

2556 {
2557 if(mouse_setup(&n->tcache, eventmask)){
2558 return -1;
2559 }
2560 return 0;
2561}
int mouse_setup(tinfo *ti, unsigned eventmask)
Definition mice.c:3
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notcurses_osversion()

API ALLOC char * notcurses_osversion ( void  )

Definition at line 82 of file util.c.

82 {
83#ifdef __MINGW32__
84 // FIXME get version
85 return strdup("Microsoft Windows");
86#else
87#ifdef __APPLE__
88#define PREFIX "macOS "
89 char osver[30] = PREFIX; // shrug
90 size_t oldlenp = sizeof(osver) - strlen(PREFIX);
91 if(sysctlbyname("kern.osproductversion", osver + strlen(PREFIX),
92 &oldlenp, NULL, 0) == 0){
93 return strdup(osver);
94 }
95 return strdup("macOS");
96#else
97 struct utsname uts;
98 if(uname(&uts)){
99 logerror("failure invoking uname (%s)", strerror(errno));
100 return NULL;
101 }
102 const size_t nlen = strlen(uts.sysname);
103 const size_t rlen = strlen(uts.release);
104 size_t tlen = nlen + rlen + 2;
105 char* ret = malloc(tlen);
106 memcpy(ret, uts.sysname, nlen);
107 ret[nlen] = ' ';
108 strcpy(ret + nlen + 1, uts.release);
109 return ret;
110#endif
111#undef PREFIX
112#endif
113}
Here is the caller graph for this function:

◆ notcurses_palette_size()

API unsigned notcurses_palette_size ( const struct notcurses nc)

◆ notcurses_refresh()

API int notcurses_refresh ( struct notcurses n,
unsigned *RESTRICT  y,
unsigned *RESTRICT  x 
)

◆ notcurses_stats()

API void notcurses_stats ( struct notcurses nc,
ncstats stats 
)

◆ notcurses_stats_alloc()

API ALLOC ncstats * notcurses_stats_alloc ( const struct notcurses *nc   __attribute__(unused))

◆ notcurses_stats_reset()

API void API void notcurses_stats_reset ( struct notcurses nc,
ncstats stats 
)

Definition at line 100 of file stats.c.

100 {
101 pthread_mutex_lock(&nc->stats.lock);
102 if(stats){
103 memcpy(stats, &nc->stats.s, sizeof(*stats));
104 }
105 // add the stats to the stashed stats, so that we can show true totals on
106 // shutdown in the closing banner
107 ncstats* stash = &nc->stashed_stats;
108 if(nc->stats.s.render_min_ns < stash->render_min_ns){
109 stash->render_min_ns = nc->stats.s.render_min_ns;
110 }
111 if(nc->stats.s.raster_min_bytes < stash->raster_min_bytes){
113 }
114 if(nc->stats.s.raster_min_ns < stash->raster_min_ns){
115 stash->raster_min_ns = nc->stats.s.raster_min_ns;
116 }
117 if(nc->stats.s.writeout_min_ns < stash->writeout_min_ns){
119 }
120 if(nc->stats.s.render_max_ns > stash->render_max_ns){
121 stash->render_max_ns = nc->stats.s.render_max_ns;
122 }
123 if(nc->stats.s.raster_max_bytes > stash->raster_max_bytes){
125 }
126 if(nc->stats.s.raster_max_ns > stash->raster_max_ns){
127 stash->raster_max_ns = nc->stats.s.raster_max_ns;
128 }
129 if(nc->stats.s.writeout_max_ns > stash->writeout_max_ns){
131 }
132 stash->writeout_ns += nc->stats.s.writeout_ns;
133 stash->raster_ns += nc->stats.s.raster_ns;
134 stash->render_ns += nc->stats.s.render_ns;
135 stash->raster_bytes += nc->stats.s.raster_bytes;
136 stash->failed_renders += nc->stats.s.failed_renders;
138 stash->renders += nc->stats.s.renders;
139 stash->writeouts += nc->stats.s.writeouts;
140 stash->cellelisions += nc->stats.s.cellelisions;
141 stash->cellemissions += nc->stats.s.cellemissions;
142 stash->fgelisions += nc->stats.s.fgelisions;
143 stash->fgemissions += nc->stats.s.fgemissions;
144 stash->bgelisions += nc->stats.s.bgelisions;
145 stash->bgemissions += nc->stats.s.bgemissions;
148 stash->refreshes += nc->stats.s.refreshes;
151 stash->sprixelbytes += nc->stats.s.sprixelbytes;
153 stash->input_errors += nc->stats.s.input_errors;
154 stash->input_events += nc->stats.s.input_events;
155 stash->hpa_gratuitous += nc->stats.s.hpa_gratuitous;
158
159 stash->fbbytes = nc->stats.s.fbbytes;
160 stash->planes = nc->stats.s.planes;
161 reset_stats(&nc->stats.s);
162 pthread_mutex_unlock(&nc->stats.lock);
163}
void reset_stats(ncstats *stats)
Definition stats.c:74
uint64_t failed_writeouts
Definition notcurses.h:1786
uint64_t raster_ns
Definition notcurses.h:1793
uint64_t cellemissions
Definition notcurses.h:1800
int64_t render_min_ns
Definition notcurses.h:1792
uint64_t failed_renders
Definition notcurses.h:1785
uint64_t refreshes
Definition notcurses.h:1807
uint64_t defaultelisions
Definition notcurses.h:1805
uint64_t appsync_updates
Definition notcurses.h:1811
uint64_t cell_geo_changes
Definition notcurses.h:1815
uint64_t cellelisions
Definition notcurses.h:1799
uint64_t bgemissions
Definition notcurses.h:1804
uint64_t fgemissions
Definition notcurses.h:1802
uint64_t hpa_gratuitous
Definition notcurses.h:1814
int64_t writeout_min_ns
Definition notcurses.h:1798
uint64_t defaultemissions
Definition notcurses.h:1806
uint64_t sprixelemissions
Definition notcurses.h:1808
uint64_t writeout_ns
Definition notcurses.h:1796
uint64_t sprixelelisions
Definition notcurses.h:1809
uint64_t render_ns
Definition notcurses.h:1790
uint64_t renders
Definition notcurses.h:1783
uint64_t input_errors
Definition notcurses.h:1812
uint64_t raster_bytes
Definition notcurses.h:1787
int64_t raster_min_ns
Definition notcurses.h:1795
uint64_t pixel_geo_changes
Definition notcurses.h:1816
int64_t raster_max_bytes
Definition notcurses.h:1788
uint64_t fgelisions
Definition notcurses.h:1801
int64_t render_max_ns
Definition notcurses.h:1791
uint64_t input_events
Definition notcurses.h:1813
uint64_t bgelisions
Definition notcurses.h:1803
uint64_t sprixelbytes
Definition notcurses.h:1810
unsigned planes
Definition notcurses.h:1820
int64_t writeout_max_ns
Definition notcurses.h:1797
uint64_t writeouts
Definition notcurses.h:1784
uint64_t fbbytes
Definition notcurses.h:1819
int64_t raster_max_ns
Definition notcurses.h:1794
int64_t raster_min_bytes
Definition notcurses.h:1789
ncstats stashed_stats
Definition internal.h:357
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notcurses_stdplane()

API struct ncplane * notcurses_stdplane ( struct notcurses nc)

Definition at line 699 of file notcurses.c.

699 {
700 return nc->stdplane;
701}
Here is the caller graph for this function:

◆ notcurses_stdplane_const()

API const struct ncplane * notcurses_stdplane_const ( const struct notcurses nc)

◆ notcurses_stop()

API int notcurses_stop ( struct notcurses nc)

Definition at line 1446 of file notcurses.c.

1446 {
1447 logdebug("stopping notcurses");
1448//notcurses_debug(nc, stderr);
1449 int ret = 0;
1450 if(nc){
1451 void* altstack;
1452 ret |= notcurses_stop_minimal(nc, &altstack);
1453 // if we were not using the alternate screen, our cursor's wherever we last
1454 // wrote. move it to the furthest place to which it advanced.
1455 if(!get_escape(&nc->tcache, ESCAPE_SMCUP)){
1456 fbuf_reset(&nc->rstate.f);
1457//fprintf(stderr, "CLOSING TO %d/%d\n", nc->rstate.logendy, nc->rstate.logendx);
1458 goto_location(nc, &nc->rstate.f, nc->rstate.logendy, nc->rstate.logendx, NULL);
1459//fprintf(stderr, "***"); fflush(stderr);
1460 fbuf_finalize(&nc->rstate.f, stdout);
1461 }
1462 if(nc->stdplane){
1464 free_plane(nc->stdplane);
1465 }
1466 if(nc->tcache.ttyfd >= 0){
1467 ret |= close(nc->tcache.ttyfd);
1468 }
1469 egcpool_dump(&nc->pool);
1470 free(nc->lastframe);
1471 // perhaps surprisingly, this stops the input thread
1473 // get any current stats loaded into stash_stats
1475 if(!(nc->flags & NCOPTION_SUPPRESS_BANNERS)){
1476 summarize_stats(nc);
1477 }
1478#ifndef __MINGW32__
1479 del_curterm(cur_term);
1480#endif
1481 ret |= pthread_mutex_destroy(&nc->stats.lock);
1482 ret |= pthread_mutex_destroy(&nc->pilelock);
1483 fbuf_free(&nc->rstate.f);
1484 free(nc);
1485 free(altstack);
1486 }
1487 return ret;
1488}
void summarize_stats(notcurses *nc)
Definition stats.c:166
void notcurses_drop_planes(notcurses *nc)
Definition notcurses.c:1434
void notcurses_stats_reset(notcurses *nc, ncstats *stats)
Definition stats.c:100
void free_terminfo_cache(tinfo *ti)
Definition termdesc.c:197
@ ESCAPE_SMCUP
Definition termdesc.h:68
Here is the call graph for this function:

◆ notcurses_str_blitter()

API const char * notcurses_str_blitter ( ncblitter_e  blitter)

Definition at line 1394 of file blit.c.

1394 {
1395 if(blitfxn == NCBLIT_DEFAULT){
1396 return "default";
1397 }
1398 const struct blitset* bset = notcurses_blitters;
1399 while(bset->name){
1400 if(bset->geom == blitfxn){
1401 return bset->name;
1402 }
1403 ++bset;
1404 }
1405 return NULL;
1406}
Here is the caller graph for this function:

◆ notcurses_str_scalemode()

API const char * notcurses_str_scalemode ( ncscale_e  scalemode)

Definition at line 3052 of file notcurses.c.

3052 {
3053 if(scalemode == NCSCALE_STRETCH){
3054 return "stretch";
3055 }else if(scalemode == NCSCALE_SCALE){
3056 return "scale";
3057 }else if(scalemode == NCSCALE_NONE){
3058 return "none";
3059 }else if(scalemode == NCSCALE_NONE_HIRES){
3060 return "hires";
3061 }else if(scalemode == NCSCALE_SCALE_HIRES){
3062 return "scalehi";
3063 }
3064 return NULL;
3065}
Here is the caller graph for this function:

◆ notcurses_supported_styles()

API uint16_t notcurses_supported_styles ( const struct notcurses nc)

◆ notcurses_ucs32_to_utf8()

API int notcurses_ucs32_to_utf8 ( const uint32_t *  ucs32,
unsigned  ucs32count,
unsigned char *  resultbuf,
size_t  buflen 
)

◆ notcurses_version()

API const char * notcurses_version ( void  )

Definition at line 182 of file notcurses.c.

182 {
183 return NOTCURSES_VERSION;
184}
Here is the caller graph for this function:

◆ notcurses_version_components()

API void notcurses_version_components ( int *  major,
int *  minor,
int *  patch,
int *  tweak 
)

Definition at line 24 of file notcurses.c.

24 {
25 *major = NOTCURSES_VERNUM_MAJOR;
26 *minor = NOTCURSES_VERNUM_MINOR;
27 *patch = NOTCURSES_VERNUM_PATCH;
28 *tweak = atoi(NOTCURSES_VERSION_TWEAK);
29}
Here is the caller graph for this function:

Variable Documentation

◆ c

API int const nccell* c

Definition at line 861 of file notcurses.h.

◆ else

else
Initial value:
{
API ALLOC struct ncplane API ALLOC struct ncplane * ncpile_create(struct notcurses *nc, const ncplane_options *nopts) __attribute__((nonnull(1

Definition at line 3491 of file notcurses.h.

◆ len

API int const nccell unsigned len
Initial value:
{
API int API int ncplane_hline_interp(struct ncplane *n, const nccell *c, unsigned len, uint64_t c1, uint64_t c2) __attribute__((nonnull(1
API int API int const nccell unsigned len
Definition notcurses.h:2588

Definition at line 2588 of file notcurses.h.

◆ n

vopts n = newn

Definition at line 3502 of file notcurses.h.

◆ ncplane_resizecb

API int(*)(struct ncplane *) ncplane_resizecb(const struct ncplane *n) ( const struct ncplane n)

Definition at line 1513 of file notcurses.h.

◆ ncv

const struct ncplane_options struct ncvisual* ncv

Definition at line 3484 of file notcurses.h.

◆ newn

return newn

Definition at line 3508 of file notcurses.h.

◆ opts

const struct ncplane_options* opts

Definition at line 3483 of file notcurses.h.

◆ v

struct ncvisual_options v

Definition at line 3497 of file notcurses.h.

◆ vopts

const struct ncplane_options struct ncvisual struct ncvisual_options* vopts
Initial value:
{
struct ncplane* newn

Definition at line 3484 of file notcurses.h.

◆ x

int int x
Initial value:
{
int oy, ox

Definition at line 1905 of file notcurses.h.

◆ y

int y

Definition at line 1905 of file notcurses.h.