Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Namespaces | Functions
presentation.cpp File Reference
#include "presentation.hpp"
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <utility>
Include dependency graph for presentation.cpp:

Namespaces

namespace  uni20
 
namespace  uni20::presentation
 

Functions

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.
 
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.
 
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.
 
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.
 
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.
 

Variable Documentation

◆ alignment

table_alignment alignment = table_alignment::right

◆ bottom_left

semantic_glyph bottom_left = semantic_glyph::box_bottom_left

◆ bottom_right

semantic_glyph bottom_right = semantic_glyph::box_bottom_right

◆ bytes

std::size_t bytes = 1

◆ cross

semantic_glyph cross = semantic_glyph::box_cross

◆ decimal_position

std::optional<std::size_t> decimal_position

◆ glyph

std::optional<semantic_glyph> glyph

◆ horizontal

semantic_glyph horizontal = semantic_glyph::box_horizontal

◆ lines

std::vector<styled_text> lines

◆ span

std::size_t span = 1

◆ style

◆ tee_down

semantic_glyph tee_down = semantic_glyph::box_tee_down

◆ tee_left

semantic_glyph tee_left = semantic_glyph::box_tee_left

◆ tee_right

semantic_glyph tee_right = semantic_glyph::box_tee_right

◆ tee_up

semantic_glyph tee_up = semantic_glyph::box_tee_up

◆ text

std::string text

◆ top_left

semantic_glyph top_left = semantic_glyph::box_top_left

◆ top_right

semantic_glyph top_right = semantic_glyph::box_top_right

◆ valid

bool valid = false

◆ value

char32_t value = U'\0'

◆ vertical

semantic_glyph vertical = semantic_glyph::box_vertical

◆ width

std::size_t width = 1