Notcurses 3.0.16
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 int ncplane_family_destroy (struct ncplane *n)
 
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 2613 of file notcurses.h.

◆ NCBOXCORNER_SHIFT

#define NCBOXCORNER_SHIFT   8u

Definition at line 2614 of file notcurses.h.

◆ NCBOXGRAD_BOTTOM

#define NCBOXGRAD_BOTTOM   0x0040

Definition at line 2611 of file notcurses.h.

◆ NCBOXGRAD_LEFT

#define NCBOXGRAD_LEFT   0x0080

Definition at line 2612 of file notcurses.h.

◆ NCBOXGRAD_RIGHT

#define NCBOXGRAD_RIGHT   0x0020

Definition at line 2610 of file notcurses.h.

◆ NCBOXGRAD_TOP

#define NCBOXGRAD_TOP   0x0010

Definition at line 2609 of file notcurses.h.

◆ NCBOXMASK_BOTTOM

#define NCBOXMASK_BOTTOM   0x0004

Definition at line 2607 of file notcurses.h.

◆ NCBOXMASK_LEFT

#define NCBOXMASK_LEFT   0x0008

Definition at line 2608 of file notcurses.h.

◆ NCBOXMASK_RIGHT

#define NCBOXMASK_RIGHT   0x0002

Definition at line 2606 of file notcurses.h.

◆ NCBOXMASK_TOP

#define NCBOXMASK_TOP   0x0001

Definition at line 2605 of file notcurses.h.

◆ NCBPREFIXCOLUMNS

#define NCBPREFIXCOLUMNS   9

Definition at line 3831 of file notcurses.h.

◆ NCBPREFIXFMT

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

Definition at line 3841 of file notcurses.h.

◆ NCBPREFIXSTRLEN

#define NCBPREFIXSTRLEN   (NCBPREFIXCOLUMNS + 1)

Definition at line 3834 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 3830 of file notcurses.h.

◆ NCIPREFIXFMT

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

Definition at line 3840 of file notcurses.h.

◆ NCIPREFIXSTRLEN

#define NCIPREFIXSTRLEN   (NCIPREFIXCOLUMNS + 1)

Definition at line 3833 of file notcurses.h.

◆ NCMENU_OPTION_BOTTOM

#define NCMENU_OPTION_BOTTOM   0x0001ull

Definition at line 4131 of file notcurses.h.

◆ NCMENU_OPTION_HIDING

#define NCMENU_OPTION_HIDING   0x0002ull

Definition at line 4132 of file notcurses.h.

◆ NCMETRICFWIDTH

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

Definition at line 3837 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 4488 of file notcurses.h.

◆ NCPLOT_OPTION_EXPONENTIALD

#define NCPLOT_OPTION_EXPONENTIALD   0x0002u

Definition at line 4485 of file notcurses.h.

◆ NCPLOT_OPTION_LABELTICKSD

#define NCPLOT_OPTION_LABELTICKSD   0x0001u

Definition at line 4484 of file notcurses.h.

◆ NCPLOT_OPTION_NODEGRADE

#define NCPLOT_OPTION_NODEGRADE   0x0008u

Definition at line 4487 of file notcurses.h.

◆ NCPLOT_OPTION_PRINTSAMPLE

#define NCPLOT_OPTION_PRINTSAMPLE   0x0020u

Definition at line 4489 of file notcurses.h.

◆ NCPLOT_OPTION_VERTICALI

#define NCPLOT_OPTION_VERTICALI   0x0004u

Definition at line 4486 of file notcurses.h.

◆ NCPREFIXCOLUMNS

#define NCPREFIXCOLUMNS   7

Definition at line 3829 of file notcurses.h.

◆ NCPREFIXFMT

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

Definition at line 3839 of file notcurses.h.

◆ NCPREFIXSTRLEN

#define NCPREFIXSTRLEN   (NCPREFIXCOLUMNS + 1)

Definition at line 3832 of file notcurses.h.

◆ NCPROGBAR_OPTION_RETROGRADE

#define NCPROGBAR_OPTION_RETROGRADE   0x0001u

Definition at line 4207 of file notcurses.h.

◆ NCREADER_OPTION_CURSOR

#define NCREADER_OPTION_CURSOR   0x0008ull

Definition at line 4622 of file notcurses.h.

◆ NCREADER_OPTION_HORSCROLL

#define NCREADER_OPTION_HORSCROLL   0x0001ull

Definition at line 4615 of file notcurses.h.

◆ NCREADER_OPTION_NOCMDKEYS

#define NCREADER_OPTION_NOCMDKEYS   0x0004ull

Definition at line 4619 of file notcurses.h.

◆ NCREADER_OPTION_VERSCROLL

#define NCREADER_OPTION_VERSCROLL   0x0002ull

Definition at line 4617 of file notcurses.h.

◆ NCREEL_OPTION_CIRCULAR

#define NCREEL_OPTION_CIRCULAR   0x0002ull

Definition at line 3702 of file notcurses.h.

◆ NCREEL_OPTION_INFINITESCROLL

#define NCREEL_OPTION_INFINITESCROLL   0x0001ull

Definition at line 3698 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 4241 of file notcurses.h.

◆ NCVISUAL_OPTION_ADDALPHA

#define NCVISUAL_OPTION_ADDALPHA   0x0010ull

Definition at line 3345 of file notcurses.h.

◆ NCVISUAL_OPTION_BLEND

#define NCVISUAL_OPTION_BLEND   0x0002ull

Definition at line 3342 of file notcurses.h.

◆ NCVISUAL_OPTION_CHILDPLANE

#define NCVISUAL_OPTION_CHILDPLANE   0x0020ull

Definition at line 3346 of file notcurses.h.

◆ NCVISUAL_OPTION_HORALIGNED

