UIRuntime class
#include <nxtio/app.hpp>
Runtime state for the UI system. Owns scheduler, glyph table, compositor, and coordinates signals/events.
Constructors, destructors, conversion operators
Public functions
- void cleanup()
- Clean up before exit - clears HUD region.
- auto compositor() → TerminalCompositor& noexcept
- Direct access to compositor (for testing or advanced use).
-
auto damage_event() → nxt::
event& noexcept - Event signaled when damage occurs.
-
auto get_stop_token() const → std::
stop_token noexcept - Stop token tied to runtime shutdown.
- auto glyphs() → GlyphTable& noexcept
- Access the glyph table.
- auto has_terminal_surface() const → bool noexcept
-
auto input_channel() → nxt::
queue<nxt:: input:: KeyEvent>& noexcept - Channel for keyboard input events.
-
auto input_loop() → nxt::
task - Coroutine that reads stdin and publishes decoded keyboard events.
-
auto next_input() → nxt::
task<std:: optional<nxt:: input:: KeyEvent>> - auto operator=(const UIRuntime&) → UIRuntime& deleted
- auto operator=(UIRuntime&&) → UIRuntime& deleted
-
void print(std::
string_view text) -
void println(std::
string_view line) -
template <typename Layout>void render(const Layout& layout)
- void request_shutdown()
- Request shutdown.
-
auto resize_channel() → nxt::
queue<TermSize>& noexcept - Channel for resize notifications.
-
template <typename... Tasks>auto run(Tasks && ... tasks) → auto
- Schedule tasks on the runtime scheduler and await all of them.
-
template <typename BuildUI>auto run_render_loop(BuildUI build_ui, std::
chrono:: milliseconds frame_time = std:: chrono:: milliseconds{ 16}) → nxt:: task -
auto scheduler() → nxt::
scheduler& noexcept - Access the scheduler.
-
auto scheduler_handle() → std::
unique_ptr<nxt:: scheduler>& noexcept - Access the scheduler owner for libcoro networking APIs.
-
auto shutdown_after(nxt::
task<> t) → nxt:: task - Run a task, then request shutdown when it completes.
- auto shutdown_requested() const → bool noexcept
- Check if shutdown has been requested.
- void signal_damage()
- Signal that the view has been damaged and needs redraw.
-
auto signal_loop() → nxt::
task -
template <class rep_type, class period_type>auto sleep(std::
chrono:: duration<rep_type, period_type> duration) → nxt:: task - Sleep on the runtime scheduler.
-
auto terminal_height() const → height_
t noexcept - auto terminal_size() const → TermSize noexcept
- Current terminal dimensions.
-
auto terminal_width() const → width_
t noexcept
Function documentation
nxt:: task<std:: optional<nxt:: input:: KeyEvent>> nxt:: ui:: UIRuntime:: next_input()
Wait for the next keyboard event. Returns nullopt if the channel shuts down.
void nxt:: ui:: UIRuntime:: print(std:: string_view text)
Write text to the scroll region cursor. HUD rendering preserves this cursor, so long-running streams can emit incremental text while the HUD keeps redrawing below.
void nxt:: ui:: UIRuntime:: println(std:: string_view line)
Print a line to the scroll region (only works when HUD height < terminal). In full-screen mode, this is a no-op.
template <typename Layout>
void nxt:: ui:: UIRuntime:: render(const Layout& layout)
Render a layout to the screen. Computes HUD height from layout hint, sets up scroll region, renders.
template <typename BuildUI>
nxt:: task nxt:: ui:: UIRuntime:: run_render_loop(BuildUI build_ui,
std:: chrono:: milliseconds frame_time = std:: chrono:: milliseconds{ 16})
Run a render loop until shutdown. BuildUI is called each frame to produce the layout. Waits for damage signal, but rate-limits to frame_time. Note: pass by value to avoid dangling references in coroutine.
nxt:: task nxt:: ui:: UIRuntime:: signal_loop()
Coroutine that handles signals from the pipe. Should be run as part of the main task group.