Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
render.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3
4#pragma once
5
6#include <portals/cell_buffer.hpp>
7
8#include <cstddef>
9#include <cstdint>
10#include <expected>
11#include <limits>
12#include <span>
13#include <variant>
14
15namespace portals {
16
34 std::int32_t z{};
36 std::size_t firstGrapheme{};
38 std::size_t graphemeCount{std::numeric_limits<std::size_t>::max()};
39};
40
52
54using RenderCommand = std::variant<TextCommand, FillCommand>;
55
61 std::size_t max_commands{65536};
63 std::size_t max_text_bytes{4 * 1024 * 1024};
65 std::size_t max_work{4 * 1024 * 1024};
66};
67
85
96 bool operator==(const RenderError &other) const noexcept = default;
97};
98
118[[nodiscard]] std::expected<CellBuffer, RenderError> renderFullFrame(CellSize size,
119 std::span<const RenderCommand> commands,
120 WidthPolicy policy = {}, RenderLimits limits = {});
121
122} // namespace portals
An owning, invariant-preserving half-open cell rectangle.
Definition geometry.hpp:81
Owning validated UTF-8 and immutable extended grapheme measurements.
Definition text.hpp:145
Public Portals API.
Definition action.hpp:8
@ WORK_LIMIT
The input admission budget was reached.
Definition document_encoding.hpp:36
RenderErrorKind
Observable full-frame failure; no partial buffer is returned.
Definition render.hpp:69
@ INVALID_TEXT_RANGE
A selected text range exceeds its borrowed grapheme sequence.
Definition render.hpp:83
@ BUFFER_ERROR
Buffer creation or placement failed; RenderError::buffer_error describes it.
Definition render.hpp:79
@ COMMAND_LIMIT
The command count exceeds its cap.
Definition render.hpp:71
@ TEXT_BYTE_LIMIT
Summed original text bytes exceed their cap.
Definition render.hpp:73
std::expected< CellBuffer, RenderError > renderFullFrame(CellSize size, std::span< const RenderCommand > commands, WidthPolicy policy={}, RenderLimits limits={})
Render a deterministic fresh frame, independent of diff/damage/output code.
std::variant< TextCommand, FillCommand > RenderCommand
One text or fill command, with TextCommand's synchronous borrow lifetime.
Definition render.hpp:54
CellBufferError
Observable, owning buffer failure; no partial write or resize is returned.
Definition cell_buffer.hpp:134
@ ALLOCATION_FAILURE
Storage allocation failed; the original buffer remains unchanged.
Definition cell_buffer.hpp:160
@ POLICY_MISMATCH
The text's complete captured width policy differs from this buffer.
Definition cell_buffer.hpp:150
Owning caps; creation allocates all intern pool capacity, including defaults.
Definition cell_buffer.hpp:113
An owning value in terminal columns/rows, x right and y down.
Definition geometry.hpp:24
An owning available extent in terminal columns/rows.
Definition geometry.hpp:44
Small owning paint value, independent of themes and text metrics.
Definition cell_buffer.hpp:35
Fill an owning half-open area with styled one-cell ASCII spaces.
Definition render.hpp:42
CellRect area
Area in surface cells, intersected with clip and frame bounds.
Definition render.hpp:44
CellRect clip
Half-open surface-cell clip.
Definition render.hpp:46
CellStyle style
Owning paint style for every filled cell.
Definition render.hpp:48
std::int32_t z
Ascending paint order; equal values preserve command input order.
Definition render.hpp:50
Owning renderer error, independent of the scene lifetime.
Definition render.hpp:87
RenderErrorKind kind
Failure category.
Definition render.hpp:89
CellBufferError buffer_error
Underlying error, meaningful only when kind is buffer_error.
Definition render.hpp:91
bool operator==(const RenderError &other) const noexcept=default
Compare both owning error fields.
Owning full-frame resource caps; over-limit scenes fail without truncation.
Definition render.hpp:57
std::size_t max_work
Maximum visited text graphemes plus clipped fill cells, not CPU instructions.
Definition render.hpp:65
std::size_t max_text_bytes
Maximum summed original text bytes; repeated text runs count separately.
Definition render.hpp:63
CellBufferLimits buffer
Caps of the fresh owning result and its intern tables.
Definition render.hpp:59
std::size_t max_commands
Maximum commands, including empty or offscreen commands.
Definition render.hpp:61
One horizontal text run; controls display placeholders, never line breaks.
Definition render.hpp:24
std::int32_t z
Ascending paint order; equal values preserve command input order.
Definition render.hpp:34
std::size_t firstGrapheme
First selected grapheme; origin places this grapheme, not the complete text.
Definition render.hpp:36
CellPoint origin
First grapheme origin in surface cells; negative coordinates are valid.
Definition render.hpp:26
std::size_t graphemeCount
Selected count; SIZE_MAX selects the remaining suffix. Invalid ranges reject the frame.
Definition render.hpp:38
CellStyle style
Owning paint style for every visible grapheme.
Definition render.hpp:32
const GraphemeText & text
Validated text borrowed synchronously; no pointer is retained in the result.
Definition render.hpp:28
CellRect clip
Half-open surface-cell clip; new graphemes must fit completely inside it.
Definition render.hpp:30
Owning deterministic width policy; no font or terminal matching promise.
Definition text.hpp:42