2020-01-02 02:23:11 +00:00
|
|
|
% notcurses(3)
|
|
|
|
% nick black <nickblack@linux.com>
|
2021-02-18 12:07:26 +00:00
|
|
|
% v2.2.2
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
# NAME
|
|
|
|
|
2020-01-04 07:37:55 +00:00
|
|
|
notcurses - TUI library for modern terminal emulators
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
2021-01-18 19:10:04 +00:00
|
|
|
**#include <notcurses/notcurses.h>** or
|
|
|
|
**#include <notcurses/notcurses-core.h>**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2021-02-03 03:19:58 +00:00
|
|
|
**-lnotcurses-core -lnotcurses** or **-lnotcurses-core**
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
# DESCRIPTION
|
|
|
|
|
2020-10-12 13:45:44 +00:00
|
|
|
Notcurses builds atop the **terminfo(5)** abstraction layer to provide
|
2020-01-02 02:23:11 +00:00
|
|
|
reasonably portable vivid character displays. It is an intellectual descendant
|
|
|
|
of **ncurses(3NCURSES)**, but goes beyond that library (and the X/Open Curses
|
2021-01-04 02:14:29 +00:00
|
|
|
API it implements).
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-10-12 13:45:44 +00:00
|
|
|
A program wishing to use Notcurses will need to link it, ideally using the
|
2020-01-02 02:23:11 +00:00
|
|
|
output of **pkg-config --libs notcurses** (see **pkg-config(1)**). It is
|
|
|
|
advised to compile with the output of **pkg-config --cflags notcurses**. If
|
2020-09-02 02:02:36 +00:00
|
|
|
using CMake, a support file is provided, and can be accessed as **Notcurses**
|
2021-01-18 19:10:04 +00:00
|
|
|
(see **cmake(1)**). If multimedia capabilities are not needed, it is possible
|
|
|
|
to link against a minimal Notcurses using **pkg-config --libs notcurses-core**.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-10-12 13:45:44 +00:00
|
|
|
**notcurses_init(3)** can then be used to initialize a Notcurses instance for a
|
2020-11-14 20:58:25 +00:00
|
|
|
given **FILE** (usually **stdout**, usually attached to a terminal).
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
## Construction
|
|
|
|
|
2020-10-12 13:45:44 +00:00
|
|
|
Before calling into Notcurses—and usually as one of the first calls of the
|
2020-01-02 02:23:11 +00:00
|
|
|
program—be sure to call **setlocale** with an appropriate UTF-8 **LC_ALL**
|
|
|
|
locale. It is usually appropriate to use **setlocale(LC_ALL, "")**, relying on
|
2020-10-12 13:45:44 +00:00
|
|
|
the user to properly set the **LANG** environment variable. Notcurses will
|
2020-04-19 22:48:34 +00:00
|
|
|
refuse to start if **nl_langinfo(3)** doesn't indicate UTF-8 or ANSI_X3.4-1968
|
|
|
|
(aka US-ASCII). Be aware that capabilities are substantially reduced in ASCII.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
**notcurses_init(3)** accepts a **struct notcurses_options** allowing fine-grained
|
2020-10-12 13:45:44 +00:00
|
|
|
control of Notcurses behavior, including signal handlers, alternative screens,
|
2020-01-02 02:23:11 +00:00
|
|
|
and overriding the TERM environment variable. A **terminfo** entry appropriate
|
|
|
|
for the actual terminal must be available.
|
|
|
|
|
2021-02-06 18:45:27 +00:00
|
|
|
**ncdirect_init(3)** makes available a 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
|
|
|
|
**notcurses_direct(3)**.
|
2020-01-25 06:13:04 +00:00
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
## Output
|
|
|
|
|
|
|
|
All output is performed on **struct ncplane**s (see [Ncplanes][] below). Output
|
|
|
|
is not visible until explicitly rendered via **notcurses_render(3)**. It is safe to
|
|
|
|
output from multiple threads. Information on drawing functions is available at
|
|
|
|
**notcurses_output(3)**.
|
|
|
|
|
|
|
|
## Input
|
|
|
|
|
2020-10-12 13:45:44 +00:00
|
|
|
Notcurses supports input from keyboards (via **stdin**) and pointing devices (via
|
2020-01-02 02:23:11 +00:00
|
|
|
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's
|
2020-05-19 06:02:02 +00:00
|
|
|
[Supplementary Private Use Area-B](https://unicode.org/charts/PDF/U100000.pdf).
|
2020-01-17 02:41:06 +00:00
|
|
|
Information on input is available at **notcurses_input(3)**. The included tool
|
|
|
|
**notcurses-input(1)** can be used to test input decoding.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2021-01-03 07:48:12 +00:00
|
|
|
## Ncpiles
|
|
|
|
|
|
|
|
A given **notcurses** context is made up of one or more piles. Piles provide
|
|
|
|
distinct rendering contexts: a thread can be rendering or mutating one pile,
|
|
|
|
while another thread concurrently renders or mutates another pile. A pile is
|
|
|
|
made up of planes, totally ordered on a z-axis. In addition to the z-ordering,
|
|
|
|
the planes of a pile are bound in a forest (a set of directed, acyclic graphs).
|
|
|
|
Those planes which are not bound to some other plane constitute the root planes
|
|
|
|
of a pile. A pile is destroyed when all its planes are destroyed, or moved to
|
|
|
|
other piles. Since the standard plane (see below) always exists, and cannot be
|
|
|
|
moved to another pile, one pile always exists, known as the standard pile.
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
## Ncplanes
|
|
|
|
|
|
|
|
Following initialization, a single ncplane exists, the "standard plane" (see
|
2020-02-18 12:12:25 +00:00
|
|
|
**notcurses_stdplane(3)**). This plane cannot be destroyed nor manually resized,
|
2020-09-02 02:02:36 +00:00
|
|
|
and is always exactly as large as the screen (if run without a TTY, the "screen"
|
|
|
|
is assumed to be 80x24 cells). Further ncplanes can be created with
|
|
|
|
**ncplane_new(3)**. 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
|
2020-12-13 05:19:24 +00:00
|
|
|
relative to it (including entirely off-screen). Ncplanes are made up of
|
|
|
|
`nccell`s (see [NcCells][] below). Information on ncplanes is available at
|
2020-04-24 07:17:34 +00:00
|
|
|
**notcurses_plane(3)**.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-12-13 05:19:24 +00:00
|
|
|
## NcCells
|
2020-01-02 02:23:11 +00:00
|
|
|
|
2020-12-13 05:19:24 +00:00
|
|
|
`nccell`s make up the framebuffers backing each ncplane, one cell per
|
|
|
|
coordinate, one extended grapheme cluster (see **unicode(7)**) per cell. An
|
|
|
|
`nccell` consists of a gcluster (either a directly-encoded 7-bit ASCII
|
|
|
|
character (see **ascii(7)**), or a 25-bit index into the ncplane's egcpool), a
|
|
|
|
set of attributes, and two channels (one for the foreground, and one for the
|
|
|
|
background—see **notcurses_channels(3)**). Information on cells is available at
|
2020-12-16 10:40:14 +00:00
|
|
|
**notcurses_cell(3)**.
|
2020-01-02 03:06:07 +00:00
|
|
|
|
2020-12-13 05:19:24 +00:00
|
|
|
It is not usually necessary for users to interact directly with `nccell`s. They
|
2020-01-02 03:06:07 +00:00
|
|
|
are typically encountered when retrieving data from ncplanes or the rendered
|
|
|
|
scene (see e.g. **ncplane_at_yx(3)**), or to achieve peak performance when a
|
|
|
|
particular EGC is heavily reused within a plane.
|
|
|
|
|
2020-01-30 13:55:01 +00:00
|
|
|
## Widgets
|
|
|
|
|
|
|
|
A few high-level widgets are included, all built atop ncplanes:
|
|
|
|
|
2020-04-29 07:24:11 +00:00
|
|
|
* **notcurses_fds(3)** for dumping file descriptors/subprocesses to a plane
|
2020-02-06 01:18:11 +00:00
|
|
|
* **notcurses_menu(3)** for menu bars at the top or bottom of the screen
|
2020-04-01 09:05:29 +00:00
|
|
|
* **notcurses_multiselector(3)** for selecting one or more items from a set
|
|
|
|
* **notcurses_plot(3)** for drawing histograms and lineplots
|
2020-12-12 09:36:17 +00:00
|
|
|
* **notcurses_progbar(3)** for drawing progress bars
|
2020-06-05 09:56:29 +00:00
|
|
|
* **notcurses_reader(3)** for free-form input data
|
2021-02-11 20:32:04 +00:00
|
|
|
* **notcurses_reel(3)** for hierarchal display of block-based data
|
2020-01-30 13:55:01 +00:00
|
|
|
* **notcurses_selector(3)** for selecting one item from a set
|
|
|
|
|
2020-01-02 03:06:07 +00:00
|
|
|
## Threads
|
|
|
|
|
2020-02-19 01:03:20 +00:00
|
|
|
Notcurses explicitly supports use in multithreaded environments, but it does
|
2021-01-03 07:48:12 +00:00
|
|
|
not itself perform any locking.
|
|
|
|
|
|
|
|
* Only one pile's rendered frame can be rasterized at a time, and it is **not**
|
|
|
|
safe to concurrently render that pile. It is safe to rasterize a frame while
|
|
|
|
rendering some other pile.
|
|
|
|
* It is otherwise always safe to operate concurrently on distinct piles.
|
|
|
|
* It is not safe to render a pile while concurrently modifying that pile.
|
|
|
|
* It is safe to output to multiple distinct ncplanes at the same time, even
|
|
|
|
within the same pile.
|
|
|
|
* It is safe to output to ncplanes while adding or deleting some other ncplane.
|
|
|
|
* It is **not** safe for multiple threads to output to the same ncplane.
|
|
|
|
* It is **not** safe to add, delete, or reorder ncplanes within a single pile
|
|
|
|
from multiple threads.
|
2020-02-19 01:03:20 +00:00
|
|
|
|
|
|
|
Only one thread may call **notcurses_getc** or any other input-related thread
|
|
|
|
at a time, but it **is** safe to call for input while another thread renders.
|
2020-01-02 03:06:07 +00:00
|
|
|
|
|
|
|
Since multiple threads can concurrently manipulate distinct ncplanes, peak
|
2021-01-03 07:48:12 +00:00
|
|
|
performance might require dividing the screen into several planes, and
|
2020-01-02 03:06:07 +00:00
|
|
|
manipulating them from multiple threads.
|
2020-01-02 02:23:11 +00:00
|
|
|
|
|
|
|
## Destruction
|
|
|
|
|
|
|
|
Before exiting, **notcurses_stop(3)** 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, **notcurses_init(3)** installs signal handlers to catch all
|
|
|
|
signals which would normally terminate the process. The new handlers will try
|
|
|
|
to call **notcurses_stop(3)**, and then propagate the received signal to the
|
|
|
|
previous action.
|
|
|
|
|
2020-12-06 16:55:45 +00:00
|
|
|
# NOTES
|
|
|
|
|
|
|
|
When using the C++ wrappers, **NCPP_EXCEPTIONS_PLEASE** can be defined in
|
|
|
|
order to turn most error returns into exceptions.
|
|
|
|
|
2020-01-02 02:23:11 +00:00
|
|
|
# SEE ALSO
|
|
|
|
|
2020-01-17 02:41:06 +00:00
|
|
|
**ncurses(3NCURSES)**,
|
|
|
|
**notcurses-demo(1)**,
|
|
|
|
**notcurses-input(1)**,
|
2020-08-16 05:22:53 +00:00
|
|
|
**notcurses_capabilities(3)**,
|
2020-12-16 10:40:14 +00:00
|
|
|
**notcurses_cell(3)**,
|
2020-06-18 15:04:29 +00:00
|
|
|
**notcurses_channels(3)**,
|
2021-02-03 05:18:10 +00:00
|
|
|
**notcurses_direct(3)**,
|
2020-04-27 23:11:00 +00:00
|
|
|
**notcurses_fade(3)**,
|
|
|
|
**notcurses_fds(3)**,
|
|
|
|
**notcurses_init(3)**,
|
|
|
|
**notcurses_input(3)**,
|
2020-01-17 02:41:06 +00:00
|
|
|
**notcurses_lines(3)**,
|
2020-02-06 01:18:11 +00:00
|
|
|
**notcurses_menu(3)**,
|
2020-03-25 11:38:35 +00:00
|
|
|
**notcurses_multiselector(3)**,
|
2020-01-17 02:41:06 +00:00
|
|
|
**notcurses_output(3)**,
|
|
|
|
**notcurses_palette(3)**,
|
2020-04-24 07:17:34 +00:00
|
|
|
**notcurses_plane(3)**,
|
2020-04-01 09:05:29 +00:00
|
|
|
**notcurses_plot(3)**,
|
2020-12-12 09:36:17 +00:00
|
|
|
**notcurses_progbar(3)**,
|
2020-05-11 07:23:05 +00:00
|
|
|
**notcurses_reader(3)**,
|
2020-02-06 01:18:11 +00:00
|
|
|
**notcurses_reel(3)**,
|
2020-04-08 09:39:41 +00:00
|
|
|
**notcurses_refresh(3)**,
|
2020-01-30 13:55:01 +00:00
|
|
|
**notcurses_render(3)**,
|
|
|
|
**notcurses_selector(3)**,
|
2020-01-17 02:41:06 +00:00
|
|
|
**notcurses_stats(3)**,
|
2020-06-18 15:04:29 +00:00
|
|
|
**notcurses_stdplane(3)**,
|
|
|
|
**notcurses_stop(3)**,
|
2020-04-24 07:17:34 +00:00
|
|
|
**notcurses_visual(3)**,
|
2020-01-17 02:41:06 +00:00
|
|
|
**terminfo(5)**, **ascii(7)**, **utf-8(7)**,
|
|
|
|
**unicode(7)**
|