#define NCVISUAL_OPTION_HORALIGNED   0x0004ull

Definition at line 3343 of file notcurses.h.

◆ NCVISUAL_OPTION_NODEGRADE

#define NCVISUAL_OPTION_NODEGRADE   0x0001ull

Definition at line 3341 of file notcurses.h.

◆ NCVISUAL_OPTION_NOINTERPOLATE

#define NCVISUAL_OPTION_NOINTERPOLATE   0x0040ull

Definition at line 3347 of file notcurses.h.

◆ NCVISUAL_OPTION_VERALIGNED

#define NCVISUAL_OPTION_VERALIGNED   0x0008ull

Definition at line 3344 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 3033 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 4550 of file notcurses.h.

◆ ncfdplane_done_cb

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

Definition at line 4551 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 3537 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 4254 of file notcurses.h.

◆ tabletcb

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

Definition at line 3732 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:2561
vopts n
Definition notcurses.h:3506
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 3502 of file notcurses.h.

3502 {
3503 vopts = &v;
3504 memset(vopts, 0, sizeof(*vopts));
3505 }
const struct ncplane_options struct ncvisual struct ncvisual_options * vopts
Definition notcurses.h:3488
struct ncvisual_options v
Definition notcurses.h:3501

◆ if() [2/4]

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

Definition at line 3507 of file notcurses.h.

3507 {
3509 vopts->n = NULL;
3510 return NULL;
3511 }
return newn
Definition notcurses.h:3512
API int ncplane_destroy(struct ncplane *n)
Definition notcurses.c:1021
return NULL
Definition termdesc.h:229
Here is the call graph for this function:

◆ if() [3/4]

if ( newn  = NULL)

Definition at line 3498 of file notcurses.h.

3498 {
3499 return NULL;
3500 }

◆ if() [4/4]

if ( vopts &&vopts->  n)

Definition at line 3490 of file notcurses.h.

