croatoan

Description

croatoan is a set of bindings to the ncurses terminal / console library for Common Lisp.

It allows easy creation of simple text-based GUI interfaces in the terminal / console.

It is inspired by, but not derived from similar libraries cl-ncurses and cl-charms.

Its main goal is to provide a higher-level, lispy/CLOSy interface, whereas the existing bindings clone the cryptic C API.

As of today (10/2024), the library is in active development and an hopefully usable stage. Ncurses is old and huge and it will take a while to cover completely. The API is not yet fully stable.

It was last tested on Linux x86_64, Ubuntu 20.04, SBCL 2.4.0, ncurses 6.5. More testing is needed on implementations other than SBCL and operating systems other than Ubuntu.

It is available on quicklisp since october 2014 an can be easily installed by calling (ql:quickload :croatoan)

Example

The basic functionality is shown in the following example:

(in-package :croatoan) (defun test1 () (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t) (clear scr) (move scr 2 0) (format scr "Type chars. Type q to quit.~%~%") (refresh scr) (setf (color-pair scr) '(:yellow :red) (attributes scr) '(:bold)) (event-case (scr event) (#\q (return-from event-case)) (otherwise (princ event scr) (refresh scr)))))

The macro with-screen is the main entry point. It creates the main output window called screen, and passes init options to it.

We now can clear the screen, move the cursor (to the third row and first column), output text at cursor position, set foreground and background colors, text attributes or catch keyboard and mouse events with the macro event-case. Every change to the screen is only displayed after an explicit call to refresh.

Further documentation on features like windows, menus, mouse and input and output options is provided by the docstrings on quickdocs [2], on quickref [3] and in the included examples.

Links

[1] https://codeberg.org/McParen/croatoan - croatoan Git repository at Codeberg

[2] http://quickdocs.org/croatoan/ - croatoan api documentation at quickdocs

[3] http://quickref.common-lisp.net/croatoan.html - croatoan api documentation at quickref

[4] Screenshot: Menus and 256 color support

[5] Screenshot: Dialogs and forms

[6] Video: Evolution from Land Of Lisp, Chapter 10

[7] Tinmop - An opinionated client for Gemini, gopher, kami and Mastodon/Pleroma

[8] cl-netstat - A curses tool to visualize network traffic

[9] gIRC - a basic IRC client for the terminal.

[10] https://packages.guix.gnu.org/packages/sbcl-croatoan - Guix package