Skip to content

Repository files navigation

nctui - C++20 Terminal UI Framework

This is an Text User Interface (TUI) framework which provides a rich set of widgets for building sophisticated text-based user interfaces in the terminal. This framework leverages notcurses for rendering.

It is a C++20 port of a Terminal UI framework originally created for the Mono project as part of MonoCurses by Miguel de Icaza (see his original blog post). Later it was - still using ncurses - ported to D.

Overview

nctui is a C++20 module-based framework. It offers:

  • Module-based architecture using C++20's module system
  • Comprehensive widget library including buttons, labels, text entries, dialogs, menus, and more
  • Event-driven input handling with keyboard and mouse support
  • Main loop integration for application lifecycle management
  • Container-based layout system for building complex UIs

Features

Widgets

WidgetDescription
ButtonClickable button with customizable text
LabelStatic text display
TrimLabelLabel with automatic text trimming
DocbrowserAsciiDoc document browser
CheckboxToggleable checkbox
EntrySingle-line text input
ComboboxMulti-select that shows selection
TextViewMulti-line text display and editing
ListViewScrollable list of items
ProgressBarVisual progress indicator
FrameContainer with border and title
DialogModal dialog windows
MessageBoxPre-configured message dialogs
MenuBarDrop-down menu system
RadioGroupGroup of mutually exclusive radio buttons
ContainerBase class for custom widget containers

Requirements

  • C++20 compliant compiler (GCC 11+, Clang 14+, MSVC 19.29+)
  • notcurses (via notcurses++ C++ bindings)
  • xmake build system

Quick Start

Building

The project uses xmake as its build system:

# Install dependencies (notcurses and notcurses++)# On Ubuntu/Debian:
sudo apt-get install libnotcurses-dev notcurses++-dev
# Build the library and examples
xmake
# Run a specific example
xmake run simple_example
xmake run mainloop_example
xmake run menu_example
xmake run tui_example

Examples

The examples/ directory contains several examples demonstrating various features of nctui:

ExampleDescriptionWidgets Used
simple.cppMinimal nctui application showing basic widget usageContainer, Label, Entry
mainloop.cppDemonstrates the MainLoop class with timer-based eventsMainLoop (no UI widgets)
menu.cppShows a menu bar with drop-down menus and a read-only text viewerMenuBar, MenuBarItem, MenuItem, Frame, TextView, Dialog, DocBrowser, Button
tui.cppFull torrent-manager-style TUI with resizable multi-pane layoutContainer, Frame, Button, ListView, Label, TrimLabel, ProgressBar, Entry, RadioGroup, ComboBox, Dialog, plus custom LogWidget

Menu example

Example Highlights

  • simple.cpp: Perfect starting point. Creates a container with a label and an editable entry field.
  • mainloop.cpp: Demonstrates timer management with addTimeout() for scheduled callbacks.
  • menu.cpp: Features a complete menu system with File (Exit) and Help (About, Index) menus. The Index menu opens a DocBrowser dialog to view AsciiDoc documentation, and this README.md is displayed in a read-only TextView in the main window.
  • tui.cpp: A comprehensive demo showcasing advanced features including:
    • Multi-pane layout with draggable resizable frames
    • Status panel with ProgressBar and multiple Label widgets
    • Options dialog with Entry fields, RadioGroup, and ComboBox for theme selection
    • Live theme switching with preview
    • Input validation for dialog fields
    • Custom LogWidget demonstrating how to create custom widgets
    • Timer-based status updates and logging
    • Add dialog for file selection with validation

TUI example

For detailed usage information, module imports, input handling, focus management, dialogs, and menu system documentation, please refer to the AsciiDoc documentation in the docs/ folder.

Documentation

The docs/ directory contains comprehensive AsciiDoc documentation covering:

  • Usage: Project setup, module imports, and requirements
  • Widgets: Complete widget reference with examples
  • Input Handling: Key processing phases and hot keys
  • Focus Management: Widget focus and navigation
  • Dialogs: Message boxes and dialog widgets
  • Menu System: Menu bar and drop-down menus
  • Themes: Color themes and styling

License

MIT License - see project root for full text.

Contributing

Contributions are welcome! Please ensure:

  • Code follows the existing style and conventions
  • C++20 features are used appropriately
  • Module interfaces are clean and well-organized

About

C++20 notcurses TUI toolkit module

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages