Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions
presentation.hpp File Reference
#include "terminal.hpp"
#include <uni20/core/math.hpp>
#include <uni20/core/scalar_io.hpp>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <deque>
#include <fmt/core.h>
#include <initializer_list>
#include <optional>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>
Include dependency graph for presentation.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  uni20::presentation::numeric_format_options
 Numeric scalar formatting controls shared by tensor-style renderers. More...
 
struct  uni20::presentation::output_policy
 Output policy shared by presentation renderers and layout helpers. More...
 
class  uni20::presentation::report_builder
 Builder for simple terminal reports with headings, status lines, fields, and tables. More...
 
class  uni20::presentation::report_table
 A small report table builder for command-line examples and diagnostics. More...
 
struct  uni20::presentation::semantic_glyph_span
 A semantic glyph token carrying style metadata but no rendered spelling. More...
 
class  uni20::presentation::styled_text
 A sequence of styled text spans and semantic glyph tokens. More...
 
struct  uni20::presentation::styled_text_span
 A text span carrying style metadata but no terminal escape sequences. More...
 
struct  uni20::presentation::table_border_options
 Rule and border controls for report tables. More...
 
struct  uni20::presentation::table_cell
 Cell specification for table rows, including optional style, column span, and alignment. More...
 
struct  uni20::presentation::table_column
 Column specification for report tables. More...
 
struct  uni20::presentation::table_separator
 Explicit separator row inserted between table data rows. More...
 
class  uni20::presentation::text_style
 Callable style wrapper that builds styled presentation text. More...
 

Namespaces

namespace  uni20
 
namespace  uni20::presentation
 

Typedefs

using uni20::presentation::presentation_span = std::variant< styled_text_span, semantic_glyph_span >
 
using uni20::presentation::table_entry = std::variant< std::vector< table_cell >, table_separator >
 

Enumerations

enum class  uni20::presentation::ambiguous_width { uni20::presentation::narrow , uni20::presentation::wide }
 Selects how East Asian ambiguous-width code points are measured. More...
 
enum class  uni20::presentation::color_mode { uni20::presentation::never , uni20::presentation::automatic , uni20::presentation::always }
 Selects when terminal color/style control sequences may be emitted. More...
 
enum class  uni20::presentation::glyph_set { uni20::presentation::unicode , uni20::presentation::emoji , uni20::presentation::ascii }
 Selects the preferred glyph family for semantic symbols and ornaments. More...
 
enum class  uni20::presentation::invalid_utf8 { uni20::presentation::escape , uni20::presentation::replace }
 Selects how invalid UTF-8 bytes are represented. More...
 
enum class  uni20::presentation::ornament_mode { uni20::presentation::none , uni20::presentation::minimal , uni20::presentation::rich }
 Selects the richness of decorative line and tree glyphs. More...
 
enum class  uni20::presentation::real_notation { uni20::presentation::general , uni20::presentation::fixed , uni20::presentation::scientific }
 Selects how real floating-point values are formatted. More...
 
