Notcurses
blingful character graphics/TUI library. definitely not curses.
Install / Use
/learn @dankamongmen/NotcursesREADME
Notcurses: blingful TUIs and character graphics
What it is: a library facilitating complex TUIs on modern terminal emulators, supporting vivid colors, multimedia, threads, and Unicode to the maximum degree possible. Things can be done with Notcurses that simply can't be done with NCURSES. It is furthermore fast as shit. What it is not: a source-compatible X/Open Curses implementation, nor a replacement for NCURSES on existing systems.
<p align="center"> <a href="https://www.youtube.com/watch?v=dcjkezf1ARY"><img src="https://raw.githubusercontent.com/dankamongmen/notcurses/gh-pages/notcurses-logo.png" alt="setting the standard (hype video)"/></a> </p>for more information, see dankwiki and the man pages. in addition, there is Doxygen output. i wrote a coherent guidebook, which is available for free download (or paperback purchase).
i've not yet added many documented examples, but src/poc/
and src/pocpp/
contain many small C and C++ programs respectively. notcurses-demo covers
most of the functionality of Notcurses.
If you're running Notcurses applications in a Docker, please consult "Environment notes" below.
<a href="https://repology.org/project/notcurses/versions"> <img src="https://repology.org/badge/vertical-allrepos/notcurses.svg" alt="Packaging status" align="right"> </a>
Introduction
Notcurses abandons the X/Open Curses API bundled as part of the Single UNIX Specification. For some necessary background, consult Thomas E. Dickey's superb and authoritative NCURSES FAQ. As such, Notcurses is not a drop-in Curses replacement.
Wherever possible, Notcurses makes use of the Terminfo library shipped with NCURSES, benefiting greatly from its portability and thoroughness.
Notcurses opens up advanced functionality for the interactive user on workstations, phones, laptops, and tablets, possibly at the expense of e.g. some industrial and retail terminals. Fundamentally, Curses assumes the minimum and allows you (with effort) to step up, whereas Notcurses assumes the maximum and steps down (by itself) when necessary. The latter approach probably breaks on some older hardware, but the former approach results in new software looking like old hardware.
Why use this non-standard library?
-
Thread safety, and efficient use in parallel programs, has been a design consideration from the beginning.
-
A more orderly surface than that codified by X/Open: Exported identifiers are prefixed to avoid common namespace collisions. Where reasonable,
static inlineheader-only code is used. This facilitates compiler optimizations, and reduces loader time. Notcurses can be built without its multimedia functionality, requiring a significantly lesser set of dependencies. -
All APIs natively support the Universal Character Set (Unicode). The
nccellAPI is based around Unicode's Extended Grapheme Cluster concept. -
Visual features including images, fonts, video, high-contrast text, sprites, and transparent regions. All APIs natively support 24-bit color, quantized down as necessary for the terminal.
-
Portable support for bitmapped graphics, using Sixel, Kitty, and even the Linux framebuffer console.
-
Support for unambiguous keyboard protocols.
-
"TUI mode" facilitates high-performance, non-scrolling, full-screen applications. "CLI mode" supports scrolling output for shell utilities, but with the full power of Notcurses.
-
It's Apache2-licensed in its entirety, as opposed to the drama in several acts that is the NCURSES license (the latter is summarized as "a restatement of MIT-X11").
Much of the above can be had with NCURSES, but they're not what NCURSES was designed for. On the other hand, if you're targeting industrial or critical applications, or wish to benefit from time-tested reliability and portability, you should by all means use that fine library.
Requirements
Minimum versions generally indicate the oldest version I've tested with; it may well be possible to use still older versions. Let me know of any successes!
- (build) CMake 3.21.0+ and a C17 compiler
- (OPTIONAL) (OpenImageIO, testing, C++ bindings): A C++17 compiler
- (build+runtime) From NCURSES: terminfo 6.1+
- (build+runtime) GNU libunistring 0.9.10+
- (OPTIONAL) (build+runtime) libgpm 1.20+
- (OPTIONAL) (build+runtime) From QR-Code-generator: libqrcodegen 1.5.0+
- (OPTIONAL) (build+runtime) From FFmpeg: libswscale 5.0+, libavformat 57.0+, libavutil 56.0+, libavdevice 57.0+
- (OPTIONAL) (build+runtime) OpenImageIO 2.15.0+, requires C++
- (OPTIONAL) (testing) Doctest 2.3.5+
- (OPTIONAL) (documentation) pandoc 1.19.2+
- (OPTIONAL) (python bindings): Python 3.7+, CFFI 1.13.2+, pypandoc 1.5+
- (runtime) Linux 2.6+, FreeBSD 11+, DragonFly BSD 5.9+, Windows 10 v1093+, or macOS 11.4+
More information on building and installation is available in INSTALL.md.
Wrappers
If you wish to use a language other than C to work with Notcurses, numerous wrappers are available. Several are included in this repository, while others are external.
| Language | Lead(s) | Repository | | -------- | ----------------------------- | ---------- | | Ada | Jeremy Grosser | JeremyGrosser/notcursesada | | C++ | Marek Habersack, nick black | internal | | Dart | Nelson Fernandez | kascote/dart_notcurses | | Julia | Dheepak Krishnamurthy | kdheepak/Notcurses.jl | | Nim | Michael S. Bradley, Jr. | michaelsbradleyjr/nim-notcurses | | Python | nick black | internal | | Python | igo95862 | internal | | Rust | José Luis Cruz | dankamongmen/libnotcurses-sys | | Zig | Jakub Dundalek | dundalek/notcurses-zig-example |
Included tools
Nine executables are installed as part of Notcurses:
ncls: anlsthat displays multimedia in the terminalncneofetch: a neofetch ripoffncplayer: renders visual media (images/videos)nctetris: a tetris clonenotcurses-demo: some demonstration codenotcurses-info: detect and print terminal capabilities/diagnosticsnotcurses-input: decode and print keypressesnotcurses-tester: unit testingtfman: a swank manual browser
To run notcurses-demo from a checkout, provide the data directory via
the -p argument. Demos requiring data files will otherwise abort. The base
delay used in notcurses-demo can be changed with -d, accepting a
floating-point multiplier. Values less than 1 will speed up the demo, while
values greater than 1 will slow it down.
notcurses-tester likewise requires that data, populated with the necessary
data files, be specified with -p. It can be run by itself, or via make test.
Documentation
With -DUSE_PANDOC=on (the default), a full set of man pages and XHTML
will be built from doc/man. The following Markdown documentation is included
directly:
- Per-release News for packagers, developers, and users.
- The
TERMenvironment variable and various terminal emulators. - Notes on contributing and hacking.
- There's a semi-com
