Skip to content

a-n-t-h-o-n-y/TermOx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TermOx II 🐂🐂

TermOx is a C++20 library for creating rich, interactive terminal user interfaces with minimal code.

Quick Example

#include <ox/ox.hpp>
using namespace ox;

int main()
{
    auto head = Label{{
                    .text  = "C++20 Terminal UI Framework",
                    .align = Align::Center,
                    .brush = {.foreground = XColor::Blue, .traits = Trait::Bold},
                }} | Border{.box = shape::Box::round(), .label = "TermOx II"};

    return Application{head}.run();
}

📂 Explore more in the examples directory.

Use scratch.cpp and the TermOx.examples.scratch build target to try out the library quickly.

Features

Core Capabilities

  • Flexible Layout System - Size policies and automatic sizing
  • Event-Driven Architecture - Clean handling of user input and system events
  • Signal/Slot System - Based on Signals Light
  • Timer Support - Periodic actions with timer events
  • Custom Widgets - Create your own widgets with ease

Rich Terminal Styling

  • Colors - Full RGB, HSL, and XTerm 256 Color support
  • Text Styling - Bold, italic, underline, strikethrough, and more
  • Unicode Support - Wide character and multi-byte encoding compatibility

Input Handling

  • Keyboard - Key press/release events, modifiers, and special keys
  • Mouse - Click, scroll, movement, and enter/leave events
  • Focus Management - Tab navigation, mouse click, and focus events

Widget Library

  • Core Widgets - Labels, buttons, text inputs, checkboxes, radio buttons, data tables and more
  • Layout Widgets - Horizontal, vertical, and suspended layouts

Build Instructions

TermOx uses CMake to generate build targets.

git clone https://github.com/a-n-t-h-o-n-y/TermOx.git
mkdir TermOx/build && cd TermOx/build
cmake ..
make TermOx

Dependencies (Signals Light, zzz, and Escape) are automatically fetched by CMake.

Note on Version 2

Version 2 is a complete rewrite of the library. It focuses on providing a simpler set of base widgets and a light-weight core implementation of events processing and rendering. As such, the API has little in common with the previous version.

A Second Example

#include <ox/ox.hpp>
using namespace ox;

// Counter Button + Label
int main()
{
    auto counter = Row{
        IntegerLabel{{
            .value = 0,
            .align = Align::Center,
            .brush = {.background = XColor::White, .foreground = XColor::Black},
        }},
        Button{{
            .text = "Click to Increment",
            .align = Align::Center,
            .brush = {.background = XColor::Black,
                      .foreground = XColor::White,
                      .traits = Trait::Bold},
            .press_mod = [](Label& l) { l.brush.foreground = XColor::Yellow; },
        }},
    };

    auto& [label, button] = counter.children;

    // Signals and Slots
    Connection{
        .signal = button.on_press,
        .slot = [](IntegerLabel& l) { ++l.value; },
    }(label);

    return Application{counter}.run();
}

Gallery

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

C++20 Terminal User Interface (TUI) Library.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 10