enum class  uni20::presentation::semantic_glyph {
  uni20::presentation::success , uni20::presentation::failure , uni20::presentation::fatal , uni20::presentation::warning ,
  uni20::presentation::info , uni20::presentation::partial , uni20::presentation::deferred , uni20::presentation::skipped ,
  uni20::presentation::arrow_right , uni20::presentation::arrow_left , uni20::presentation::arrow_up , uni20::presentation::arrow_down ,
  uni20::presentation::arrow_left_right , uni20::presentation::ellipsis , uni20::presentation::box_horizontal , uni20::presentation::box_vertical ,
  uni20::presentation::box_top_left , uni20::presentation::box_top_right , uni20::presentation::box_bottom_left , uni20::presentation::box_bottom_right ,
  uni20::presentation::box_round_top_left , uni20::presentation::box_round_top_right , uni20::presentation::box_round_bottom_left , uni20::presentation::box_round_bottom_right ,
  uni20::presentation::box_tee_left , uni20::presentation::box_tee_right , uni20::presentation::box_tee_up , uni20::presentation::box_tee_down ,
  uni20::presentation::box_cross , uni20::presentation::box_double_horizontal , uni20::presentation::box_double_vertical , uni20::presentation::box_double_top_left ,
  uni20::presentation::box_double_top_right , uni20::presentation::box_double_bottom_left , uni20::presentation::box_double_bottom_right , uni20::presentation::box_double_tee_left ,
  uni20::presentation::box_double_tee_right , uni20::presentation::box_double_tee_up , uni20::presentation::box_double_tee_down , uni20::presentation::box_double_cross ,
  uni20::presentation::box_double_vertical_tee_right_single , uni20::presentation::box_double_vertical_tee_left_single , uni20::presentation::box_double_vertical_cross_single_horizontal , uni20::presentation::box_double_down_single_horizontal ,
  uni20::presentation::box_double_up_single_horizontal , uni20::presentation::box_single_vertical_tee_right_double , uni20::presentation::box_single_vertical_tee_left_double , uni20::presentation::box_single_vertical_cross_double_horizontal ,
  uni20::presentation::box_single_down_double_horizontal , uni20::presentation::box_single_up_double_horizontal , uni20::presentation::box_diagonal_forward , uni20::presentation::box_diagonal_back ,
  uni20::presentation::box_diagonal_cross , uni20::presentation::tree_branch , uni20::presentation::tree_last , uni20::presentation::tree_vertical ,
  uni20::presentation::tree_space , uni20::presentation::bullet , uni20::presentation::matrix_top_left , uni20::presentation::matrix_top_right ,
  uni20::presentation::matrix_middle_left , uni20::presentation::matrix_middle_right , uni20::presentation::matrix_bottom_left , uni20::presentation::matrix_bottom_right
}
 Names semantic glyphs independently of their rendered spelling. More...
 
enum class  uni20::presentation::table_alignment { uni20::presentation::left , uni20::presentation::right , uni20::presentation::center , uni20::presentation::decimal }
 Selects table cell alignment in report-style output. More...
 
enum class  uni20::presentation::table_rule_style { uni20::presentation::single , uni20::presentation::double_line }
 Selects the glyph family used for table rules and borders. More...
 
enum class  uni20::presentation::text_charset { uni20::presentation::utf8 , uni20::presentation::ascii_escape , uni20::presentation::ascii_replace }
 Selects how non-ASCII text code points are rendered. More...
 
enum class  uni20::presentation::width_mode { uni20::presentation::bytes , uni20::presentation::display_cells }
 Selects the unit used by alignment and clipping helpers. More...
 

Functions

table_cell uni20::presentation::cell (char const *text, std::size_t span=1, std::optional< table_alignment > alignment=std::nullopt)
 Build a table cell from literal text.
 
table_cell uni20::presentation::cell (std::string_view text, std::size_t span=1, std::optional< table_alignment > alignment=std::nullopt)
 Build a table cell from literal text.
 
table_cell uni20::presentation::cell (styled_text content, std::size_t span=1, std::optional< table_alignment > alignment=std::nullopt)
 Build a table cell from styled presentation text.
 
std::string uni20::presentation::clip_to_width (std::string_view text, std::size_t max_width, output_policy const &policy, std::size_t initial_column=0)
 Clip rendered text to a target width without appending a marker.
 
uni20::real_format_notation uni20::presentation::core_notation (real_notation notation)
 
std::size_t uni20::presentation::display_width (std::string_view text, output_policy const &policy, std::size_t initial_column=0)
 Measure rendered text width under the selected policy.
 
std::size_t uni20::presentation::display_width (styled_text const &text, output_policy const &policy, std::size_t initial_column=0)
 Measure rendered styled text width under the selected policy.
 
template<uni20::Complex T>
std::string uni20::presentation::format_complex (T const &value, numeric_format_options const &options)
 Format a complex value as real+imagi.
 
template<uni20::Real T>
std::string uni20::presentation::format_real (T value, numeric_format_options const &options)
 Format a real scalar value according to numeric presentation options.
 
template<typename T >
std::string uni20::presentation::format_scalar (T const &value, numeric_format_options const &options)
 Format an arbitrary scalar-like value for presentation output.
 
template<typename T >
std::string uni20::presentation::format_scalar_for_output (T const &value, numeric_format_options const &options, output_policy const &policy)
 Format a scalar for policy-aware presentation output.
 
std::string uni20::presentation::indent_text (std::string_view text, std::size_t spaces, output_policy const &policy, bool indent_first=true)
 Indent each rendered line by a fixed number of spaces.
 
std::string uni20::presentation::pad_center (std::string_view text, std::size_t target_width, output_policy const &policy)
 Center rendered text within a target width.
 