3490 {
3492 return NULL; // the whole point is to create a new plane
3493 }
3495 }else{
#define NCVISUAL_OPTION_CHILDPLANE
Definition notcurses.h:3346
API ALLOC struct ncplane * ncplane_create(struct ncplane *n, const ncplane_options *nopts) __attribute__((nonnull(1
const struct ncplane_options * opts
Definition notcurses.h:3487
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
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:508
#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:486
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:2631
const struct ncplane_options struct ncvisual * ncv
Definition notcurses.h:3488
uint32_t * data
ncvisual * ncvisual_from_rgba(const void *rgba, int rows, int rowstride, int cols)
Definition visual.c:779
void ncvisual_destroy(ncvisual *ncv)
Definition visual.c:1231
ncplane * ncvisual_blit(notcurses *nc, ncvisual *ncv, const struct ncvisual_options *vopts)
Definition visual.c:1142
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:207
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 1836 of file notcurses.c.

1836 {
1837 int cols;
1838 int bytes = utf8_egc_len(gcluster, &cols);
1839 return pool_load_direct(&n->pool, c, gcluster, bytes, cols);
1840}
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:1021
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 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 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:710
int ncplane_set_base_cell(ncplane *ncp, const nccell *c)
Definition notcurses.c:1561
void ncplane_dim_yx(const ncplane *n, unsigned *rows, unsigned *cols)
Definition notcurses.c:304
#define NCMENU_OPTION_HIDING
Definition notcurses.h:4132
#define NCALPHA_TRANSPARENT
Definition notcurses.h:106
#define NCMENU_OPTION_BOTTOM
Definition notcurses.h:4131
#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:2464
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:723
void ncplane_set_channels(ncplane *n, uint64_t channels)
Definition notcurses.c:1497
void ncplane_set_styles(ncplane *n, unsigned stylebits)
Definition notcurses.c:2077
int ncplane_putegc_yx(ncplane *n, int y, int x, const char *gclust, size_t *sbytes)
Definition notcurses.c:2001
int ncplane_at_yx_cell(ncplane *n, int y, int x, nccell *c)
Definition notcurses.c:273
uint64_t ncplane_channels(const ncplane *n)
Definition notcurses.c:1493
int ncplane_putc_yx(ncplane *n, int y, int x, const nccell *c)
Definition notcurses.c:1986
#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:702
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
Definition notcurses.c:3311
void ncmultiselector_destroy(ncmultiselector *n)
Definition selector.c:985
char * option
Definition selector.c:12
const char * option
Definition notcurses.h:3972
const char * desc
Definition notcurses.h:3973
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 2591 of file notcurses.c.

2591 {
2592 free(p);
2593}
Here is the caller graph for this function:

◆ ncpalette_new()

API ALLOC ncpalette * ncpalette_new ( struct notcurses nc)

Definition at line 2568 of file notcurses.c.

2568 {
2569 ncpalette* p = malloc(sizeof(*p));
2570 if(p){
2571 memcpy(p, &nc->palette, sizeof(*p));
2572 }
2573 return p;
2574}
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 2549 of file notcurses.c.

2549 {
2550 return ncplane_pile(n)->bottom;
2551}
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:2635
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 2545 of file notcurses.c.

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

◆ ncplane_above()

API struct ncplane * ncplane_above ( struct ncplane n)

Definition at line 2557 of file notcurses.c.

2557 {
2558 return n->above;
2559}
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 1572 of file notcurses.c.

1572 {
1573 return nccell_duplicate(ncp, c, &ncp->basecell);
1574}
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 2553 of file notcurses.c.

2553 {
2554 return n->below;
2555}
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 2277 of file notcurses.c.

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

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

753 {
754 if((int)n->y + y == -1){
755 logerror("invalid target y -1");
756 return -1;
757 }else if((int)n->x + x == -1){
758 logerror("invalid target x -1");
759 return -1;
760 }else return ncplane_cursor_move_yx(n, n->y + y, n->x + x);
761}
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 723 of file notcurses.c.

723 {
724 if(x < 0){
725 if(x < -1){
726 logerror("negative target x %d", x);
727 return -1;
728 }
729 }else if((unsigned)x >= n->lenx){
730 logerror("target x %d >= width %u", x, n->lenx);
731 return -1;
732 }else{
733 n->x = x;
734 }
735 if(y < 0){
736 if(y < -1){
737 logerror("negative target y %d", y);
738 return -1;
739 }
740 }else if((unsigned)y >= n->leny){
741 logerror("target y %d >= height %u", y, n->leny);
742 return -1;
743 }else{
744 n->y = y;
745 }
746 if(cursor_invalid_p(n)){
747 logerror("invalid cursor following move (%d/%d)", n->y, n->x);
748 return -1;
749 }
750 return 0;
751}
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 1021 of file notcurses.c.

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

2464 {
2465 loginfo("erasing %dx%d plane", n->leny, n->lenx);
2466 if(n->sprite){
2467 sprixel_hide(n->sprite);
2468 destroy_tam(n);
2469 }
2470 // we must preserve the background, but a pure nccell_duplicate() would be
2471 // wiped out by the egcpool_dump(). do a duplication (to get the stylemask
2472 // and channels), and then reload.
2473 char* egc = nccell_strdup(n, &n->basecell);
2474 memset(n->fb, 0, sizeof(*n->fb) * n->leny * n->lenx);
2475 egcpool_dump(&n->pool);
2476 // we need to zero out the EGC before handing this off to nccell_load, but
2477 // we don't want to lose the channels/attributes, so explicit gcluster load.
2478 n->basecell.gcluster = 0;
2479 nccell_load(n, &n->basecell, egc);
2480 free(egc);
2481 n->y = n->x = 0;
2482}
const char * egc
Definition egcpool.h:162
void sprixel_hide(sprixel *s)
Definition sprite.c:83
int nccell_load(ncplane *n, nccell *c, const char *gcluster)
Definition notcurses.c:1836
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 2484 of file notcurses.c.

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

API int ncplane_family_destroy ( struct ncplane n)

Definition at line 1071 of file notcurses.c.

1071 {
1072 if(ncp == NULL){
1073 return 0;
1074 }
1075 if(ncplane_notcurses(ncp)->stdplane == ncp){
1076 logerror("won't destroy standard plane");
1077 return -1;
1078 }
1079 int ret = 0;
1080 while(ncp->blist){
1081 ret |= ncplane_family_destroy(ncp->blist);
1082 }
1083 ret |= ncplane_destroy(ncp);
1084 return ret;
1085}
int ncplane_family_destroy(ncplane *ncp)
Definition notcurses.c:1071
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 718 of file notcurses.c.

718 {
719 n->x = 0;
720 n->y = 0;
721}
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 2417 of file notcurses.c.

2417 {
2418 if(n == ncplane_notcurses(n)->stdplane){
2419 return -1;
2420 }
2421 int dy, dx; // amount moved
2422 if(n->boundto == n){
2423 dy = y - n->absy;
2424 dx = x - n->absx;
2425 }else{
2426 dy = (n->boundto->absy + y) - n->absy;
2427 dx = (n->boundto->absx + x) - n->absx;
2428 }
2429 if(dy || dx){ // don't want to trigger sprixel_movefrom() if unneeded
2430 if(n->sprite){
2431 sprixel_movefrom(n->sprite, n->absy, n->absx);
2432 }
2433 n->absx += dx;
2434 n->absy += dy;
2435 move_bound_planes(n->blist, dy, dx);
2436 }
2437 return 0;
2438}
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 2087 of file notcurses.c.

2087 {
2088 n->stylemask &= ~(stylebits & NCSTYLE_MASK);
2089}
#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 2082 of file notcurses.c.

2082 {
2083 n->stylemask |= (stylebits & NCSTYLE_MASK);
2084}
Here is the caller graph for this function:

◆ ncplane_parent()

API struct ncplane * ncplane_parent ( struct ncplane n)

Definition at line 2656 of file notcurses.c.

2656 {
2657 return n->boundto;
2658}
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 2014 of file notcurses.c.

2014 {
2015 uint64_t channels = n->channels;
2016 uint16_t stylemask = n->stylemask;
2017 const nccell* targ = &n->fb[nfbcellidx(n, n->y, n->x)];
2018 n->channels = targ->channels;
2019 n->stylemask = targ->stylemask;
2020 int ret = ncplane_putchar(n, c);
2021 n->channels = channels;
2022 n->stylemask = stylemask;
2023 return ret;
2024}
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 1009 of file notcurses.c.

1012 {
1013 if(n == ncplane_notcurses(n)->stdplane){
1014//fprintf(stderr, "Can't resize standard plane\n");
1015 return -1;
1016 }
1017 return ncplane_resize_internal(n, keepy, keepx, keepleny, keeplenx,
1018 yoff, xoff, ylen, xlen);
1019}
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:857
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 2728 of file notcurses.c.

2728 {
2729 const ncplane* parent = ncplane_parent_const(n);
2730 // a marginalized plane cannot be larger than its oppressor plane =]
2731 unsigned maxy, maxx;
2732 if(parent == n){ // root plane, need to use pile size
2733 ncpile* p = ncplane_pile(n);
2734 maxy = p->dimy;
2735 maxx = p->dimx;
2736 }else{
2737 ncplane_dim_yx(parent, &maxy, &maxx);
2738 }
2739 if((maxy -= (n->margin_b + (n->absy - n->boundto->absy))) < 1){
2740 maxy = 1;
2741 }
2742 if((maxx -= (n->margin_r + (n->absx - n->boundto->absx))) < 1){
2743 maxx = 1;
2744 }
2745 unsigned oldy, oldx;
2746 ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
2747 unsigned keepleny = oldy > maxy ? maxy : oldy;
2748 unsigned keeplenx = oldx > maxx ? maxx : oldx;
2749 if(ncplane_resize_internal(n, 0, 0, keepleny, keeplenx, 0, 0, maxy, maxx)){
2750 return -1;
2751 }
2752 int targy = maxy - n->margin_b;
2753 int targx = maxx - n->margin_b;
2754 loginfo("marg %d/%d, pdim %d/%d, move %d/%d", n->margin_b, n->margin_r, maxy, maxx, targy, targx);
2755 return ncplane_move_yx(n, targy, targx);
2756}
int ncplane_move_yx(ncplane *n, int y, int x)
Definition notcurses.c:2417
const ncplane * ncplane_parent_const(const ncplane *n)
Definition notcurses.c:2660
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 2758 of file notcurses.c.

2758 {
2759 const ncpile* pile = ncplane_pile(n); // FIXME should be taken against parent
2760 const unsigned rows = pile->dimy;
2761 const unsigned cols = pile->dimx;
2762 unsigned oldy, oldx;
2763 ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
2764 unsigned keepleny = oldy > rows ? rows : oldy;
2765 unsigned keeplenx = oldx > cols ? cols : oldx;
2766 return ncplane_resize_internal(n, 0, 0, keepleny, keeplenx, 0, 0, rows, cols);
2767}
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 2686 of file notcurses.c.

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

◆ ncplane_resize_realign()

API int ncplane_resize_realign ( struct ncplane n)

Definition at line 2769 of file notcurses.c.

2769 {
2770 const ncplane* parent = ncplane_parent_const(n);
2771 if(parent == n){
2772 logerror("can't realign a root plane");
2773 return 0;
2774 }
2775 if(n->halign == NCALIGN_UNALIGNED && n->valign == NCALIGN_UNALIGNED){
2776 logerror("passed a non-aligned plane");
2777 return -1;
2778 }
2779 int xpos = ncplane_x(n);
2780 if(n->halign != NCALIGN_UNALIGNED){
2781 xpos = ncplane_halign(parent, n->halign, ncplane_dim_x(n));
2782 }
2783 int ypos = ncplane_y(n);
2784 if(n->valign != NCALIGN_UNALIGNED){
2785 ypos = ncplane_valign(parent, n->valign, ncplane_dim_y(n));
2786 }
2787 return ncplane_move_yx(n, ypos, xpos);
2788}
int ncplane_x(const ncplane *n)
Definition notcurses.c:2447
int ncplane_y(const ncplane *n)
Definition notcurses.c:2440
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:3270
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 1795 of file notcurses.c.

1795 {
1796 if(!ncplane_scrolling_p(n)){
1797 logerror("can't scroll %d on non-scrolling plane", r);
1798 return -1;
1799 }
1800 if(r < 0){
1801 logerror("can't scroll %d lines", r);
1802 return -1;
1803 }
1804 while(r-- > 0){
1805 scroll_down(n);
1806 }
1808 notcurses_render(ncplane_notcurses(n));
1809 }
1810 return 0;
1811}
bool ncplane_scrolling_p(const ncplane *n)
Definition notcurses.c:3004
void scroll_down(ncplane *n)
Definition notcurses.c:1761
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 3008 of file notcurses.c.

3008 {
3010 logerror("can't set the standard plane autogrow");
3011 return false;
3012 }
3013 bool old = n->autogrow;
3014 n->autogrow = growp;
3015 return old;
3016}
const ncplane * notcurses_stdplane_const(const notcurses *nc)
Definition notcurses.c:706
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 1568 of file notcurses.c.

1568 {
1569 return nccell_prime(ncp, &ncp->basecell, egc, stylemask, channels);
1570}
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 1561 of file notcurses.c.

1561 {
1562 if(nccell_wide_right_p(c)){
1563 return -1;
1564 }
1565 return nccell_duplicate(ncp, &ncp->basecell, c);
1566}
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 1533 of file notcurses.c.

1533 {
1534 return ncchannels_set_bchannel(&n->channels, channel);
1535}

◆ ncplane_set_bg_alpha()

API int ncplane_set_bg_alpha ( struct ncplane n,
int  alpha 
)

Definition at line 1549 of file notcurses.c.

1549 {
1550 return ncchannels_set_bg_alpha(&n->channels, alpha);
1551}
Here is the caller graph for this function:

◆ ncplane_set_bg_default()

API void ncplane_set_bg_default ( struct ncplane n)

Definition at line 1509 of file notcurses.c.

1509 {
1510 ncchannels_set_bg_default(&n->channels);
1511}
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 1557 of file notcurses.c.

1557 {
1558 return ncchannels_set_bg_palindex(&n->channels, idx);
1559}
uint32_t idx
Definition egcpool.h:209

◆ 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 1517 of file notcurses.c.

1517 {
1518 return ncchannels_set_bg_rgb8(&n->channels, r, g, b);
1519}
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 1513 of file notcurses.c.

1513 {
1514 ncchannels_set_bg_rgb8_clipped(&n->channels, r, g, b);
1515}
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 1497 of file notcurses.c.

1497 {
1498 ncchannels_set_channels(&n->channels, channels);
1499}
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 1537 of file notcurses.c.

1537 {
1538 return ncchannels_set_fchannel(&n->channels, channel);
1539}

◆ ncplane_set_fg_alpha()

API int ncplane_set_fg_alpha ( struct ncplane n,
int  alpha 
)

Definition at line 1545 of file notcurses.c.

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

◆ ncplane_set_fg_default()

API void ncplane_set_fg_default ( struct ncplane n)

Definition at line 1505 of file notcurses.c.

1505 {
1506 ncchannels_set_fg_default(&n->channels);
1507}
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 1553 of file notcurses.c.

1553 {
1554 return ncchannels_set_fg_palindex(&n->channels, idx);
1555}
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 1525 of file notcurses.c.

1525 {
1526 return ncchannels_set_fg_rgb8(&n->channels, r, g, b);
1527}
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 1521 of file notcurses.c.

1521 {
1522 ncchannels_set_fg_rgb8_clipped(&n->channels, r, g, b);
1523}
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 2664 of file notcurses.c.

2664 {
2665 char* copy = name ? strdup(name) : NULL;
2666 if(copy == NULL && name != NULL){
2667 return -1;
2668 }
2669 free(n->name);
2670 n->name = copy;
2671 return 0;
2672}

◆ 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 2998 of file notcurses.c.

2998 {
2999 bool old = n->scrolling;
3000 n->scrolling = scrollp;
3001 return old;
3002}
Here is the caller graph for this function:

◆ ncplane_set_styles()

API void ncplane_set_styles ( struct ncplane n,
unsigned  stylebits 
)

Definition at line 2077 of file notcurses.c.

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

◆ ncplane_set_userptr()

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

Definition at line 189 of file notcurses.c.

189 {
190 void* ret = n->userptr;
191 n->userptr = opaque;
192 return ret;
193}
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 195 of file notcurses.c.

195 {
196 return n->userptr;
197}
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:4207
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:4619
#define NCREADER_OPTION_HORSCROLL
Definition notcurses.h:4615
#define NCREADER_OPTION_CURSOR
Definition notcurses.h:4622
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:2454
@ 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:3912
const char * desc
Definition notcurses.h:3913
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 3311 of file notcurses.c.

3311 {
3312 int cols;
3313 if(validwidth == NULL){
3314 validwidth = &cols;
3315 }
3316 *validwidth = 0;
3317 int bytes;
3318 if(validbytes == NULL){
3319 validbytes = &bytes;
3320 }
3321 *validbytes = 0;
3322 do{
3323 int thesecols, thesebytes;
3324 thesebytes = utf8_egc_len(egcs, &thesecols);
3325 if(thesebytes < 0){
3326 return -1;
3327 }
3328 egcs += thesebytes;
3329 *validbytes += thesebytes;
3330 *validwidth += thesecols;
3331 }while(*egcs);
3332 return *validwidth;
3333}
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 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:4254

◆ 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}
#define NCTABBED_OPTION_BOTTOM
Definition notcurses.h:4241
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}

