Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
ui_document_view.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4#include <portals/document_view.hpp>
5#include <portals/ui_description.hpp>
6
7namespace portals::ui {
8namespace detail {
9struct DocumentSourceAccess;
10struct DocumentSourceData;
11} // namespace detail
12
18public:
19 DocumentSource() = default;
21 std::shared_ptr<ByteDocumentSource> byteSource() const noexcept;
23 std::shared_ptr<SourceBudget> budget() const noexcept;
24
25private:
26 friend struct detail::DocumentSourceAccess;
27 std::shared_ptr<detail::DocumentSourceData> data_;
28 std::optional<DocumentError> error_;
29};
30
34DocumentSource document(std::shared_ptr<ByteDocumentSource> source);
38DocumentSource document(std::unexpected<DocumentError> failure);
39
43DocumentSource document(std::shared_ptr<ByteDocumentProvider> provider, std::shared_ptr<SourceBudget> budget = {},
44 DocumentSourceOptions options = {});
49DocumentSource document(std::shared_ptr<const std::string> text, std::shared_ptr<SourceBudget> budget = {});
53DocumentSource documentFile(std::string_view path);
57Description<DocumentView> viewer(DocumentSource source, DocumentViewConfig config = {}, ControlStyle style = {});
61Description<DocumentView> viewer(Ref<DocumentView> reference, DocumentSource source, DocumentViewConfig config = {},
62 ControlStyle style = {});
66Description<DocumentView> viewer(std::string_view path, DocumentViewConfig config = {}, ControlStyle style = {});
70Description<DocumentView> viewer(Ref<DocumentView> reference, std::string_view path, DocumentViewConfig config = {},
71 ControlStyle style = {});
72} // namespace portals::ui
73
74namespace portals {
78std::expected<void, ManagedError> setDocumentModel(ManagedScene &scene, Node<DocumentView> node,
79 ui::DocumentSource source);
83std::expected<void, ManagedError> setDocumentLineNumbers(ManagedScene &scene, Node<DocumentView> node, bool enabled);
87std::expected<void, ManagedError> setDocumentWrap(ManagedScene &scene, Node<DocumentView> node, bool enabled);
91std::expected<void, ManagedError> setDocumentEncoding(ManagedScene &scene, Node<DocumentView> node,
92 DocumentEncoding encoding);
93
95namespace detail {
96std::expected<void, ManagedError> navigateDocument(ManagedScene &, Node<DocumentView>, DocumentNavigation,
97 std::int64_t);
98}
99
101} // namespace portals
Read-only worker provider; callers serialize operations using the existing executor....
Definition document_source.hpp:88
Cold source; inspect/read reject its creating (UI) thread. Dispatch synchronous operations through th...
Definition document_source.hpp:245
Additive lifecycle owner over one existing Application subtree. UI affine and nonmovable....
Definition managed.hpp:530
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Thread-safe credit ledger; final page/worker release may happen on any thread.
Definition source_budget.hpp:119
Owning cold source descriptor; copies retain the same provider, revision namespace and budget....
Definition ui_document_view.hpp:17
DocumentSource()=default
Empty descriptor; mount reports INVALID_ARGUMENT.
std::shared_ptr< SourceBudget > budget() const noexcept
std::shared_ptr< ByteDocumentSource > byteSource() const noexcept
std::expected< void, ManagedError > setDocumentEncoding(ManagedScene &scene, Node< DocumentView > node, DocumentEncoding encoding)
ui::ValueText text(std::format_string< const ui::detail::TextArgumentValue< Args > &... > pattern, Args &&...args)
Declare live formatted text over explicit scalar roots, fields or value properties.
Definition ui_value_text.hpp:567
std::expected< void, ManagedError > setDocumentModel(ManagedScene &scene, Node< DocumentView > node, ui::DocumentSource source)
std::expected< void, ManagedError > setDocumentLineNumbers(ManagedScene &scene, Node< DocumentView > node, bool enabled)
std::expected< void, ManagedError > setDocumentWrap(ManagedScene &scene, Node< DocumentView > node, bool enabled)
DocumentEncoding
Resolved byte encoding, or an unresolved selection.
Definition document_encoding.hpp:14
Failure with an optional native provider cause, preserved by source operations.
Definition document_source.hpp:13
Page bounds limit windows, never logical line length.
Definition document_source.hpp:205