styled_text uni20::presentation::pad_center (styled_text const &text, std::size_t target_width, output_policy const &policy)
 Center styled text within a target width.
 
std::string uni20::presentation::pad_left (std::string_view text, std::size_t target_width, output_policy const &policy)
 Left-pad rendered text to a target width.
 
styled_text uni20::presentation::pad_left (styled_text const &text, std::size_t target_width, output_policy const &policy)
 Left-pad styled text to a target width.
 
std::string uni20::presentation::pad_right (std::string_view text, std::size_t target_width, output_policy const &policy)
 Right-pad rendered text to a target width.
 
styled_text uni20::presentation::pad_right (styled_text const &text, std::size_t target_width, output_policy const &policy)
 Right-pad styled text to a target width.
 
output_policy uni20::presentation::plain_policy ()
 Build a policy for plain file/log rendering with no ANSI color.
 
std::string uni20::presentation::prefix_lines (std::string_view text, std::string_view prefix, output_policy const &policy, bool prefix_first=true)
 Prefix each rendered line with fixed text.
 
template<uni20::Real T>
int uni20::presentation::real_precision (numeric_format_options const &options)
 Select the configured precision for a Uni20 real scalar type.
 
std::string uni20::presentation::render (styled_text const &text, output_policy const &policy)
 Render styled text with color/style sequences only when policy allows.
 
std::string uni20::presentation::render_glyph (semantic_glyph glyph, output_policy const &policy)
 Render a semantic glyph according to an output policy.
 
std::string uni20::presentation::render_plain (report_builder const &report, output_policy policy=plain_policy())
 Render a high-level report builder without ANSI escape sequences.
 
std::string uni20::presentation::render_plain (styled_text const &text, output_policy policy=plain_policy())
 Render styled text without ANSI escape sequences.
 
styled_text uni20::presentation::render_report (report_builder const &report, output_policy const &policy)
 Format a high-level report builder into styled text.
 
std::string uni20::presentation::render_strict_ascii (styled_text const &text, text_charset charset=text_charset::ascii_escape, output_policy policy=strict_ascii_policy())
 Render styled text under strict ASCII fallback.
 
std::string uni20::presentation::render_terminal (report_builder const &report, output_policy policy, std::FILE *stream=stdout)
 Render a high-level report builder for a terminal stream.
 
std::string uni20::presentation::render_terminal (styled_text const &text, output_policy policy, std::FILE *stream=stdout)
 Render styled text for a terminal stream.
 
std::string uni20::presentation::render_text (std::string_view text, output_policy const &policy)
 Render raw UTF-8 text through charset and ASCII fallback policy.
 
bool uni20::presentation::should_emit_color (output_policy const &policy)
 Return whether a policy currently permits ANSI color output.
 
output_policy uni20::presentation::strict_ascii_policy (text_charset charset=text_charset::ascii_escape)
 Build a strict ASCII policy.
 
text_style uni20::presentation::style (char const *spec)
 Create a callable style wrapper from a style specification.
 
text_style uni20::presentation::style (std::string_view spec)
 Create a callable style wrapper from a style specification.
 
text_style uni20::presentation::style (terminal::TerminalStyle style)
 Create a callable style wrapper from terminal style metadata.
 
template<typename T >
std::string uni20::presentation::style_nonfinite_scalar (std::string text, T const &value, output_policy const &policy)
 Apply the default non-finite scalar style to already-formatted presentation text.
 
output_policy uni20::presentation::terminal_policy (std::FILE *stream=stdout)
 Build a policy for terminal rendering.
 
std::string uni20::presentation::truncate_left_to_width (std::string_view text, std::size_t max_width, output_policy const &policy, std::string_view marker="", std::size_t initial_column=0)
 Truncate rendered text from the left to a target width and optionally prepend a marker.
 
std::string uni20::presentation::truncate_to_width (std::string_view text, std::size_t max_width, output_policy const &policy, std::string_view marker="", std::size_t initial_column=0)
 Truncate rendered text to a target width and optionally append a marker.
 
std::vector< std::string > uni20::presentation::wrap_text (std::string_view text, std::size_t max_width, output_policy const &policy)
 Wrap rendered text by display cells or bytes.
 
std::vector< styled_text > uni20::presentation::wrap_text (styled_text const &text, std::size_t max_width, output_policy const &policy)
 Wrap styled text by display cells or bytes.