◆ 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}

◆ 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}

◆ 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 1142 of file visual.c.

1142 {
1143//fprintf(stderr, "%p tacache: %p\n", n, n->tacache);
1144 struct ncvisual_options fakevopts;
1145 if(vopts == NULL){
1146 memset(&fakevopts, 0, sizeof(fakevopts));
1147 vopts = &fakevopts;
1148 }
1149 loginfo("inblit %dx%d %d@%d %dx%d @ %dx%d %p", ncv->pixy, ncv->pixx, vopts->y, vopts->x,
1150 vopts->leny, vopts->lenx, vopts->begy, vopts->begx, vopts->n);
1151 ncvgeom geom;
1152 const struct blitset* bset;
1153 unsigned disppxy, disppxx, outy, outx;
1154 int placey, placex;
1155 if(ncvisual_geom_inner(&nc->tcache, ncv, vopts, &geom, &bset,
1156 &disppxy, &disppxx, &outy, &outx,
1157 &placey, &placex)){
1158 // ncvisual_blitset_geom() emits its own diagnostics, no need for an error here
1159 return NULL;
1160 }
1161 ncplane* n = vopts->n;
1162 uint32_t transcolor = 0;
1164 transcolor = 0x1000000ull | vopts->transcolor;
1165 }
1166 ncplane* createdn = NULL; // to destroy on error
1167 if(n == NULL || (vopts->flags & NCVISUAL_OPTION_CHILDPLANE)){ // create plane
1168 struct ncplane_options nopts = {
1169 .y = placey,
1170 .x = placex,
1171 .rows = geom.rcelly,
1172 .cols = geom.rcellx,
1173 .userptr = NULL,
1174 .name = geom.blitter == NCBLIT_PIXEL ? "bmap" : "cvis",
1175 .resizecb = NULL,
1176 .flags = 0,
1177 };
1180 nopts.x = vopts->x;
1181 }
1184 nopts.y = vopts->y;
1185 }
1186 loginfo("placing new plane: %d/%d @ %d/%d 0x%016" PRIx64, nopts.rows, nopts.cols, nopts.y, nopts.x, nopts.flags);
1187 if(n == NULL){
1188 n = ncpile_create(nc, &nopts);
1189 }else{
1190 n = ncplane_create(n, &nopts);
1191 }
1192 if((createdn = n) == NULL){
1193 return NULL;
1194 }
1195 placey = 0;
1196 placex = 0;
1197 }
1198 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));
1199 if(geom.blitter != NCBLIT_PIXEL){
1200 n = ncvisual_render_cells(ncv, bset, placey, placex,
1201 &geom, n, vopts->flags, transcolor);
1202 }else{
1203 n = ncvisual_render_pixels(nc, ncv, bset, placey, placex,
1204 &geom, n,
1205 vopts->flags, transcolor,
1206 vopts->pxoffy, vopts->pxoffx);
1207 }
1208 if(n == NULL){
1209 ncplane_destroy(createdn);
1210 }
1211 return n;
1212}
ncplane * ncpile_create(notcurses *nc, const struct ncplane_options *nopts)
Definition notcurses.c:714
#define NCPLANE_OPTION_HORALIGNED
Definition notcurses.h:1441
#define NCPLANE_OPTION_VERALIGNED
Definition notcurses.h:1443
#define NCVISUAL_OPTION_ADDALPHA
Definition notcurses.h:3345
#define NCVISUAL_OPTION_VERALIGNED
Definition notcurses.h:3344
#define NCVISUAL_OPTION_HORALIGNED
Definition notcurses.h:3343
ncblitter_e geom
Definition internal.h:399
ncblitter_e blitter
Definition notcurses.h:3410
unsigned rcellx
Definition notcurses.h:3405
unsigned rcelly
Definition notcurses.h:3405
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:1056
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:1019
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:1802
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:1803
Here is the caller graph for this function:

