2020-10-21 06:00:42 +00:00
# Notcurses: blingful TUIs and character graphics
2019-12-13 22:14:15 +00:00
2021-06-19 07:38:00 +00:00
**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 ](https://www.youtube.com/watch?v=dcjkezf1ARY ) 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.
2020-07-01 23:31:23 +00:00
2021-01-12 23:49:16 +00:00
< p align = "center" >
2021-06-19 07:36:38 +00:00
< 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 >
2021-06-27 12:14:30 +00:00
< / p >
2021-06-27 12:12:14 +00:00
2020-01-22 11:51:25 +00:00
for more information, see [dankwiki ](https://nick-black.com/dankwiki/index.php/Notcurses )
2021-04-04 01:54:10 +00:00
and the [man pages ](https://notcurses.com ). in addition, there is
[Doxygen ](https://notcurses.com/html/ ) output. there is a
2020-07-01 23:31:23 +00:00
[mailing list ](https://groups.google.com/forum/#!forum/notcurses ) which can be reached
2020-10-15 10:57:41 +00:00
via notcurses@googlegroups.com. i wrote a coherent
[guidebook ](https://nick-black.com/htp-notcurses.pdf ), which is available for
2021-02-05 04:37:30 +00:00
free download (or [paperback purchase ](https://amazon.com/dp/B086PNVNC9 )).
2019-12-22 04:31:57 +00:00
2021-02-05 04:37:30 +00:00
i've not yet added many documented examples, but [src/poc/ ](https://github.com/dankamongmen/notcurses/tree/master/src/poc )
and [src/pocpp/ ](https://github.com/dankamongmen/notcurses/tree/master/src/pocpp )
contain many small C and C++ programs respectively. `notcurses-demo` covers
most of the functionality of Notcurses.
2020-04-02 18:01:57 +00:00
2020-06-16 08:13:49 +00:00
**If you're running Notcurses applications in a Docker, please consult
2021-08-08 23:57:46 +00:00
"[Environment notes](#environment-notes)" below.**
2020-02-03 20:26:29 +00:00
2021-06-19 07:28:07 +00:00
< a href = "https://repology.org/project/notcurses/versions" >
< img src = "https://repology.org/badge/vertical-allrepos/notcurses.svg" alt = "Packaging status" align = "right" >
< / a >
2020-10-28 19:26:06 +00:00
![Linux ](https://img.shields.io/badge/-Linux-grey?logo=linux )
2020-10-28 19:27:56 +00:00
![FreeBSD ](https://img.shields.io/badge/-FreeBSD-grey?logo=freebsd )
2021-07-22 19:24:13 +00:00
![Windows ](https://img.shields.io/badge/-Windows-grey?logo=windows )
2021-07-25 01:56:10 +00:00
![macOS ](https://img.shields.io/badge/-macOS-grey?logo=macos )
2021-06-19 06:10:56 +00:00
2021-10-04 06:21:28 +00:00
[![Linux ](https://github.com/dankamongmen/notcurses/actions/workflows/ubuntu_test.yml/badge.svg?branch=master )](https://github.com/dankamongmen/notcurses/actions/workflows/ubuntu_test.yml?query=branch%3Amaster)
2021-07-14 16:55:17 +00:00
[![macOS ](https://github.com/dankamongmen/notcurses/actions/workflows/macos_test.yml/badge.svg?branch=master )](https://github.com/dankamongmen/notcurses/actions/workflows/macos_test.yml?query=branch%3Amaster)
2021-07-18 22:39:26 +00:00
[![Windows ](https://github.com/dankamongmen/notcurses/actions/workflows/windows_test.yml/badge.svg?branch=master )](https://github.com/dankamongmen/notcurses/actions/workflows/windows_test.yml?query=branch%3Amaster)
2021-06-19 06:10:56 +00:00
2020-10-28 19:43:16 +00:00
[![pypi_version ](https://img.shields.io/pypi/v/notcurses?label=pypi )](https://pypi.org/project/notcurses)
2020-11-22 06:17:14 +00:00
[![crates.io ](https://img.shields.io/crates/v/libnotcurses-sys.svg )](https://crates.io/crates/libnotcurses-sys)
2020-07-09 08:15:31 +00:00
2021-10-28 00:36:07 +00:00
[![Matrix ](https://img.shields.io/matrix/notcursesdev:matrix.org?label=matrixchat )](https://app.element.io/#/room/#notcursesdev:matrix.org)
2021-10-04 06:21:28 +00:00
[![Sponsor ](https://img.shields.io/badge/-Sponsor-red?logo=github )](https://github.com/sponsors/dankamongmen)
2019-11-25 05:26:35 +00:00
## Introduction
2020-04-21 05:50:53 +00:00
Notcurses abandons the X/Open Curses API bundled as part of the Single UNIX
2021-01-07 22:00:04 +00:00
Specification. For some necessary background, consult Thomas E. Dickey's
2020-01-05 23:36:33 +00:00
superb and authoritative [NCURSES FAQ ](https://invisible-island.net/ncurses/ncurses.faq.html#xterm_16MegaColors ).
2020-12-30 06:06:51 +00:00
As such, Notcurses is not a drop-in Curses replacement.
2019-11-21 16:00:40 +00:00
2020-12-30 06:06:51 +00:00
Wherever possible, Notcurses makes use of the Terminfo library shipped with
2019-11-23 14:07:35 +00:00
NCURSES, benefiting greatly from its portability and thoroughness.
2019-11-18 04:09:06 +00:00
2020-04-21 05:50:53 +00:00
Notcurses opens up advanced functionality for the interactive user on
2021-03-15 00:48:20 +00:00
workstations, phones, laptops, and tablets, possibly at the expense of e.g.
2021-02-06 18:52:59 +00:00
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.
2019-11-18 04:09:06 +00:00
Why use this non-standard library?
2019-12-14 10:33:34 +00:00
* Thread safety, and efficient use in parallel programs, has been a design
consideration from the beginning.
2019-11-18 04:09:06 +00:00
2021-04-12 13:49:19 +00:00
* A more orderly surface than that codified by X/Open: Exported identifiers are
2021-06-21 17:34:46 +00:00
prefixed to avoid common namespace collisions. Where reasonable,
`static inline` header-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.
2019-11-18 04:09:06 +00:00
2021-03-24 18:46:05 +00:00
* All APIs natively support the Universal Character Set (Unicode). The `nccell`
2020-04-26 21:32:08 +00:00
API is based around Unicode's [Extended Grapheme Cluster ](https://unicode.org/reports/tr29/ ) concept.
2019-12-14 10:33:34 +00:00
* 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.
2019-11-18 17:16:26 +00:00
2021-08-20 04:00:38 +00:00
* Portable support for bitmapped graphics, whether using Sixel, Kitty, the iTerm2
protocol, or even the Linux framebuffer console.
2021-09-04 20:56:01 +00:00
* Support for unambiguous [keyboard protocols ](https://sw.kovidgoyal.net/kitty/keyboard-protocol/ ).
* "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.
2019-11-23 14:05:32 +00:00
* It's Apache2-licensed in its entirety, as opposed to the
2019-11-23 14:12:00 +00:00
[drama in several acts ](https://invisible-island.net/ncurses/ncurses-license.html )
2019-11-23 14:05:32 +00:00
that is the NCURSES license (the latter is [summarized ](https://invisible-island.net/ncurses/ncurses-license.html#issues_freer )
as "a restatement of MIT-X11").
2019-12-14 10:33:34 +00:00
Much of the above can be had with NCURSES, but they're not what NCURSES was
2021-01-07 22:00:04 +00:00
*designed* for. On the other hand, if you're targeting industrial or critical
2021-05-26 05:24:08 +00:00
applications, or wish to benefit from time-tested reliability and
2021-01-07 22:00:04 +00:00
portability, you should by all means use that fine library.
2019-11-21 14:06:36 +00:00
2019-11-25 03:24:41 +00:00
## Requirements
2021-01-08 12:27:26 +00:00
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!
2021-03-29 05:38:18 +00:00
* (build) CMake 3.14.0+ and a C11 compiler
* (OPTIONAL) (OpenImageIO, testing, C++ bindings): A C++17 compiler
2020-12-03 06:39:09 +00:00
* (build+runtime) From [NCURSES ](https://invisible-island.net/ncurses/announce.html ): terminfo 6.1+
* (build+runtime) GNU [libunistring ](https://www.gnu.org/software/libunistring/ ) 0.9.10+
2021-08-24 01:42:08 +00:00
* (OPTIONAL) (build+runtime) [libgpm ](https://www.nico.schottelius.org/software/gpm/ ) 1.20+
2020-04-21 03:26:41 +00:00
* (OPTIONAL) (build+runtime) From QR-Code-generator: [libqrcodegen ](https://github.com/nayuki/QR-Code-generator ) 1.5.0+
2020-05-20 17:22:43 +00:00
* (OPTIONAL) (build+runtime) From [FFmpeg ](https://www.ffmpeg.org/ ): libswscale 5.0+, libavformat 57.0+, libavutil 56.0+
2021-03-29 05:38:18 +00:00
* (OPTIONAL) (build+runtime) [OpenImageIO ](https://github.com/OpenImageIO/oiio ) 2.15.0+, requires C++
2020-02-19 01:03:20 +00:00
* (OPTIONAL) (testing) [Doctest ](https://github.com/onqtam/doctest ) 2.3.5+
2020-02-18 17:36:16 +00:00
* (OPTIONAL) (documentation) [pandoc ](https://pandoc.org/index.html ) 1.19.2+
2020-07-29 13:34:46 +00:00
* (OPTIONAL) (python bindings): Python 3.7+, [CFFI ](https://pypi.org/project/cffi/ ) 1.13.2+, [pypandoc ](https://pypi.org/project/pypandoc/ ) 1.5+
2021-11-18 08:54:59 +00:00
* (runtime) Linux 5.3+, FreeBSD 11+, DragonFly BSD 5.9+, Windows 10 v1093+, or macOS 11.4+
2019-11-25 03:24:41 +00:00
2021-01-17 00:57:52 +00:00
[Here's more information ](INSTALL.md ) on building and installation.
2020-05-20 17:22:43 +00:00
2021-09-20 06:45:59 +00:00
### 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 ](https://github.com/JeremyGrosser/notcursesada ) |
| C++ | Marek Habersack, nick black | internal |
| Python | nick black | internal |
| Python | igo95862 | internal |
| Rust | José Luis Cruz | [dankamongmen/libnotcurses-sys ](https://github.com/dankamongmen/libnotcurses-sys ) |
| Zig | Jakub Dundalek | [dundalek/notcurses-zig-example ](https://github.com/dundalek/notcurses-zig-example ) |
2019-11-29 06:58:45 +00:00
## Included tools
2021-12-04 17:10:21 +00:00
Nine binaries are installed as part of Notcurses:
2021-01-18 19:22:54 +00:00
* `ncls` : an `ls` that displays multimedia in the terminal
2021-12-04 17:10:21 +00:00
* `ncman` : a fancy manual browser
2021-01-18 19:22:54 +00:00
* `ncneofetch` : a [neofetch ](https://github.com/dylanaraps/neofetch ) ripoff
* `ncplayer` : renders visual media (images/videos)
2021-01-21 08:51:12 +00:00
* `nctetris` : a tetris clone
* `notcurses-demo` : some demonstration code
2021-06-10 00:54:20 +00:00
* `notcurses-info` : detect and print terminal capabilities/diagnostics
2019-11-29 06:58:45 +00:00
* `notcurses-input` : decode and print keypresses
2019-12-14 00:22:11 +00:00
* `notcurses-tester` : unit testing
2019-11-29 06:58:45 +00:00
2021-02-25 07:57:10 +00:00
To run `notcurses-demo` from a checkout, provide the `data` directory via
2019-12-21 21:02:27 +00:00
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.
2021-02-25 07:57:10 +00:00
`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` .
2019-12-21 21:02:27 +00:00
2021-02-05 04:33:24 +00:00
## Documentation
2021-02-06 18:45:27 +00:00
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:
2021-02-05 04:33:24 +00:00
* Per-release [News ](NEWS.md ) for packagers, developers, and users.
* The `TERM` environment variable and [various terminal emulators ](TERMINALS.md ).
* Notes on [contributing ](doc/CONTRIBUTING.md ) and [hacking ](doc/HACKING.md ).
* There's a semi-complete [reference guide ](USAGE.md ).
* A list of [other TUI libraries ](doc/OTHERS.md ).
* Abbreviated [history ](doc/HISTORY.md ) and thanks.
2021-02-06 18:45:27 +00:00
* [Differences from ](doc/CURSES.md ) Curses and adapting Curses programs.
2019-12-14 12:23:49 +00:00
2021-04-29 22:01:59 +00:00
If you (understandably) want to avoid the large Pandoc stack, but still enjoy
manual page goodness, I publish a tarball with generated man/XHTML along with
each release. Download it, and install the contents as you deem fit.
2019-11-29 10:54:50 +00:00
## Environment notes
2020-06-16 08:13:49 +00:00
* If your `TERM` variable is wrong, or that terminfo definition is out-of-date,
2021-01-07 23:57:58 +00:00
you're going to have a very bad time. Use *only* `TERM` values appropriate
for your terminal. If this variable is undefined, or Notcurses can't load the
specified Terminfo entry, it will refuse to start, and you will
[not be going to space today ](https://xkcd.com/1133/ ).
2020-06-16 08:13:49 +00:00
2021-07-16 04:25:36 +00:00
* Notcurses queries the terminal on startup, enabling some advanced features
based on the determined terminal (and even version). Basic capabilities,
however, are taken from Terminfo. So if you have, say, Kitty, but
2021-09-08 05:37:56 +00:00
`TERM=vt100` , you're going to be able to draw RGBA bitmap graphics (despite
such things being but a dream for a VT100), but *unable* to use the alternate
screen (despite it being supported by every Kitty version). So `TERM` and an
up-to-date Terminfo database remain important.
2021-07-16 04:25:36 +00:00
2020-06-16 08:13:49 +00:00
* Ensure your `LANG` environment variable is set to a UTF8-encoded locale, and
that this locale has been generated. This usually means
`"[language]_[Countrycode].UTF-8"` , i.e. `en_US.UTF-8` . The first part
(`en_US`) ought exist as a directory or symlink in `/usr/share/locales` .
This usually requires editing `/etc/locale.gen` and running `locale-gen` .
2020-11-25 04:19:08 +00:00
On Debian systems, this can be accomplished with `dpkg-reconfigure locales` ,
2020-06-16 08:13:49 +00:00
and enabling the desired locale. The default locale is stored somewhere like
`/etc/default/locale` .
2019-11-29 10:54:50 +00:00
* If your terminal has an option about default interpretation of "ambiguous-width
characters" (this is actually a technical term from Unicode), ensure it is
2021-01-07 23:57:58 +00:00
set to **Wide** , not narrow (if that doesn't work, ensure it is set to
**Narrow** , heh).
2019-11-29 10:54:50 +00:00
2021-07-19 01:59:15 +00:00
* If your terminal supports 3x8bit RGB color via `setaf` and `setbf` (most
modern terminals), but exports neither the `RGB` nor `Tc` terminfo capability,
you can export the `COLORTERM` environment variable as `truecolor` or `24bit` .
Note that some terminals accept a 24-bit specification, but map it down to
fewer colors. RGB is unconditionally enabled whenever
[most modern terminals ](TERMINALS.md ) are identified.
2021-05-14 10:02:06 +00:00
2019-12-16 07:00:33 +00:00
### Fonts
2021-07-16 04:25:36 +00:00
Glyph width, and indeed whether a glyph can be displayed at all, is dependent
in part on the font configuration. Ideally, your font configuration has a
2021-10-28 00:42:01 +00:00
glyph for every Unicode EGC, and each glyph's width matches up with the POSIX
function's `wcswidth()` result for the EGC. If this is not the case, you'll
2021-07-16 04:25:36 +00:00
likely get blanks or <20> (U+FFFD, REPLACEMENT CHARACTER) for missing characters,
and subsequent characters on the line may be misplaced.
2019-12-18 10:02:02 +00:00
2020-12-03 06:57:23 +00:00
It is worth knowing that several terminals draw the block characters directly,
2021-07-16 04:25:36 +00:00
rather than loading them from a font. This is generally desirable. Quadrants
and sextants are not the place to demonstrate your design virtuosity. To
inspect your environment's rendering of drawing characters, run
`notcurses-info` . The desired output ought look something like this:
< p align = "center" >
< img src = "https://raw.githubusercontent.com/dankamongmen/notcurses/gh-pages/notcurses-info.png" alt = "notcurses-info can be used to check Unicode drawing" / >
< / p >
2020-12-03 06:57:23 +00:00
2021-06-20 14:13:31 +00:00
## FAQs
2019-12-18 10:02:02 +00:00
2020-06-25 05:27:14 +00:00
If things break or seem otherwise lackluster, **please** consult the
2021-10-28 00:42:01 +00:00
[Environment Notes ](#environment-notes ) section! You **need** correct
`TERM` and `LANG` definitions, and might want `COLORTERM` .
2020-06-25 05:27:14 +00:00
2021-10-28 01:00:07 +00:00
< details >
< summary > Can I use Notcurses in my closed-source program?< / summary >
Notcurses is licensed under < a href = "https://www.apache.org/licenses/LICENSE-2.0" > Apache2< / a > ,
a demonstration that I have transcended your petty world of material goods,
fiat currencies, and closed sources. Implement Microsoft Bob in it. Charge
rubes for it. Put it in your ballistic missiles so that you have a nice LED
display of said missile's speed and projected yield; right before impact,
scroll "FUCK YOU" in all the world's languages, and close it out with a smart
palette fade. Carve the compiled objects onto bricks and mail them to Richard
Stallman, taunting him through a bullhorn as you do so.
< / details >
2021-09-28 05:37:44 +00:00
< details >
< summary > Can I write a CLI program (scrolling, fits in with the shell, etc.)
with Notcurses?< / summary >
Yes! Use the flags < code > NCOPTION_NO_ALTERNATE_SCREEN< / code > ,
< code > NCOPTION_NO_CLEAR_BITMAPS< / code > , and < code > NCOPTION_PRESERVE_CURSOR< / code > ,
2021-10-28 00:36:07 +00:00
and call < code > ncplane_set_scrolling()< / code > on the standard plane. You
still must explicitly render.
2021-10-07 19:02:23 +00:00
< / details >
2021-07-11 08:21:17 +00:00
< details >
< summary > Can I have Notcurses without this huge multimedia stack?< / summary >
2021-09-28 05:37:44 +00:00
Again yes! Build with < code > -DUSE_MULTIMEDIA=none< / code > .
2021-07-11 08:21:17 +00:00
< / details >
< details >
< summary > Can I build this individual Notcurses program without aforementioned
multimedia stack?< / summary >
2021-09-28 05:37:44 +00:00
Almost unbelievably, yes! Use < code > notcurses_core_init()< / code > or
2021-07-11 08:21:17 +00:00
< code > ncdirect_core_init()< / code > in place of < code > notcurses_init()< / code > /
< code > ncdirect_init()< / code > , and link with < code > -lnotcurses-core< / code > .
Your application will likely start a few milliseconds faster;
more importantly, it will link against minimal Notcurses installations.
< / details >
2021-09-28 12:13:09 +00:00
< details >
< summary > We're paying by the electron, and have no C++ compiler. Can we still
enjoy Notcurses goodness?< / summary >
Some of it! You won't be able to build several binaries, nor the NCPP C++
wrappers, nor can you build with the OpenImageIO multimedia backend (OIIO
ships C++ headers). You'll be able to build the main library, though, as
2021-10-28 00:36:07 +00:00
well as < code > notcurses-demo< / code > (and maybe a few other binaries).
2021-09-28 12:13:09 +00:00
< / details >
2021-11-28 04:49:15 +00:00
< details >
< summary > Do I want ffmpeg or OpenImageIO?< / summary >
While OpenImageIO is a superb library for dealing with single-frame images,
its video support is less than perfect (blame me; I've been promising Larry
I'd rewrite it for several months), and in any case implemented
atop...ffmpeg. ffmpeg is the preferred multimedia backend.
< / details >
2021-09-12 07:25:37 +00:00
< details >
< summary > Does it work with hardware terminals?< / summary >
2021-10-28 00:36:07 +00:00
With the correct < code > TERM< / code > value, many hardware terminals are
supported. The VT100 is sadly unsupported due to its extensive need for
delays. In general, if the terminfo database entry indicates mandatory
delays, Notcurses will not currently support that terminal properly. It's
known that Notcurses can drive the VT320 and VT340, including Sixel graphics
on the latter.
2021-09-12 07:25:37 +00:00
< / details >
< details >
< summary > What happens if I try blitting bitmap graphics on a terminal which
doesn't support them?< / summary >
Notcurses will not make use of bitmap protocols unless the terminal positively
2021-10-28 00:36:07 +00:00
indicates support for them, even if < code > NCBLIT_PIXEL< / code > has been
requested. Likewise, sextants (< code > NCBLIT_3x2< / code > ) won't be used without
Unicode 13 support, etc. < code > ncvisual_blit()< / code > will use the best blitter
available, unless < code > NCVISUAL_OPTION_NODEGRADE< / code > is provided (in
which case it will fail).
2021-09-12 07:25:37 +00:00
< / details >
2021-07-11 08:21:17 +00:00
< details >
< summary > Notcurses looks like absolute crap in < code > screen< / code > .< / summary >
< code > screen< / code > doesn't support RGB colors (at least as of 4.08.00);
if you have < code > COLORTERM< / code > defined, you'll have a bad time.
If you have a < code > screen< / code > that was compiled with
< code > --enable-colors256< / code > , try exporting
< code > TERM=screen-256color< / code > as opposed to < code > TERM=screen< / code > .
< / details >
< details >
< summary > Notcurses looks like absolute crap in < code > mosh< / code > .< / summary >
Yeah it sure does. I'm not yet sure what's up.
< / details >
2021-08-24 08:00:36 +00:00
< details >
< summary > Notcurses looks like absolute crap in Windows Terminal.< / summary >
2021-10-28 01:00:07 +00:00
Go to < a href = "ms-settings:regionlanguage" > Language Setting< / a > , click
"Administrative language settings", click "Change system locale", and check
the "Beta: Use Unicode UTF-8 for worldwide language support" option. Restart
2021-12-06 06:58:56 +00:00
the computer. That ought help a little bit. Try playing with fonts—Cascadia
Code and Cascadia Mono both seem to work well (quadrants and Braille both
work), whereas Consolas and Courier New both have definite problems.
2021-08-24 08:00:36 +00:00
< / details >
2021-07-11 08:21:17 +00:00
< details >
2021-10-16 12:19:26 +00:00
< summary > I'm getting strange and/or duplicate inputs in Kitty.< / summary >
2021-10-28 00:42:01 +00:00
Notcurses supports Kitty's powerful
< a href = "https://sw.kovidgoyal.net/kitty/keyboard-protocol/" > keyboard protocol< / a > ,
2021-10-16 12:19:26 +00:00
which includes things like key release events and modifier keypresses by
themselves. This means, among other things, that a program in Kitty will
2021-10-28 00:36:07 +00:00
usually immediately get an < code > NC_ENTER< / code > < code > NCTYPE_RELEASE< / code >
event, and each keypress will typically result in at least two inputs.
2021-10-16 12:19:26 +00:00
< / details >
< details >
< summary > Why didn't you just render everything to bitmaps?< / summary >
2021-07-11 08:21:17 +00:00
That's not a TUI; it's a slow and inflexible GUI. Many terminal emulators
2021-10-16 12:19:26 +00:00
don't support bitmaps. They doesn't work well with mouse selection.
Sixels have a limited color palette. With that said, both Sixel and the
2021-07-11 08:21:17 +00:00
Kitty bitmap protocol are well-supported.
< / details >
< details >
2021-10-28 01:00:07 +00:00
< summary > My multithreaded program doesn't see < code > NCKEY_RESIZE< / code > until
I press some other key.< / summary >
2021-07-11 08:21:17 +00:00
You've almost certainly failed to mask < code > SIGWINCH< / code > in some thread,
and that thread is receiving the signal instead of the thread which called
< code > notcurses_getc_blocking()< / code > . As a result, the < code > poll()< / code >
is not interrupted. Call < code > pthread_sigmask()< / code > before spawning any
threads.
< / details >
< details >
< summary > Using the C++ wrapper, how can I ensure that the < code > NotCurses< / code >
destructor is run when I return from < code > main()< / code > ?< / summary >
As noted in the
< a href = "https://isocpp.org/wiki/faq/dtors#artificial-block-to-control-lifetimes" >
C++ FAQ< / a > , wrap it in an artificial scope (this assumes your
< code > NotCurses< / code > is scoped to < code > main()< / code > ).
< / details >
< details >
< summary > How do I hide a plane I want to make visible later?< / summary >
In order of least to most performant: move it offscreen using
< code > ncplane_move_yx()< / code > , move it underneath an opaque plane with
< code > ncplane_move_below()< / code > , or move it off-pile with
< code > ncplane_reparent()< / code > .
< / details >
< details >
< summary > Why isn't there an < code > ncplane_box_yx()< / code > ? Do you hate
orthogonality, you dullard?< / summary > < code > ncplane_box()< / code > and friends
already have far too many arguments, you monster.
< / details >
< details >
< summary > Why doesn't Notcurses support 10- or 16-bit color?< / summary >
Notcurses supports 24 bits of color, spread across three eight-bit channels.
You presumably mean 10-bit-per-channel color. I needed those six bits for
other things. When terminals support it, Notcurses might support it.
< / details >
< details >
< summary > The name is dumb.< / summary >
That's not a question?
< / details >
< details >
< summary > I'm not finding qrcodegen on BSD, despite having installed
< code > graphics/qr-code-generator< / code > .< / summary >
Try < code > cmake -DCMAKE_REQUIRED_INCLUDES=/usr/local/include< / code > .
This is passed by < code > bsd.port.mk< / code > .
< / details >
< details >
< summary > Do you support < a href = "https://musl.libc.org/" > musl< / a > ?< / summary >
I try to! You'll need at least 1.20.
< / details >
< details >
< summary > I only seem to blit in ASCII, and/or can't emit Unicode beyond ASCII
in general.< / summary >
Your < code > LANG< / code > environment variable is underdefined or incorrectly
defined, or the necessary locale is not present on your machine (it is also
possible that you explicitly supplied < code > NCOPTION_INHIBIT_SETLOCALE< / code > ,
but never called < code > setlocale(3)< / code > , in which case don't do that).
< / details >
< details >
< summary > I pretty much always need an < code > ncplane< / code > when using a
< code > nccell< / code > . Why doesn't the latter hold a pointer to the former?
< / summary >
Besides the massive redundancy this would entail, < code > nccell< / code > needs to
remain as small as possible, and you almost always have the < code > ncplane< / code >
handy if you've got a reference to a valid < code > nccell< / code > anyway.
< / details >
2021-11-25 21:42:14 +00:00
< details >
< summary > I compiled with AddressSanitizer, and ASAN throws an exception on
program exit.< / summary >
Yeah, I think it has something to do with our signal handling, don't know
yet, sorry.
< / details >
< details >
< summary > I ran my Notcurses program under < code > valgrind< / code > /ASAN, and
it shows memory leaks from < code > libtinfo.so< / code > , what's up with that?< / summary >
Yeah, the NCURSES Terminfo leaks memory unless compiled a special,
non-standard way (see the NCURSES FAQ). It shouldn't be a substantial amount;
you're advised not to worry overmuch about it.
2021-11-28 16:34:34 +00:00
< / details >
2021-07-11 08:21:17 +00:00
< details >
< summary > I ran < code > notcurses-demo< / code > , but my table numbers don't match
the Notcurses banner numbers, you charlatan.< / summary >
< code > notcurses-demo< / code > renders several frames beyond the actual demos.
< / details >
< details >
< summary > When my program exits, I don't have a cursor, or text is invisible,
or colors are weird, < i > ad nauseam< / i > .< / summary >
Ensure you're calling < code > notcurses_stop()< / code > /< code > ncdirect_stop()< / code >
on all exit paths, including fatal signals (note that, by default, Notcurses
installs handlers for most fatal signals to do exactly this).
< / details >
< details >
< summary > How can I use Direct Mode in conjunction with libreadline?< / summary >
2021-09-28 05:37:44 +00:00
You can't anymore (you could up until 2.4.1, but the new input system is
2021-10-28 00:36:07 +00:00
fundamentally incompatible with it). < code > ncdirect_readline()< / code > still exists,
2021-09-28 05:37:44 +00:00
though, and now actually works even without libreadline, though it is of
course not exactly libreadline. In any case, you'd probably be better off
using CLI mode with a < code > ncreader< / code > .
< / details >
< details >
< summary > So is Direct Mode deprecated or what?< / summary >
It is not currently deprecated, and definitely receives bugfixes. You are
probably better served using CLI mode (see above), which came about
somewhat late in Notcurses development (the 2.3.x series), but is superior
to Direct Mode in pretty much every way. The only reason to use Direct
Mode is if you're going to have other programs junking up your display.
2021-07-11 08:21:17 +00:00
< / details >
2021-09-28 05:37:44 +00:00
< details >
< summary > Direct Mode sounds fast! Since it's, like, direct.< / summary >
Direct mode is < i > substantially slower< / i > than rendered mode. Rendered
mode assumes it knows what's on the screen, and uses this information to
generate optimized sequences of escapes and glyphs. Direct mode writes
everything it's told to write. It is furthermore far less capable—all
widgets etc. are available only to rendered mode, and will definitely
not be extended to Direct Mode.
2021-10-07 19:03:02 +00:00
< / details >
2021-09-28 05:37:44 +00:00
2021-07-11 08:21:17 +00:00
< details >
< summary > Will there ever be Java wrappers?< / summary >
2021-12-01 23:25:11 +00:00
I should hope not. If you want a Java solution, try @klamonte 's
2021-10-28 05:26:55 +00:00
< a href = "https://jexer.sourceforge.io/" > Jexer< / a > . Autumn's a good
woman, and thorough. We seem to have neatly partitioned the language
space.
2021-07-11 08:21:17 +00:00
< / details >
< details >
< summary > Given that the glyph channel is initialized as transparent for a
plane, shouldn't the foreground and background be initialized as transparent,
also?< / summary >
2021-07-13 06:45:01 +00:00
Probably (they are instead by default initialized to opaque). This would change
2021-07-11 08:21:17 +00:00
some of the most longstanding behavior of Notcurses, though,
so it isn't happening.
< / details >
< details >
< summary > I get linker errors when statically linking.< / summary >
Are you linking all necessary libraries? Use
< code > pkg-config --static --libs notcurses< / code >
(or < code > --libs notcurses-core< / code > ) to discover them.
< / details >
2021-10-08 02:47:34 +00:00
< details >
2021-10-09 06:12:28 +00:00
< summary > Notcurses exits immediately in MSYS2/Cygwin.< / summary >
2021-10-28 00:42:01 +00:00
Notcurses requires the
< a href = "https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/" > Windows ConPTY< / a >
2021-10-08 02:47:34 +00:00
layer. This is available in Cygwin by default since 3.2.0, but is disabled
2021-10-28 00:36:07 +00:00
by default in MSYS. Launch < code > mintty< / code > with < code > -P on< / code >
arguments, or export < code > MSYS=enable_pcon< / code > before launching it.
2021-10-08 02:47:34 +00:00
< / details >
2021-07-11 08:21:17 +00:00
< details >
< summary > Can I avoid manually exporting < code > COLORTERM=24bit< / code >
everywhere?< / summary >
Sure. Add < code > SendEnv COLORTERM< / code > to < code > .ssh/config< / code > , and
< code > AcceptEnv COLORTERM< / code > to < code > sshd_config< / code > on the remote
server. Yes, this will probably require root on the remote server.
Don't blame me, man; I didn't do it.
< / details >
< details >
2021-10-28 01:00:07 +00:00
< summary > How about < i > arbitrary image manipulation here< / i > functionality?< / summary >
2021-07-11 08:21:17 +00:00
I'm not going to beat ImageMagick et al. on image manipulation, but you can
load an < code > ncvisual< / code > from RGBA memory using
< code > ncvisual_from_rgba()< / code > .
< / details >
< details >
< summary > My program locks up during initialization. < / summary >
Notcurses interrogates the terminal. If the terminal doesn't reply to standard
interrogations, file a Notcurses bug, send upstream a patch, or use a different
terminal. No known terminal emulators exhibit this behavior.
< / details >
< details >
< summary > Why no < code > NCSTYLE_REVERSE< / code > ?< / summary >
It would consume a precious bit. You can use < code > ncchannels_reverse()< / code >
to correctly invert fore- and background colors.
< / details >
< details >
< summary > How do I mix Rendered and Direct mode?< / summary >
You really don't want to. You can stream a subprocess to a plane with the
< code > ncsubproc< / code > widget.
< / details >
< details >
< summary > How can I clear the screen on startup in Rendered mode when not using
the alternate screen?< / summary >
Call < code > notcurses_refresh()< / code > after < code > notcurses_init()< / code >
returns successfully.
< / details >
2021-07-10 23:51:12 +00:00
2021-07-21 21:41:32 +00:00
< details >
< summary > Why do the stats show more Linux framebuffer bitmap bytes written
2021-10-31 11:17:25 +00:00
than total bytes written to the terminal? And why don't Linux console
graphics work when I ssh?< / summary >
Linux framebuffer graphics aren't implemented via terminal writes, but rather
writes directly into a memory map. This memory map isn't available on remote
machines, and these writes aren't tracked by the standard statistics.
2021-07-21 21:41:32 +00:00
< / details >
2021-11-30 07:41:46 +00:00
< details >
< summary > What is the possessive form of Notcurses?< / summary >
2021-11-30 07:45:07 +00:00
< b > Notcurses'.< / b > I cite < a href = "https://en.wikipedia.org/wiki/Garner%27s_Modern_English_Usage" >
Garner's Modern English Usage< / a > in its third edition: "< b > POSSESSIVES. A. Singular
Possessives.< / b > …Biblical and Classical names that end with a /zəs/ or /eez/
sound take only the apostrophe." Some ask: is Notcurses then Biblical, or is it
Classical? Truly, it is both.
2021-11-30 07:41:46 +00:00
< / details >
2021-11-28 08:05:43 +00:00
< details >
< summary > I just want to display a bitmap on my terminal. Your library is
complex and stupid. You are simple and stupid.< / summary >
If you're willing to call a binary, use < tt > ncplayer< / tt > to put an image,
with desired scaling, anywhere on the screen and call it a day. Otherwise,
call < tt > notcurses_init()< / tt > , < tt > ncvisual_from_file()< / tt > ,
< tt > ncvisual_blit()< / tt > , < tt > notcurses_render()< / tt > , and
< tt > notcurses_stop()< / tt > . It's not too tough. And thanks—your thoughtful
comments and appreciative tone are why I work on Free Software.
< / details >
2021-02-05 04:33:24 +00:00
## Useful links
2019-11-29 03:08:26 +00:00
* [BiDi in Terminal Emulators ](https://terminal-wg.pages.freedesktop.org/bidi/ )
* [The Xterm FAQ ](https://invisible-island.net/xterm/xterm.faq.html )
2019-12-23 03:45:20 +00:00
* [XTerm Control Sequences ](https://invisible-island.net/xterm/ctlseqs/ctlseqs.pdf )
2019-11-29 03:08:26 +00:00
* [The NCURSES FAQ ](https://invisible-island.net/ncurses/ncurses.faq.html )
* [ECMA-35 Character Code Structure and Extension Techniques ](https://www.ecma-international.org/publications/standards/Ecma-035.htm ) (ISO/IEC 2022)
* [ECMA-43 8-bit Coded Character Set Structure and Rules ](https://www.ecma-international.org/publications/standards/Ecma-043.htm )
* [ECMA-48 Control Functions for Coded Character Sets ](https://www.ecma-international.org/publications/standards/Ecma-048.htm ) (ISO/IEC 6429)
2021-10-20 09:19:30 +00:00
* [Unicode 14.0 Full Emoji List ](https://unicode.org/emoji/charts/full-emoji-list.html )
2019-12-02 15:39:48 +00:00
* [Unicode Standard Annex #29 Text Segmentation ](http://www.unicode.org/reports/tr29 )
2019-11-29 03:08:26 +00:00
* [Unicode Standard Annex #15 Normalization Forms ](https://unicode.org/reports/tr15/ )
2021-06-25 00:06:09 +00:00
* [mintty tips ](https://github.com/mintty/mintty/wiki/Tips )
2019-11-29 09:57:09 +00:00
* [The TTY demystified ](http://www.linusakesson.net/programming/tty/ )
2019-12-14 10:33:34 +00:00
* [Dark Corners of Unicode ](https://eev.ee/blog/2015/09/12/dark-corners-of-unicode/ )
* [UTF-8 Decoder Capability and Stress Test ](https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt )
2020-06-05 08:19:56 +00:00
* [Emoji: how do you get from U+1F355 to 🍕? ](https://meowni.ca/posts/emoji-emoji-emoji/ )
2020-06-16 22:48:51 +00:00
* [Glyph Hell: An introduction to glyphs, as used and defined in the FreeType engine ](http://chanae.walon.org/pub/ttf/ttf_glyphs.htm )
2021-07-11 13:55:37 +00:00
* [Text Rendering Hates You ](https://gankra.github.io/blah/text-hates-you/ )
2021-11-18 09:02:09 +00:00
* [Use the UTF-8 code page ](https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page )
2021-03-24 18:49:43 +00:00
* My wiki's [Sixel page ](https://nick-black.com/dankwiki/index.php?title=Sixel ) and Kitty's [extensions ](https://sw.kovidgoyal.net/kitty/protocol-extensions.html ).
2021-07-31 11:36:24 +00:00
* Linux man pages: [console_codes(4) ](http://man7.org/linux/man-pages/man4/console_codes.4.html ), [termios(3) ](http://man7.org/linux/man-pages/man3/termios.3.html ), [ioctl_tty(2) ](http://man7.org/linux/man-pages/man2/ioctl_tty.2.html ), [ioctl_console(2) ](http://man7.org/linux/man-pages/man2/ioctl_console.2.html )
* The Microsoft Windows [Console Reference ](https://docs.microsoft.com/en-us/windows/console/console-reference )
* NCURSES man pages: [terminfo(5) ](http://man7.org/linux/man-pages/man5/terminfo.5.html ), [user_caps(5) ](http://man7.org/linux/man-pages/man5/user_caps.5.html )
2019-12-23 03:45:20 +00:00
2019-12-13 18:00:29 +00:00
> “Our fine arts were developed, their types and uses were established, in times
very different from the present, by men whose power of action upon things was
insignificant in comparison with ours. But the amazing growth of our
techniques, the adaptability and precision they have attained, the ideas and
habits they are creating, make it a certainty that _profound changes are
2019-12-14 23:44:04 +00:00
impending in the ancient craft of the Beautiful_.” —Paul Valéry