.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "notcurses" "3" "v2.0.4" "" "" .hy .SH NAME .PP notcurses - TUI library for modern terminal emulators .SH SYNOPSIS .PP \f[B]#include \f[R] .PP \f[B]-lnotcurses\f[R] .SH DESCRIPTION .PP Notcurses builds atop the \f[B]terminfo(5)\f[R] abstraction layer to provide reasonably portable vivid character displays. It is an intellectual descendant of \f[B]ncurses(3NCURSES)\f[R], but goes beyond that library (and the X/Open Curses API it implements). Notcurses is capable of subregion fades, 24bpp TrueColor, transparency, multimedia, and safe multithreaded use. .PP A program wishing to use Notcurses will need to link it, ideally using the output of \f[B]pkg-config \[en]libs notcurses\f[R] (see \f[B]pkg-config(1)\f[R]). It is advised to compile with the output of \f[B]pkg-config \[en]cflags notcurses\f[R]. If using CMake, a support file is provided, and can be accessed as \f[B]Notcurses\f[R] (see \f[B]cmake(1)\f[R]). .PP \f[B]notcurses_init(3)\f[R] can then be used to initialize a Notcurses instance for a given \f[B]FILE\f[R] (usually \f[B]stdout\f[R]), after calling \f[B]setlocale(3)\f[R] to prepare a UTF-8 locale (see Construction). .SS Construction .PP Before calling into Notcurses\[em]and usually as one of the first calls of the program\[em]be sure to call \f[B]setlocale\f[R] with an appropriate UTF-8 \f[B]LC_ALL\f[R] locale. It is usually appropriate to use \f[B]setlocale(LC_ALL, \[dq]\[dq])\f[R], relying on the user to properly set the \f[B]LANG\f[R] environment variable. Notcurses will refuse to start if \f[B]nl_langinfo(3)\f[R] doesn\[cq]t indicate UTF-8 or ANSI_X3.4-1968 (aka US-ASCII). Be aware that capabilities are substantially reduced in ASCII. .PP \f[B]notcurses_init(3)\f[R] accepts a \f[B]struct notcurses_options\f[R] allowing fine-grained control of Notcurses behavior, including signal handlers, alternative screens, and overriding the TERM environment variable. A \f[B]terminfo\f[R] entry appropriate for the actual terminal must be available. .PP \f[B]ncdirect_init(3)\f[R] makes available a very restricted subset of Notcurses functionality. This subset is intended to be interleaved with user- generated output, and is limited to coloring and styling. Direct mode is documented in \f[B]notcurses_directmode(3)\f[R] .SS Output .PP All output is performed on \f[B]struct ncplane\f[R]s (see Ncplanes below). Output is not visible until explicitly rendered via \f[B]notcurses_render(3)\f[R]. It is safe to output from multiple threads. Information on drawing functions is available at \f[B]notcurses_output(3)\f[R]. .SS Input .PP Notcurses supports input from keyboards (via \f[B]stdin\f[R]) and pointing devices (via a broker such as GPM, X, or Wayland). Input is delivered as 32-bit Unicode code points. Synthesized events such as mouse button presses and arrow keys are mapped into Unicode\[cq]s Supplementary Private Use Area-B (https://unicode.org/charts/PDF/U100000.pdf). Information on input is available at \f[B]notcurses_input(3)\f[R]. The included tool \f[B]notcurses-input(1)\f[R] can be used to test input decoding. .SS Ncplanes .PP Following initialization, a single ncplane exists, the \[lq]standard plane\[rq] (see \f[B]notcurses_stdplane(3)\f[R]). This plane cannot be destroyed nor manually resized, and is always exactly as large as the screen (if run without a TTY, the \[lq]screen\[rq] is assumed to be 80x24 cells). Further ncplanes can be created with \f[B]ncplane_new(3)\f[R]. A total z-ordering always exists on the set of ncplanes, and new ncplanes are placed at the top of the z-buffer. Ncplanes can be larger, smaller, or the same size as the physical screen, and can be placed anywhere relative to it (including entirely off-screen). Ncplanes are made up of cells (see Cells below). Information on ncplanes is available at \f[B]notcurses_plane(3)\f[R]. .SS Cells .PP Cells make up the framebuffers backing each ncplane, one cell per coordinate, one extended grapheme cluster (see \f[B]unicode(7)\f[R]) per cell. A cell consists of a gcluster (either a directly-encoded 7-bit ASCII character (see \f[B]ascii(7)\f[R]), or a 25-bit index into the ncplane\[cq]s egcpool), a set of attributes, and two channels (one for the foreground, and one for the background\[em]see \f[B]notcurses_channels(3)\f[R]). Information on cells is available at \f[B]notcurses_cell(3)\f[R]. .PP It is not usually necessary for users to interact directly with cells. They are typically encountered when retrieving data from ncplanes or the rendered scene (see e.g.\ \f[B]ncplane_at_yx(3)\f[R]), or to achieve peak performance when a particular EGC is heavily reused within a plane. .SS Widgets .PP A few high-level widgets are included, all built atop ncplanes: .IP \[bu] 2 \f[B]notcurses_fds(3)\f[R] for dumping file descriptors/subprocesses to a plane .IP \[bu] 2 \f[B]notcurses_menu(3)\f[R] for menu bars at the top or bottom of the screen .IP \[bu] 2 \f[B]notcurses_multiselector(3)\f[R] for selecting one or more items from a set .IP \[bu] 2 \f[B]notcurses_plot(3)\f[R] for drawing histograms and lineplots .IP \[bu] 2 \f[B]notcurses_reader(3)\f[R] for free-form input data .IP \[bu] 2 \f[B]notcurses_reel(3)\f[R] for hierarchal display of data .IP \[bu] 2 \f[B]notcurses_selector(3)\f[R] for selecting one item from a set .SS Threads .PP Notcurses explicitly supports use in multithreaded environments, but it does not itself perform any locking. It is safe to output to multiple distinct ncplanes at the same time. It is safe to output to ncplanes while adding or deleting some other ncplane. It is \f[B]not\f[R] safe for multiple threads to output to the same ncplane. It is \f[B]not\f[R] safe to add, delete, or reorder ncplanes from multiple threads, and it is never safe to invoke \f[B]notcurses_render\f[R] while any other thread is touching that \f[B]notcurses\f[R] object (aside from input functions; read on). .PP Only one thread may call \f[B]notcurses_getc\f[R] or any other input-related thread at a time, but it \f[B]is\f[R] safe to call for input while another thread renders. .PP Since multiple threads can concurrently manipulate distinct ncplanes, peak performance sometimes requires dividing the screen into several planes, and manipulating them from multiple threads. .SS Destruction .PP Before exiting, \f[B]notcurses_stop(3)\f[R] should be called. In addition to freeing up resources, this is necessary to restore the terminal to a state useful for the shell. By default, \f[B]notcurses_init(3)\f[R] installs signal handlers to catch all signals which would normally terminate the process. The new handlers will try to call \f[B]notcurses_stop(3)\f[R], and then propagate the received signal to the previous action. .SH SEE ALSO .PP \f[B]ncurses(3NCURSES)\f[R], \f[B]notcurses-demo(1)\f[R], \f[B]notcurses-input(1)\f[R], \f[B]notcurses_capabilities(3)\f[R], \f[B]notcurses_cell(3)\f[R], \f[B]notcurses_channels(3)\f[R], \f[B]notcurses_directmode(3)\f[R], \f[B]notcurses_fade(3)\f[R], \f[B]notcurses_fds(3)\f[R], \f[B]notcurses_init(3)\f[R], \f[B]notcurses_input(3)\f[R], \f[B]notcurses_lines(3)\f[R], \f[B]notcurses_menu(3)\f[R], \f[B]notcurses_multiselector(3)\f[R], \f[B]notcurses_output(3)\f[R], \f[B]notcurses_palette(3)\f[R], \f[B]notcurses_plane(3)\f[R], \f[B]notcurses_plot(3)\f[R], \f[B]notcurses_reader(3)\f[R], \f[B]notcurses_reel(3)\f[R], \f[B]notcurses_refresh(3)\f[R], \f[B]notcurses_render(3)\f[R], \f[B]notcurses_selector(3)\f[R], \f[B]notcurses_stats(3)\f[R], \f[B]notcurses_stdplane(3)\f[R], \f[B]notcurses_stop(3)\f[R], \f[B]notcurses_visual(3)\f[R], \f[B]terminfo(5)\f[R], \f[B]ascii(7)\f[R], \f[B]utf-8(7)\f[R], \f[B]unicode(7)\f[R] .SH AUTHORS nick black .