tui namespace
Namespaces
- namespace detail
Classes
- class AnyLayout
-
template <Layout... Children>struct Column
- Vertical flex container.
-
template <Layout FalseLayout, Layout TrueLayout>struct Either
- Conditional layout that delegates to one of two child layouts.
-
template <Layout Child>struct FixedHeight
- Layout decorator that forces a fixed height hint.
-
template <typename RenderFn>struct Leaf
- Leaf layout backed by a render callback.
-
template <typename T, typename ViewFn>struct List
- Render a span of items by mapping each item to a one-line layout.
- struct PtyScreen
- Layout adapter for a PTY-backed terminal session.
-
template <Layout... Children>struct Row
- Horizontal flex container.
-
template <auto Unit>struct SizeHint
- Minimum size plus flex-grow factor for one layout axis.
-
template <Layout L>class Slot
- struct Span
- Styled text segment used by
styled_text. - struct Style
- Foreground, background, and emphasis style overlay.
-
template <Layout Child>struct Surface
- Layout decorator that clears its raster before rendering a child.
- struct TextField
- struct TextFieldOptions
- Rendering options for
text_field. - struct TextFieldStyle
-
template <typename ResizeFn = detail::struct VTermScreen
NoResize> -
template <auto Unit>struct hint_extent
- Maps a logical size unit to its strongly typed extent.
-
template <>struct hint_extent<ch>
-
template <>struct hint_extent<ln>
Concepts
-
template <typename L>concept Layout
- Concept implemented by values that can report size hints and render.
Typedefs
- using HeightHint = SizeHint<ln>
- Height hint measured in terminal lines.
- using WidthHint = SizeHint<ch>
- Width hint measured in terminal cells.
-
template <auto Unit>using hint_extent_t = typename hint_
extent<Unit>::type
Functions
-
auto apply_key(TextField& field,
const nxt::
input:: KeyEvent& event) → bool -
auto bar_string(percent_
t pct, width_ t width) → std:: string - Build the glyph string for a fractional progress bar.
- auto bg(Rgba8 color) → Style constexpr
- Build a style that sets only background color.
-
template <Layout... Children>auto column(Children && ... children) → Column<std::
decay_t<Children>...> - Create a vertical flex column.
-
template <Layout FalseLayout, Layout TrueLayout>auto either(bool choose_true, FalseLayout&& false_layout, TrueLayout&& true_layout) → auto
- Create a conditional layout from two alternatives.
- auto em(Emphasis e) → Style constexpr
- Build a style that sets only emphasis flags.
- auto fg(Rgba8 color) → Style constexpr
- Build a style that sets only foreground color.
- auto fill(Rgba8 color = Rgba8(60, 60, 60)) → auto
- Fill available space with a background color.
-
template <Layout Child>auto fixed_height(height_
t height, Child&& child) → auto - Create a layout wrapper that reports a fixed height.
- auto hrule()
- Create a one-line horizontal rule layout.
-
auto hrule_string(width_
t w) → std:: string - Build a horizontal rule string for a width.
-
template <typename F>auto leaf(WidthHint w, HeightHint h, F&& f) → auto
- Create a callback-backed leaf layout.
-
template <typename T, typename ViewFn>auto list(std::
span<const T> items, ViewFn&& view) → List<T, ViewFn> - Create a list from a borrowed item span.
-
template <typename T, typename ViewFn>auto list(const std::
vector<T>& items, ViewFn&& view) → auto - Create a list from a vector, borrowing it for the lifetime of the layout.
-
auto progress_bar(percent_
t pct, Rgba8 fg = Rgba8(100, 180, 255), Rgba8 bg = Rgba8(50, 50, 50)) → auto - Create a one-line progress bar layout.
-
auto pty_screen(nxt::
subprocess:: PtySession& session, Style clear_style = {}) → auto - Build a layout for a live PTY session.
-
auto pty_screen(nxt::
subprocess:: PtySession* session, nxt:: vterm:: Terminal& fallback, Style clear_style = {}) → auto - Build a layout that can fall back to a standalone terminal screen.
-
auto render_span(RasterView& r,
Pos pos,
const Span& s) → col_
t - Render one styled span and return the column after the written text.
-
void render_vterm_screen(RasterView& raster,
Size size,
nxt::
vterm:: Terminal& terminal, Style clear_style = {}) - Clear a raster and render a libvterm screen into it.
-
auto repeat(std::
string_view glyph, width_ t w) → std:: string - Repeat a UTF-8 glyph string
wterminal cells worth of times. -
template <Layout... Children>auto row(Children && ... children) → Row<std::
decay_t<Children>...> - Create a horizontal flex row.
- void set_bg(RasterView& r, Pos pos, Rgba8 color)
- Set one cell's background color.
- void set_fg(RasterView& r, Pos pos, Rgba8 color)
- Set one cell's foreground color.
-
template <Layout L>auto slot(L initial, std::
function<void()> on_publish = {}) → auto - Deduction helper:
slot(text("hi"), [&rt]{ rt.signal_damage(); }). -
auto span(std::
string text, Style s = {}) → Span - Create a styled text segment.
-
auto spinner(std::
size_t tick, Style style = bold|fg(Rgba8:: black())|bg(Rgba8:: white())) → auto - Create a compact one-line spinner frame.
-
template <typename... Spans>auto styled_text(Spans && ... spans) → auto
- Create a one-line text leaf from several styled spans.
- auto subraster(RasterView& r, Pos pos, Size size) → RasterView
- Create a child raster view relative to a parent view.
-
template <Layout Child>auto surface(Style style, Child&& child) → auto
- Create a clearing surface around a child layout.
-
auto text(std::
string s) → auto - Create a one-line text leaf using default style.
-
auto text(std::
string s, Style style) → auto - Create a one-line text leaf using
style. - auto text_field(const TextField& field, TextFieldOptions opts = {}) → auto
-
auto utf8_width(std::
string_view s) → width_ t - Display width of UTF-8 text in terminal cells.
-
auto vterm_screen(nxt::
vterm:: Terminal& terminal) → auto - Build a growable terminal layout without a resize hook.
-
auto vterm_screen(nxt::
vterm:: Terminal& terminal, Style clear_style) → auto - Build a growable terminal layout with a custom clear style.
-
template <typename ResizeFn>auto vterm_screen(nxt::
vterm:: Terminal& terminal, ResizeFn&& resize) → auto - Build a growable terminal layout with a resize hook.
-
template <typename ResizeFn>auto vterm_screen(nxt::
vterm:: Terminal& terminal, ResizeFn&& resize, Style clear_style) → auto - Build a growable terminal layout with a resize hook and clear style.
-
auto write_text(RasterView& r,
Pos pos,
std::
string_view text) → col_ t - Write UTF-8 text into a raster.
Variables
Typedef documentation
using nxt:: tui:: HeightHint = SizeHint<ln>
#include <nxt/tui.hpp>
Height hint measured in terminal lines.
using nxt:: tui:: WidthHint = SizeHint<ch>
#include <nxt/tui.hpp>
Width hint measured in terminal cells.
#include <nxt/tui.hpp>
template <auto Unit>
using nxt:: tui:: hint_extent_t = typename hint_ extent<Unit>::type
Function documentation
bool nxt:: tui:: apply_key(TextField& field,
const nxt:: input:: KeyEvent& event)
#include <nxtio/text_field.hpp>
Apply a single key event to the field. Handles text insertion and the standard editing keys (backspace, delete, arrows, home, end). Returns true if the field changed (caller should redraw).
Release events and unknown keys return false; the caller is free to handle Enter / Escape / etc. itself before or after this call.
std:: string nxt:: tui:: bar_string(percent_ t pct,
width_ t width)
#include <nxt/tui.hpp>
Build the glyph string for a fractional progress bar.
Style nxt:: tui:: bg(Rgba8 color) constexpr
#include <nxt/tui.hpp>
Build a style that sets only background color.
#include <nxt/tui.hpp>
template <Layout... Children>
Column<std:: decay_t<Children>...> nxt:: tui:: column(Children && ... children)
Create a vertical flex column.
#include <nxt/tui.hpp>
template <Layout FalseLayout, Layout TrueLayout>
auto nxt:: tui:: either(bool choose_true,
FalseLayout&& false_layout,
TrueLayout&& true_layout)
Create a conditional layout from two alternatives.
Style nxt:: tui:: em(Emphasis e) constexpr
#include <nxt/tui.hpp>
Build a style that sets only emphasis flags.
Style nxt:: tui:: fg(Rgba8 color) constexpr
#include <nxt/tui.hpp>
Build a style that sets only foreground color.
auto nxt:: tui:: fill(Rgba8 color = Rgba8(60, 60, 60))
#include <nxt/tui.hpp>
Fill available space with a background color.
#include <nxt/tui.hpp>
template <Layout Child>
auto nxt:: tui:: fixed_height(height_ t height,
Child&& child)
Create a layout wrapper that reports a fixed height.
auto nxt:: tui:: hrule()
#include <nxt/tui.hpp>
Create a one-line horizontal rule layout.
std:: string nxt:: tui:: hrule_string(width_ t w)
#include <nxt/tui.hpp>
Build a horizontal rule string for a width.
#include <nxt/tui.hpp>
template <typename F>
auto nxt:: tui:: leaf(WidthHint w,
HeightHint h,
F&& f)
Create a callback-backed leaf layout.
#include <nxt/tui.hpp>
template <typename T, typename ViewFn>
List<T, ViewFn> nxt:: tui:: list(std:: span<const T> items,
ViewFn&& view)
Create a list from a borrowed item span.
#include <nxt/tui.hpp>
template <typename T, typename ViewFn>
auto nxt:: tui:: list(const std:: vector<T>& items,
ViewFn&& view)
Create a list from a vector, borrowing it for the lifetime of the layout.
auto nxt:: tui:: progress_bar(percent_ t pct,
Rgba8 fg = Rgba8(100, 180, 255),
Rgba8 bg = Rgba8(50, 50, 50))
#include <nxt/tui.hpp>
Create a one-line progress bar layout.
auto nxt:: tui:: pty_screen(nxt:: subprocess:: PtySession& session,
Style clear_style = {})
#include <nxtio/tui_subprocess.hpp>
Build a layout for a live PTY session.
auto nxt:: tui:: pty_screen(nxt:: subprocess:: PtySession* session,
nxt:: vterm:: Terminal& fallback,
Style clear_style = {})
#include <nxtio/tui_subprocess.hpp>
Build a layout that can fall back to a standalone terminal screen.
col_ t nxt:: tui:: render_span(RasterView& r,
Pos pos,
const Span& s)
#include <nxt/tui.hpp>
Render one styled span and return the column after the written text.
void nxt:: tui:: render_vterm_screen(RasterView& raster,
Size size,
nxt:: vterm:: Terminal& terminal,
Style clear_style = {})
#include <nxt/tui_terminal.hpp>
Clear a raster and render a libvterm screen into it.
Clear a raster and render terminal cells, colors, emphasis, and cursor.
std:: string nxt:: tui:: repeat(std:: string_view glyph,
width_ t w)
#include <nxt/tui.hpp>
Repeat a UTF-8 glyph string w terminal cells worth of times.
#include <nxt/tui.hpp>
template <Layout... Children>
Row<std:: decay_t<Children>...> nxt:: tui:: row(Children && ... children)
Create a horizontal flex row.
void nxt:: tui:: set_bg(RasterView& r,
Pos pos,
Rgba8 color)
#include <nxt/tui.hpp>
Set one cell's background color.
void nxt:: tui:: set_fg(RasterView& r,
Pos pos,
Rgba8 color)
#include <nxt/tui.hpp>
Set one cell's foreground color.
#include <nxt/slot.hpp>
template <Layout L>
auto nxt:: tui:: slot(L initial,
std:: function<void()> on_publish = {})
Deduction helper: slot(text("hi"), [&rt]{ rt.signal_damage(); }).
Span nxt:: tui:: span(std:: string text,
Style s = {})
#include <nxt/tui.hpp>
Create a styled text segment.
auto nxt:: tui:: spinner(std:: size_t tick,
Style style = bold|fg(Rgba8:: black())|bg(Rgba8:: white()))
#include <nxt/tui.hpp>
Create a compact one-line spinner frame.
#include <nxt/tui.hpp>
template <typename... Spans>
auto nxt:: tui:: styled_text(Spans && ... spans)
Create a one-line text leaf from several styled spans.
RasterView nxt:: tui:: subraster(RasterView& r,
Pos pos,
Size size)
#include <nxt/tui.hpp>
Create a child raster view relative to a parent view.
#include <nxt/tui.hpp>
template <Layout Child>
auto nxt:: tui:: surface(Style style,
Child&& child)
Create a clearing surface around a child layout.
auto nxt:: tui:: text(std:: string s)
#include <nxt/tui.hpp>
Create a one-line text leaf using default style.
auto nxt:: tui:: text(std:: string s,
Style style)
#include <nxt/tui.hpp>
Create a one-line text leaf using style.
auto nxt:: tui:: text_field(const TextField& field,
TextFieldOptions opts = {})
#include <nxt/text_field.hpp>
A flexing single-line text input leaf.
Width: grows. Height: 1 line. The TextField is snapshot by value so the leaf is safe to render later.
width_ t nxt:: tui:: utf8_width(std:: string_view s)
#include <nxt/tui.hpp>
Display width of UTF-8 text in terminal cells.
auto nxt:: tui:: vterm_screen(nxt:: vterm:: Terminal& terminal)
#include <nxt/tui_terminal.hpp>
Build a growable terminal layout without a resize hook.
auto nxt:: tui:: vterm_screen(nxt:: vterm:: Terminal& terminal,
Style clear_style)
#include <nxt/tui_terminal.hpp>
Build a growable terminal layout with a custom clear style.
#include <nxt/tui_terminal.hpp>
template <typename ResizeFn>
auto nxt:: tui:: vterm_screen(nxt:: vterm:: Terminal& terminal,
ResizeFn&& resize)
Build a growable terminal layout with a resize hook.
#include <nxt/tui_terminal.hpp>
template <typename ResizeFn>
auto nxt:: tui:: vterm_screen(nxt:: vterm:: Terminal& terminal,
ResizeFn&& resize,
Style clear_style)
Build a growable terminal layout with a resize hook and clear style.
col_ t nxt:: tui:: write_text(RasterView& r,
Pos pos,
std:: string_view text)
#include <nxt/tui.hpp>
Write UTF-8 text into a raster.
Variable documentation
Style nxt:: tui:: bold constexpr
#include <nxt/tui.hpp>
Predefined emphasis-only styles.