◆ ncvisual_destroy()

API void ncvisual_destroy ( struct ncvisual ncv)

Definition at line 1231 of file visual.c.

1231 {
1232 if(ncv){
1234 if(ncv->owndata){
1235 free(ncv->data);
1236 }
1237 free(ncv);
1238 }else{
1240 }
1241 }
1242}
void(* visual_destroy)(struct ncvisual *ncv)
Definition internal.h:1810
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 895 of file visual.c.

895 {
896 if(rowstride % 4){
897 logerror("rowstride %d not a multiple of 4", rowstride);
898 return NULL;
899 }
900 if(rows <= 0 || cols <= 0 || rowstride < cols * 4){
901 logerror("illegal bgra geometry");
902 return NULL;
903 }
905 if(ncv){
906 ncv->rowstride = pad_for_image(rowstride, cols);
907 ncv->pixx = cols;
908 ncv->pixy = rows;
909 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
910 if(data == NULL){
912 return NULL;
913 }
914 for(int y = 0 ; y < rows ; ++y){
915 for(int x = 0 ; x < cols ; ++x){
916 uint32_t src;
917 memcpy(&src, (const char*)bgra + y * rowstride + x * 4, 4);
918 uint32_t* dst = &data[ncv->rowstride * y / 4 + x];
919 *dst = 0; // kill scan-build warning about using uninitialized value below
920 ncpixel_set_a(dst, ncpixel_a(src));
921 ncpixel_set_r(dst, ncpixel_b(src));
922 ncpixel_set_g(dst, ncpixel_g(src));
923 ncpixel_set_b(dst, ncpixel_r(src));
924//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]);
925 }
926 }
927 ncvisual_set_data(ncv, data, true);
929 }
930 return ncv;
931}
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:1797
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 862 of file visual.c.

