Skip to content

TheRebuild/rebuildTUI

Repository files navigation

rebuildTui (TUI for Rebuild Tool) [WIP]

Simple, cross-platform text-based user interface (TUI) library. Initially created for Rebuild Tool, but also suitable for other applications.

Key Features

  • Easy to use: This library provides a Fluent-like builder for quick setup and customization
  • Customizable Themes: Multiple built-in themes + custom styling (real custom theming will be implemented soon)
    • Including Gradient support, Accent colors
  • Keyboard Navigation: Intuitive controls with vim-style shortcuts (note: vim-style shortcuts are optional and you should enable them)
  • Custom handlers: You can write a function to control user interactions
  • Smart Pagination: Automatic pagination with specified limits
  • Compatibility: Works on Windows and Linux (macOS support will be added later)
  • Other: Built-in counters and selection management

Dependencies

  • Cmake 3.20+
  • С++23 and later (Note: C++20 will add once I don't be a lazy af and will combine with fmt and format (std) libraries)

Quick Start

Basic Example

#include "rebuildTUI/navigation_tui.hpp"
#include "rebuildTUI/section_builder.hpp"

using namespace tui;

int main() {
    auto graphics = SectionBuilder("Graphics Settings")
        .add_item("Enable VSync")
        .add_item("Anti-Aliasing")
        .add_item("Motion Blur")
        .build();

    auto audio = SectionBuilder("Audio Settings")
        .add_items({"Master Volume", "Sound Effects", "Music Volume"})
        .select_items({"Master Volume"}) // Pre-select items
        .build();

    // Build the TUI interface
    auto tui = NavigationBuilder()
        .text_titles("🎮 Game Settings", "⚙️ Configure: ")
        .theme_modern()
        .layout_centered()
        .add_section(graphics)
        .add_section(audio)
        .build();

    // Run the interface
    tui->run();

    // Get user selections
    auto selections = tui->get_all_selections();
    for (const auto& [section_name, items] : selections) {
        std::cout << section_name << ":\n";
        for (const auto& item : items) {
            std::cout << "" << item << "\n";
        }
    }

    return 0;
}

Build Instructions & Integration

Manual build

git clone https://github.com/TheRebuild/rebuildTUI

cd rebuildTUI && mkdir build && cd build && cmake ..
cmake --build .

./test_tui

Header-Only Integration (applies for manual build)

#include "rebuildTUI/navigation_tui.hpp"
#include "rebuildTUI/section_builder.hpp"
#include "rebuildTUI/styles.hpp" // access to tui_extras namespace (accent color and gradient support)

CMake Integration

Latest (development)
include(FetchContent)

FetchContent_Declare(
        rebuildtui
        GIT_REPOSITORY https://github.com/TheRebuild/rebuildtui.git
        GIT_TAG main
        GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(rebuildtui)

add_executable(example_app main.cpp)
target_link_libraries(example_app PRIVATE rebuildTUI::rebuildTUI)
Stable
include(FetchContent)

FetchContent_Declare(
        rebuildtui
        GIT_REPOSITORY https://github.com/TheRebuild/rebuildtui.git
        GIT_TAG v0.0.6
)

FetchContent_MakeAvailable(rebuildtui)

add_executable(example_app main.cpp)
target_link_libraries(example_app PRIVATE rebuildTUI::rebuildTUI)

Examples

Check out the example files:

  • test_tui.cpp - UI Example
  • state_saving_demo.cpp - Example of UI + saving state
  • system_info - System Info (hardcoded)
  • theme_customizing.cpp - Available themes in UI and more

Contributing

Soon...

License

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

About

Simple text-based user interface (TUI) library

Resources

License

Stars

Watchers

Forks

Packages

No packages published