Home

Awesome

Notcurses Clojure example

Notcurses is a moderm library for building terminal UIs with advanced graphics support. This is a demo showing how to use it with Clojure.

Bindings are generated with SWIG and compiled using Zig (any C compiler could be used, but I find Zig easiest to use because it includes powerful yet simple build system instead of relying on additional complex tools). GraalVM native-image is used to compile it to a binary executable.

Notcurses demo

Tested on Linux, might require some tweaks to run on macOS. Please let me know or open a PR if you get the demo running on macOS.

Dependencies

Pull in Notcurses source code

Since packaged versions of Notcurses are often outdated, we pull and build it from source:

git clone https://github.com/dankamongmen/notcurses.git deps/notcurses
cd deps/notcurses
git checkout v3.0.9 # latest release at the time of writing
mkdir build && cd build
cmake -DUSE_MULTIMEDIA=none -DUSE_QRCODEGEN=off -DUSE_PANDOC=off -DUSE_DOCTEST=off ..
# We just need `cmake` to generate some headers, no need to actually `make` since rest will be handled by Zig.

Build and run

Build everything with:

scripts/compile

Run the binary:

target/demo

With the bindings compiled demo can be also run with the Clojure CLI:

clojure -Mnative -m demo.main

Limitations

Related

See also the demo implemented in Zig.

License

Dual-licensed under MIT or the Unlicense.

Includes Native Utils licensed under MIT.