863 {
864 if(rowstride % 4){
865 logerror("rowstride %d not a multiple of 4", rowstride);
866 return NULL;
867 }
868 if(rows <= 0 || cols <= 0 || rowstride < cols * 4){
869 logerror("illegal packed rgb geometry");
870 return NULL;
871 }
873 if(ncv){
874 ncv->rowstride = pad_for_image(cols * 4, cols);
875 ncv->pixx = cols;
876 ncv->pixy = rows;
877 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
878 if(data == NULL){
880 return NULL;
881 }
882 for(int y = 0 ; y < rows ; ++y){
883//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, ncv->rowstride / 4, cols, data[ncv->rowstride * y / 4]);
884 memcpy(data + (ncv->rowstride * y) / 4, (const char*)rgba + rowstride * y, rowstride);
885 for(int x = 0 ; x < cols ; ++x){
886 ncpixel_set_a(&data[y * ncv->rowstride / 4 + x], alpha);
887 }
888 }
889 ncvisual_set_data(ncv, data, true);
891 }
892 return ncv;
893}
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 820 of file visual.c.

821 {
822 if(rowstride % 3){
823 logerror("rowstride %d not a multiple of 3", rowstride);
824 return NULL;
825 }
826 if(rows <= 0 || cols <= 0 || rowstride < cols * 3){
827 logerror("illegal packed rgb geometry");
828 return NULL;
829 }
831 if(ncv){
832 ncv->rowstride = pad_for_image(cols * 4, cols);
833 ncv->pixx = cols;
834 ncv->pixy = rows;
835 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
836 if(data == NULL){
838 return NULL;
839 }
840 const unsigned char* src = rgba;
841 for(int y = 0 ; y < rows ; ++y){
842//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, ncv->rowstride / 4, cols, data[ncv->rowstride * y / 4]);
843 for(int x = 0 ; x < cols ; ++x){
844 unsigned char r, g, b;
845 memcpy(&r, src + rowstride * y + 3 * x, 1);
846 memcpy(&g, src + rowstride * y + 3 * x + 1, 1);
847 memcpy(&b, src + rowstride * y + 3 * x + 2, 1);
848 data[y * ncv->rowstride / 4 + x] = 0; // eliminate scan-build uninitialized data warning
849 ncpixel_set_a(&data[y * ncv->rowstride / 4 + x], alpha);
850 ncpixel_set_r(&data[y * ncv->rowstride / 4 + x], r);
851 ncpixel_set_g(&data[y * ncv->rowstride / 4 + x], g);
852 ncpixel_set_b(&data[y * ncv->rowstride / 4 + x], b);
853//fprintf(stderr, "RGBA: 0x%02x 0x%02x 0x%02x 0x%02x\n", r, g, b, alpha);
854 }
855 }
856 ncvisual_set_data(ncv, data, true);
858 }
859 return ncv;
860}
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 779 of file visual.c.

