nxt/tui.hpp file

Namespaces

namespace nxt
namespace nxt::tui

Classes

template <>
struct nxt::tui::hint_extent<ch>
template <>
struct nxt::tui::hint_extent<ln>
template <auto Unit>
struct nxt::tui::SizeHint
Minimum size plus flex-grow factor for one layout axis.
template <typename RenderFn>
struct nxt::tui::Leaf
Leaf layout backed by a render callback.
template <Layout FalseLayout, Layout TrueLayout>
struct nxt::tui::Either
Conditional layout that delegates to one of two child layouts.
struct nxt::tui::Style
Foreground, background, and emphasis style overlay.
struct nxt::tui::Span
Styled text segment used by styled_text.
template <Layout Child>
struct nxt::tui::Surface
Layout decorator that clears its raster before rendering a child.
template <Layout Child>
struct nxt::tui::FixedHeight
Layout decorator that forces a fixed height hint.
template <Layout... Children>
struct nxt::tui::Row
Horizontal flex container.
template <Layout... Children>
struct nxt::tui::Column
Vertical flex container.
template <typename T, typename ViewFn>
struct nxt::tui::List
Render a span of items by mapping each item to a one-line layout.

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 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 render_span(RasterView& r, Pos pos, const Span& s) →  col_t
Render one styled span and return the column after the written text.
auto repeat(std::string_view glyph, width_t w) →  std::string
Repeat a UTF-8 glyph string w terminal 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.
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 utf8_width(std::string_view s) →  width_t
Display width of UTF-8 text in terminal cells.
auto write_text(RasterView& r, Pos pos, std::string_view text) →  col_t
Write UTF-8 text into a raster.

Variables

Style bold constexpr
Predefined emphasis-only styles.
Style faint constexpr
Style italic constexpr
Style reverse constexpr
Style strikethrough constexpr
Style underline constexpr