App
#include <App.hpp>The main application class that manages the TUI event loop and rendering.
App is the entry point for a Vextr application. It manages:
-
The root widget and widget tree
-
The event loop (input handling, rendering, layout)
-
Terminal initialization and rendering
-
Focus management
Typical usage:
auto app = std::make_unique<App>();auto root = std::make_shared<Container>();// ... add widgets to rootapp->setRoot(root);app->run(); // blocks until quit() is calledPublic Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
backend::Renderer | renderer | Manages rendering output to the terminal. Provides methods to draw to the screen. |
std::function< bool(const core::events::Event &)> | quitEvent | Predicate that decides whether an event should quit the app. Default: Ctrl+C. |
utils::InputReader | inputReader | |
utils::InputParser | inputParser | |
int | escapeTimer |
renderer
Section titled “renderer”backend::Renderer rendererManages rendering output to the terminal. Provides methods to draw to the screen.
quitEvent
Section titled “quitEvent”std::function< bool(const core::events::Event &)> quitEvent = [](/api/const &e) { if (auto *k = std::get_if<>(&e)) { return k->key == 'c' && k->modifiers.ctrl; } return false; }Predicate that decides whether an event should quit the app. Default: Ctrl+C.
inputReader
Section titled “inputReader”utils::InputReader inputReaderinputParser
Section titled “inputParser”utils::InputParser inputParserescapeTimer
Section titled “escapeTimer”int escapeTimer = 0Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
App | Creates a new App instance and initializes the terminal. | |
~App | Destroys the App and restores the terminal. | |
void | setRoot | Sets the root widget of the application. |
void | run | Starts the event loop and blocks until quit() is called. |
void | quit inline | Stops the event loop and exits run(). |
App()Creates a new App instance and initializes the terminal.
~App()Destroys the App and restores the terminal.
setRoot
Section titled “setRoot”void setRoot(std::shared_ptr< core::Widget > root)Sets the root widget of the application.
The root widget and its children form the widget tree that will be rendered and receive input events. This must be called before run().
Parameters
Section titled “Parameters”rootThe root widget. Must not be null.
void run()Starts the event loop and blocks until quit() is called.
This initializes the terminal, then repeatedly:
-
Polls for input events
-
Processes them through the widget tree
-
Measures and lays out widgets
-
Renders to the terminal
inline
inline void quit()Stops the event loop and exits run().
Can be called from input handlers or callbacks to stop the application.
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
std::shared_ptr< core::Widget > | root | |
backend::Terminal | terminal | |
std::unique_ptr< backend::Buffer > | buffer | |
core::Size | currentSize | |
bool | running | |
bool | needsRedraw |
std::shared_ptr< core::Widget > rootterminal
Section titled “terminal”backend::Terminal terminalbuffer
Section titled “buffer”std::unique_ptr< backend::Buffer > buffercurrentSize
Section titled “currentSize”core::Size currentSize = {0, 0}running
Section titled “running”bool running = falseneedsRedraw
Section titled “needsRedraw”bool needsRedraw = falsePrivate Methods
Section titled “Private Methods”| Return | Name | Description |
|---|---|---|
void | tick | |
void | handleResize |
void tick()handleResize
Section titled “handleResize”void handleResize()