779 {
780 if(rowstride % 4){
781 logerror("rowstride %d not a multiple of 4", rowstride);
782 return NULL;
783 }
784 if(rowstride * 4 < cols || cols <= 0 || rows <= 0){
785 logerror("invalid rowstride or geometry");
786 return NULL;
787 }
789 if(ncv){
790 // ffmpeg needs inputs with rows aligned on 192-byte boundaries
791 ncv->rowstride = pad_for_image(rowstride, cols);
792 ncv->pixx = cols;
793 ncv->pixy = rows;
794 uint32_t* data = malloc(ncv->rowstride * ncv->pixy);
795 if(data == NULL){
797 return NULL;
798 }
799 for(int y = 0 ; y < rows ; ++y){
800//fprintf(stderr, "ROWS: %d STRIDE: %d (%d) COLS: %d %08x\n", ncv->pixy, ncv->rowstride, rowstride, cols, data[ncv->rowstride * y / 4]);
801 memcpy(data + (ncv->rowstride * y) / 4, (const char*)rgba + rowstride * y, rowstride);
802 }
803 ncvisual_set_data(ncv, data, true);
805 }
806 return ncv;
807}
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 809 of file visual.c.

809 {
810 uint32_t* rgba = ncsixel_as_rgba(s, leny, lenx);
811 if(rgba == NULL){
812 logerror("failed converting sixel to rgba");
813 return NULL;
814 }
815 ncvisual* ncv = ncvisual_from_rgba(rgba, leny, lenx * sizeof(*rgba), lenx);
816 free(rgba);
817 return ncv;
818}
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 1350 of file visual.c.

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

◆ ncvisual_resize()

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

Definition at line 988 of file visual.c.

988 {
990 return ncvisual_resize_noninterpolative(n, rows, cols);
991 }
992 if(visual_implementation->visual_resize(n, rows, cols)){
993 return -1;
994 }
995 return 0;
996}
int(* visual_resize)(struct ncvisual *ncv, unsigned rows, unsigned cols)
Definition internal.h:1809
int ncvisual_resize_noninterpolative(ncvisual *n, int rows, int cols)
Definition visual.c:998
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 998 of file visual.c.

998 {
999 size_t dstride = pad_for_image(cols * 4, cols);
1000 uint32_t* r = resize_bitmap(n->data, n->pixy, n->pixx, n->rowstride,
1001 rows, cols, dstride);
1002 if(r == NULL){
1003 return -1;
1004 }
1005 ncvisual_set_data(n, r, true);
1006 n->rowstride = dstride;
1007 n->pixy = rows;
1008 n->pixx = cols;
1010 return 0;
1011}
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 707 of file visual.c.

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

1265 {
1266 if(y >= n->pixy){
1267 logerror("invalid coordinates %u/%u", y, x);
1268 return -1;
1269 }
1270 if(x >= n->pixx){
1271 logerror("invalid coordinates %u/%u", y, x);
1272 return -1;
1273 }
1274 n->data[y * (n->rowstride / 4) + x] = pixel;
1275 return 0;
1276}
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 1244 of file visual.c.

1245 {
1246 struct ncplane* subtitle = NULL;
1247 int ret = 0;
1248 if(curry){
1249 // FIXME improve this hrmmmmm
1250 ncplane* subncp = curry;
1251 if(subncp->blist){
1252 ncplane_destroy(subncp->blist);
1253 subncp->blist = NULL;
1254 }
1255 subtitle = ncvisual_subtitle_plane(subncp, ncv);
1256 }
1257 if(notcurses_render(ncplane_notcurses(vopts->n))){
1258 return -1;
1259 }
1260 clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, tspec, NULL);
1261 ncplane_destroy(subtitle);
1262 return ret;
1263}
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;
43 struct passwd* pret;
44 long blen = sysconf(_SC_GETPW_R_SIZE_MAX);
45 if(blen < 0){
46 logwarn("couldn't get getpwuid sysconf");
47 blen = 4096;
48 }
49 char* buf = malloc(blen);
50 if(buf == NULL){
51 return NULL;
52 }
53 if(getpwuid_r(uid, &p, buf, blen, &pret) || !pret){
54 free(buf);
55 return NULL;
56 }
57 char* ret = strdup(p.pw_name);
58 free(buf);
59 return ret;
60#else
61 DWORD unlen = UNLEN + 1;
62 char* un = malloc(unlen);
63 if(un == NULL){
64 return NULL;
65 }
66 if(!GetUserNameExA(NameSamCompatible, un, &unlen)){
67 logerror("couldn't get user name");
68 free(un);
69 return NULL;
70 }
71 return un;
72#endif
73}

◆ 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 1245 of file notcurses.c.

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

1437 {
1438 logdebug("we have some planes");
1439 pthread_mutex_lock(&nc->pilelock);
1440 ncpile* p = ncplane_pile(nc->stdplane);
1441 ncpile* p0 = p;
1442 do{
1443 ncpile_drop(nc, &p);
1444 }while(p0 != p);
1445 pthread_mutex_unlock(&nc->pilelock);
1446 logdebug("all planes dropped");
1447}
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 2776 of file in.c.

2776 {
2777 uint32_t ret = internal_get(nc->tcache.ictx, absdl, ni);
2778 return ret;
2779}
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 75 of file util.c.

75 {
76#ifndef __MINGW32__
77 char hostname[_POSIX_HOST_NAME_MAX + 1];
78 if(gethostname(hostname, sizeof(hostname)) == 0){
79 char* fqdn = strchr(hostname, '.');
80 if(fqdn){
81 *fqdn = '\0';
82 }
83 return strdup(hostname);
84 }
85#else // windows
86 char lp[MAX_COMPUTERNAME_LENGTH + 1];
87 DWORD s = sizeof(lp);
88 if(GetComputerNameA(lp, &s)){
89 return strdup(lp);
90 }
91#endif
92 return NULL;
93}

◆ 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 3096 of file notcurses.c.

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

◆ 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 3072 of file notcurses.c.

