2020-03-03 01:19:16 +00:00
|
|
|
% ncdirect_init(3)
|
2020-01-25 06:13:04 +00:00
|
|
|
% nick black <nickblack@linux.com>
|
2020-09-29 17:12:17 +00:00
|
|
|
% v1.7.5
|
2020-01-25 06:13:04 +00:00
|
|
|
|
|
|
|
# NAME
|
|
|
|
|
2020-03-03 01:19:16 +00:00
|
|
|
ncdirect_init - minimal notcurses instances for styling text
|
2020-01-25 06:13:04 +00:00
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
2020-07-10 19:51:28 +00:00
|
|
|
**#include <notcurses/direct.h>**
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-08-30 17:00:41 +00:00
|
|
|
**struct ncdirect* ncdirect_init(const char* termtype, FILE* fp, uint64_t flags);**
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-08-16 04:27:27 +00:00
|
|
|
**unsigned ncdirect_palette_size(const struct ncdirect* nc);**
|
2020-06-30 10:20:09 +00:00
|
|
|
|
2020-02-02 09:15:12 +00:00
|
|
|
**int ncdirect_bg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b);**
|
|
|
|
|
|
|
|
**int ncdirect_fg_rgb8(struct ncdirect* nc, unsigned r, unsigned g, unsigned b);**
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-09-17 19:58:02 +00:00
|
|
|
**int ncdirect_fg_rgb(struct ncdirect* nc, unsigned rgb);**
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-09-17 19:58:02 +00:00
|
|
|
**int ncdirect_bg_rgb(struct ncdirect* nc, unsigned rgb);**
|
2020-02-02 09:15:12 +00:00
|
|
|
|
2020-02-14 04:16:41 +00:00
|
|
|
**int ncdirect_fg_default(struct ncdirect* nc);**
|
|
|
|
|
|
|
|
**int ncdirect_bg_default(struct ncdirect* nc);**
|
|
|
|
|
2020-02-04 08:04:38 +00:00
|
|
|
**int ncdirect_dim_x(const struct ncdirect* nc);**
|
2020-02-05 07:27:41 +00:00
|
|
|
|
2020-02-04 08:04:38 +00:00
|
|
|
**int ncdirect_dim_y(const struct ncdirect* nc);**
|
|
|
|
|
2020-02-05 09:08:42 +00:00
|
|
|
**int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits);**
|
2020-02-05 07:27:41 +00:00
|
|
|
|
2020-02-05 09:08:42 +00:00
|
|
|
**int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits);**
|
2020-02-05 07:27:41 +00:00
|
|
|
|
2020-02-05 09:08:42 +00:00
|
|
|
**int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);**
|
2020-02-05 07:27:41 +00:00
|
|
|
|
2020-02-14 09:03:16 +00:00
|
|
|
**int ncdirect_clear(struct ncdirect* nc)**
|
|
|
|
|
2020-02-02 09:15:12 +00:00
|
|
|
**int ncdirect_stop(struct ncdirect* nc);**
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-02-24 21:56:51 +00:00
|
|
|
**int ncdirect_cursor_move_yx(struct ncdirect* n, int y, int x);**
|
|
|
|
|
2020-03-13 13:56:46 +00:00
|
|
|
**int ncdirect_cursor_enable(struct ncdirect* nc);**
|
|
|
|
|
|
|
|
**int ncdirect_cursor_disable(struct ncdirect* nc);**
|
|
|
|
|
2020-04-08 13:07:49 +00:00
|
|
|
**int ncdirect_cursor_up(struct ncdirect* nc, int num);**
|
|
|
|
|
|
|
|
**int ncdirect_cursor_left(struct ncdirect* nc, int num);**
|
|
|
|
|
|
|
|
**int ncdirect_cursor_right(struct ncdirect* nc, int num);**
|
|
|
|
|
|
|
|
**int ncdirect_cursor_down(struct ncdirect* nc, int num);**
|
|
|
|
|
2020-07-10 20:55:49 +00:00
|
|
|
**int ncdirect_putstr(struct ncdirect* nc, uint64_t channels, const char* utf8);**
|
2020-06-30 10:20:09 +00:00
|
|
|
|
2020-07-10 21:13:46 +00:00
|
|
|
**bool ncdirect_canopen_images(const struct ncdirect* n);**
|
|
|
|
|
|
|
|
**bool ncdirect_canutf8(const struct ncdirect* n);**
|
|
|
|
|
2020-07-10 22:37:41 +00:00
|
|
|
**int ncdirect_hline_interp(struct ncdirect* n, const char* egc, int len, uint64_t h1, uint64_t h2);**
|
|
|
|
|
|
|
|
**int ncdirect_vline_interp(struct ncdirect* n, const char* egc, int len, uint64_t h1, uint64_t h2);**
|
|
|
|
|
|
|
|
**int ncdirect_box(struct ncdirect* n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, const wchar_t* wchars, int ylen, int xlen, unsigned ctlword);**
|
|
|
|
|
|
|
|
**int ncdirect_rounded_box(struct ncdirect* n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen, unsigned ctlword);**
|
|
|
|
|
|
|
|
**int ncdirect_double_box(struct ncdirect* n, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen, unsigned ctlword);**
|
|
|
|
|
2020-08-24 05:23:35 +00:00
|
|
|
**int ncdirect_render_image(struct ncdirect* n, const char* filename, ncblitter_e blitter, ncscale_e scale);**
|
2020-06-19 18:10:18 +00:00
|
|
|
|
2020-01-25 06:13:04 +00:00
|
|
|
# DESCRIPTION
|
|
|
|
|
2020-03-03 01:19:16 +00:00
|
|
|
**ncdirect_init** prepares the **FILE** provided as **fp** (which must
|
2020-01-25 06:13:04 +00:00
|
|
|
be attached to a terminal) for colorizing and styling. On success, a pointer to
|
|
|
|
a valid **struct ncdirect** is returned. **NULL** is returned on failure.
|
2020-08-26 18:16:30 +00:00
|
|
|
Before the process exits, **ncdirect_stop** should be called to reset the
|
|
|
|
terminal and free up resources. **ncdirect_init** places the terminal into
|
|
|
|
"cbreak" (also known as "rare") mode, disabling line-buffering and echo of
|
|
|
|
input. **ncdirect_stop** restores the terminal state as it was when the
|
|
|
|
corresponding **ncdirect_init** call was made.
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-08-30 17:00:41 +00:00
|
|
|
The **flags** parameter to **ncdirect_init** does not yet have any flags
|
|
|
|
defined, and should be passed as 0 for now.
|
|
|
|
|
2020-01-25 06:13:04 +00:00
|
|
|
An appropriate **terminfo(5)** entry must exist for the terminal. This entry is
|
|
|
|
usually selected using the value of the **TERM** environment variable (see
|
|
|
|
**getenv(3)**), but a non-**NULL** value for **termtype** will override this. An
|
|
|
|
invalid terminfo specification can lead to reduced performance, reduced
|
|
|
|
display capabilities, and/or display errors. notcurses natively targets
|
|
|
|
24bpp/8bpc RGB color, and it is thus desirable to use a terminal with the
|
|
|
|
**rgb** capability (e.g. xterm's **xterm-direct**).
|
|
|
|
|
2020-02-04 08:04:38 +00:00
|
|
|
**ncdirect_dim_x** returns the current number of columns, and **ncdirect_dim_y**
|
|
|
|
the current number of rows.
|
|
|
|
|
2020-02-14 09:03:16 +00:00
|
|
|
**ncdirect_clear** clears the screen using a control code if one exists in
|
|
|
|
terminfo. Otherwise, it prints successive newlines to scroll everything off.
|
|
|
|
|
2020-02-24 21:56:51 +00:00
|
|
|
**ncdirect_cursor_move_yx** moves the cursor to the specified coordinate. -1 can
|
|
|
|
be specified for either **y** or **x** to leave that axis unchanged.
|
|
|
|
|
2020-03-13 13:56:46 +00:00
|
|
|
**ncdirect_enable_cursor** and **ncdirect_disable_cursor** always flush the
|
|
|
|
output stream, taking effect immediately.
|
|
|
|
|
2020-04-08 13:07:49 +00:00
|
|
|
**ncdirect_cursor_up** and friends all move relative to the current position.
|
|
|
|
Attempting to e.g. move up while on the top row will return 0, but have no
|
|
|
|
effect.
|
|
|
|
|
2020-01-25 06:13:04 +00:00
|
|
|
# RETURN VALUES
|
|
|
|
|
2020-03-03 01:19:16 +00:00
|
|
|
**ncdirect_init** returns **NULL** on failure. Otherwise, the return value
|
|
|
|
points to a valid **struct ncdirect**, which can be used until it is provided
|
|
|
|
to **ncdirect_stop**.
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-03-13 13:56:46 +00:00
|
|
|
All other functions return 0 on success, and non-zero on error.
|
|
|
|
|
2020-01-25 06:13:04 +00:00
|
|
|
# SEE ALSO
|
|
|
|
|
2020-02-14 04:16:41 +00:00
|
|
|
**getenv(3)**,
|
|
|
|
**termios(3)**,
|
|
|
|
**notcurses(3)**,
|
2020-05-09 00:56:39 +00:00
|
|
|
**notcurses_plane(3)**,
|
2020-02-14 04:16:41 +00:00
|
|
|
**terminfo(5)**
|