6#include <portals/diagnostics.hpp>
8#include <portals/cell_buffer.hpp>
9#include <portals/terminal.hpp>
48 std::size_t max_bytes = 1024 * 1024,
65 [[nodiscard]]
virtual std::expected<void, TerminalError>
submit(std::string bytes) = 0;
88 [[nodiscard]] std::expected<void, TerminalError>
submit(std::string bytes)
override;
136 std::shared_ptr<Diagnostics> diagnostics = {})
noexcept;
174 void poison() noexcept;
178 bool diagnostic_submission_{};
179 FrameOutput &output_;
180 FrameWriterLimits limits_;
181 std::optional<CellBuffer> committed_;
182 std::optional<CellBuffer> pending_;
184 std::size_t remaining_{};
Owning bounded cell framebuffer and immutable-width-policy intern pools.
Definition cell_buffer.hpp:203
Explicit, thread-safe metadata recorder. Disabled by default; no clocks or I/O. enable/disable/snapsh...
Definition diagnostics.hpp:141
Exclusive transport boundary, borrowed by FrameWriter for its lifetime. Implementations own submitted...
Definition diff.hpp:58
virtual TerminalWrite flush(TerminalDeadline deadline, std::stop_token stop)=0
Flush the owned suffix; report bytes for this call and total pending.
virtual std::expected< void, TerminalError > submit(std::string bytes)=0
Take an owning batch, or reject without output; allocation may throw.
virtual ~FrameOutput()=default
Destroy the adapter, without an implicit flush.
bool poisoned() const noexcept
Whether unknown side effects permanently prohibit further output.
FrameWriter(const FrameWriter &)=delete
Exclusive output cannot be shared by copying.
FrameWriter(FrameOutput &output, FrameWriterLimits limits={}, std::shared_ptr< Diagnostics > diagnostics={}) noexcept
Borrow exclusive output.
const CellBuffer * committedFrame() const noexcept
Borrow last fully transmitted frame; null initially/after error. This is historical during partial ou...
TerminalWrite flush(TerminalDeadline deadline, std::stop_token stop={})
Perform transport I/O; commit only after complete, consistent progress. Must run outside paint/measur...
std::expected< void, FrameError > submit(CellBuffer &&frame, DiagnosticContext context={})
Encode and take frame only on success; reject busy/poisoned/limits without I/O. Semantically unchange...
FrameWriter & operator=(const FrameWriter &)=delete
Exclusive output cannot be reassigned.
bool pending() const noexcept
Whether a transaction still requires completion; no allocation/errors.
std::expected< void, TerminalError > submit(std::string bytes) override
Forward ownership.
TerminalWrite flush(TerminalDeadline deadline, std::stop_token stop) override
Forward I/O.
TerminalFrameOutput(TerminalSession &session) noexcept
Borrow a stable session.
Move-only terminal mode and I/O owner; no I/O belongs in paint/measure.
Definition terminal.hpp:130
Public Portals API.
Definition action.hpp:8
FrameError
Submission failure; the supplied frame remains owned by the caller.
Definition diff.hpp:107
@ FRAME_LIMIT
Frame allocation accounting exceeds the configured cap.
Definition diff.hpp:110
@ POISONED
Unknown output state; close/reestablish terminal before creating a new writer.
Definition diff.hpp:109
@ PENDING
Complete or abandon the owning session before submitting another frame.
Definition diff.hpp:108
DiagnosticReason
Enumerated evidence, never an exception message or inferred model value.
Definition diagnostics.hpp:39
std::chrono::steady_clock::time_point TerminalDeadline
Absolute monotonic time used by terminal waits.
Definition terminal.hpp:22
ColorMode
Color encoding selected explicitly by the terminal owner.
Definition diff.hpp:17
@ ANSI16
Nearest standard RGB palette entry encoded as SGR 30-37/90-97 and 40-47/100-107.
Definition diff.hpp:19
@ TRUE_COLOR
RGB SGR 38;2/48;2, preserving the existing default.
Definition diff.hpp:18
DiagnosticEvent
Metadata stages; no stage contains application text or terminal bytes.
Definition diagnostics.hpp:16
std::expected< std::string, DiffError > encodeDiff(const CellBuffer *previous, const CellBuffer &next, std::size_t max_bytes=1024 *1024, ColorMode colorMode=ColorMode::TRUE_COLOR)
Encode changed complete rows into one owning VT transaction.
DiffError
Bounded encoding failure; input buffers are unchanged.
Definition diff.hpp:23
@ OUTPUT_LIMIT
The complete transaction cannot fit the configured byte cap.
Definition diff.hpp:24
@ ALLOCATION_FAILURE
Storage allocation failed; the original buffer remains unchanged.
Definition cell_buffer.hpp:160
Fixed-size causal token; zero fields mean unobserved, never a reused identity.
Definition diagnostics.hpp:92
Owning writer resource caps. At most two capped frames coexist.
Definition diff.hpp:101
ColorMode colorMode
Fixed output palette for this writer's complete lifetime.
Definition diff.hpp:104
std::size_t max_frame_storage_bytes
Per-frame CellBuffer::memory().total_bytes cap.
Definition diff.hpp:103
std::size_t max_output_bytes
Complete VT transaction cap.
Definition diff.hpp:102
Owning output progress for this flush call, not a rendered-frame commit.
Definition terminal.hpp:107