3072 {
3073 char* eptr;
3074 if(lex_ulong(op, &opts->margin_t, &eptr)){
3075 return -1;
3076 }
3077 if(!*eptr){ // allow a single value to be specified for all four margins
3078 opts->margin_r = opts->margin_l = opts->margin_b = opts->margin_t;
3079 return 0;
3080 }
3081 op = ++eptr; // once here, we require four values
3082 if(lex_ulong(op, &opts->margin_r, &eptr) || !*eptr){
3083 return -1;
3084 }
3085 op = ++eptr;
3086 if(lex_ulong(op, &opts->margin_b, &eptr) || !*eptr){
3087 return -1;
3088 }
3089 op = ++eptr;
3090 if(lex_ulong(op, &opts->margin_l, &eptr) || *eptr){ // must end in NUL
3091 return -1;
3092 }
3093 return 0;
3094}
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 3040 of file notcurses.c.

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

◆ notcurses_linesigs_disable()

API int notcurses_linesigs_disable ( struct notcurses n)

Definition at line 2875 of file in.c.

2875 {
2876 return linesigs_disable(&nc->tcache);
2877}
Here is the caller graph for this function:

◆ notcurses_linesigs_enable()

API int notcurses_linesigs_enable ( struct notcurses n)

Definition at line 2917 of file in.c.

2917 {
2918 return linesigs_enable(&n->tcache);
2919}
Here is the caller graph for this function:

◆ notcurses_mice_enable()

API int notcurses_mice_enable ( struct notcurses n,
unsigned  eventmask 
)

Definition at line 2561 of file notcurses.c.

2561 {
2562 if(mouse_setup(&n->tcache, eventmask)){
2563 return -1;
2564 }
2565 return 0;
2566}
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 95 of file util.c.

95 {
96#ifdef __MINGW32__
97 // FIXME get version
98 return strdup("Microsoft Windows");
99#else
100#ifdef __APPLE__
101#define PREFIX "macOS "
102 char osver[30] = PREFIX; // shrug
103 size_t oldlenp = sizeof(osver) - strlen(PREFIX);
104 if(sysctlbyname("kern.osproductversion", osver + strlen(PREFIX),
105 &oldlenp, NULL, 0) == 0){
106 return strdup(osver);
107 }
108 return strdup("macOS");
109#else
110 struct utsname uts;
111 if(uname(&uts)){
112 logerror("failure invoking uname (%s)", strerror(errno));
113 return NULL;
114 }
115 const size_t nlen = strlen(uts.sysname);
116 const size_t rlen = strlen(uts.release);
117 size_t tlen = nlen + rlen + 2;
118 char* ret = malloc(tlen);
119 memcpy(ret, uts.sysname, nlen);
120 ret[nlen] = ' ';
121 strcpy(ret + nlen + 1, uts.release);
122 return ret;
123#endif
124#undef PREFIX
125#endif
126}
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 702 of file notcurses.c.

702 {
703 return nc->stdplane;
704}
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 1449 of file notcurses.c.

1449 {
1450 logdebug("stopping notcurses");
1451//notcurses_debug(nc, stderr);
1452 int ret = 0;
1453 if(nc){
1454 void* altstack;
1455 ret |= notcurses_stop_minimal(nc, &altstack, 0);
1456 // if we were not using the alternate screen, our cursor's wherever we last
1457 // wrote. move it to the furthest place to which it advanced.
1458 if(!get_escape(&nc->tcache, ESCAPE_SMCUP)){
1459 fbuf_reset(&nc->rstate.f);
1460//fprintf(stderr, "CLOSING TO %d/%d\n", nc->rstate.logendy, nc->rstate.logendx);
1461 goto_location(nc, &nc->rstate.f, nc->rstate.logendy, nc->rstate.logendx, NULL);
1462//fprintf(stderr, "***"); fflush(stderr);
1463 fbuf_finalize(&nc->rstate.f, stdout);
1464 }
1465 if(nc->stdplane){
1467 free_plane(nc->stdplane);
1468 }
1469 if(nc->tcache.ttyfd >= 0){
1470 ret |= close(nc->tcache.ttyfd);
1471 }
1472 egcpool_dump(&nc->pool);
1473 free(nc->lastframe);
1474 // perhaps surprisingly, this stops the input thread
1476 // get any current stats loaded into stash_stats
1478 if(!(nc->flags & NCOPTION_SUPPRESS_BANNERS)){
1479 summarize_stats(nc);
1480 }
1481#ifndef __MINGW32__
1482 del_curterm(cur_term);
1483#endif
1484 ret |= pthread_mutex_destroy(&nc->stats.lock);
1485 ret |= pthread_mutex_destroy(&nc->pilelock);
1486 fbuf_free(&nc->rstate.f);
1487 free(nc);
1488 free(altstack);
1489 }
1490 return ret;
1491}
void summarize_stats(notcurses *nc)
Definition stats.c:166
void notcurses_drop_planes(notcurses *nc)
Definition notcurses.c:1437
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 3057 of file notcurses.c.

3057 {
3058 if(scalemode == NCSCALE_STRETCH){
3059 return "stretch";
3060 }else if(scalemode == NCSCALE_SCALE){
3061 return "scale";
3062 }else if(scalemode == NCSCALE_NONE){
3063 return "none";
3064 }else if(scalemode == NCSCALE_NONE_HIRES){
3065 return "hires";
3066 }else if(scalemode == NCSCALE_SCALE_HIRES){
3067 return "scalehi";
3068 }
3069 return NULL;
3070}
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 185 of file notcurses.c.

185 {
186 return NOTCURSES_VERSION;
187}
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 3495 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:2592

Definition at line 2592 of file notcurses.h.

◆ n

vopts n = newn

Definition at line 3506 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 3488 of file notcurses.h.

◆ newn

return newn

Definition at line 3512 of file notcurses.h.

◆ opts

const struct ncplane_options* opts

Definition at line 3487 of file notcurses.h.

◆ v

struct ncvisual_options v

Definition at line 3501 of file notcurses.h.

◆ vopts

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

Definition at line 3488 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.