Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
ui_log_view.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/log_navigation.hpp>
6#include <portals/log_view.hpp>
7#include <portals/ui_description.hpp>
8
9namespace portals {
10class ManagedScene;
11struct ManagedError;
12struct LogLine;
13class FileLogModel;
14class SourceBudget;
15struct FileLogOptions;
16enum class SourceError;
17template <class T> class WindowProvider;
18} // namespace portals
19
20namespace portals::ui {
21template <class T> class Description;
22template <class T> class Ref;
23
24namespace detail {
25struct LogSourceData;
26struct ExternalLogAccess;
27} // namespace detail
28
31 std::size_t maxRecords{512};
32 std::size_t maxBytes{1024 * 1024};
33 std::size_t maxRecordBytes{64 * 1024};
34};
35
44
48class LogSource {
49public:
50 LogSource() = default;
54 std::shared_ptr<FileLogModel> fileModel() const noexcept;
56 std::optional<std::uint64_t> rowCount() const noexcept;
58 std::shared_ptr<SourceBudget> budget() const noexcept;
60 std::shared_ptr<LogBookmarkProvider> bookmarks() const noexcept;
61
62private:
63 friend struct detail::ExternalLogAccess;
64
65 explicit LogSource(std::shared_ptr<detail::LogSourceData> data, SourceError error = {})
66 : data_(std::move(data)), error_(error) {
67 }
68
69 std::shared_ptr<detail::LogSourceData> data_;
70 SourceError error_{};
71};
72
76LogSource logFile(std::string_view path);
80LogSource logFile(std::string_view path, const FileLogOptions &options, std::shared_ptr<SourceBudget> budget = {});
85LogSource logSource(std::shared_ptr<WindowProvider<LogLine>> provider, std::shared_ptr<SourceBudget> budget = {});
90LogSource logSource(std::shared_ptr<WindowProvider<LogLine>> provider, std::shared_ptr<LogBookmarkProvider> bookmarks,
91 std::shared_ptr<SourceBudget> budget = {});
92
93namespace detail {
95LogSource finiteLogSource(std::shared_ptr<WindowProvider<LogLine>> provider, std::uint64_t rows, std::uint64_t revision,
96 std::shared_ptr<SourceBudget> budget);
97LogSource failedLogSource(SourceError error);
99} // namespace detail
100
107Description<LogView> logView(Ref<LogView> reference, std::string_view initial = {}, LogViewConfig config = {},
108 ControlStyle style = {});
112Description<LogView> logView(std::string_view initial = {}, LogViewConfig config = {}, ControlStyle style = {});
118Description<LogView> logView(LogSource source, LogSourceViewConfig config = {}, ControlStyle style = {});
123Description<LogView> logView(Ref<LogView> reference, LogSource source, LogSourceViewConfig config = {},
124 ControlStyle style = {});
125} // namespace portals::ui
126
127namespace portals {
137std::expected<void, ManagedError> setLogModel(ManagedScene &scene, Node<LogView> node, ui::LogSource source);
142std::expected<void, SourceError> seekLogRow(WidgetTree &tree, Node<LogView> node, std::uint64_t ordinal);
147std::expected<void, SourceError> seekLogByte(WidgetTree &tree, Node<LogView> node, std::uint64_t byteOffset);
151std::expected<LogNavigation, SourceError> logNavigation(WidgetTree &tree, Node<LogView> node);
152} // namespace portals
File-backed rich model with optional bounded WindowSource delivery. Creation owns the path without op...
Definition log_file.hpp:74
Bounded worker extension for log positions; unrelated to total extent. The provider owns its logical ...
Definition log_navigation.hpp:26
Weak UI-affine checkpoint session owned by an existing scene. Removing a view leaves this session ali...
Definition log_navigation.hpp:105
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
Exclusive parent/child ownership on Scheduler's UI thread. Scheduler must outlive this object....
Definition widget.hpp:179
Worker provider; the source captures capabilities once and never calls load on UI.
Definition window_source.hpp:323
Single-use owning construction recipe; no mounted widget ownership.
Definition ui_description.hpp:48
Owning deferred external log binding; construction performs no file I/O. Copies share the provider an...
Definition ui_log_view.hpp:48
std::shared_ptr< FileLogModel > fileModel() const noexcept
std::shared_ptr< SourceBudget > budget() const noexcept
LogSource()=default
Empty descriptor; mounting reports INVALID_ARGUMENT.
std::shared_ptr< LogBookmarkProvider > bookmarks() const noexcept
std::optional< std::uint64_t > rowCount() const noexcept
Typed Widget observation; explicit composite specializations reuse their existing weak facades.
Definition ui_ref.hpp:761
Public Portals API.
Definition action.hpp:8
std::expected< void, SourceError > seekLogByte(WidgetTree &tree, Node< LogView > node, std::uint64_t byteOffset)
std::expected< void, SourceError > seekLogRow(WidgetTree &tree, Node< LogView > node, std::uint64_t ordinal)
std::expected< LogNavigation, SourceError > logNavigation(WidgetTree &tree, Node< LogView > node)
SourceError
Source protocol and admission failures, independent of a provider's storage format.
Definition source_budget.hpp:14
std::expected< void, ManagedError > setLogModel(ManagedScene &scene, Node< LogView > node, ui::LogSource source)
Fixed bounds independent of file length; no row index is constructed.
Definition log_file.hpp:29
Configurable metadata bounds; no source-count limit or LRU eviction.
Definition log_navigation.hpp:89
Immutable UTF-8 record with its original byte position; separators are excluded.
Definition log_file.hpp:18
Original error plus independent runner/restoration and cleanup failures.
Definition managed_diagnostics.hpp:62
Positive external-source display caps; independent of rolling-log append limits.
Definition ui_log_view.hpp:30
std::size_t maxRecords
Maximum logical records retained in one local prepared window.
Definition ui_log_view.hpp:31
std::size_t maxRecordBytes
Maximum single source record, including rich finite strings.
Definition ui_log_view.hpp:33
std::size_t maxBytes
Maximum retained record payload bytes before display expansion.
Definition ui_log_view.hpp:32
External log presentation and native navigation settings.
Definition ui_log_view.hpp:37
bool readOnly
Disable user navigation; checked programmatic navigation remains available.
Definition ui_log_view.hpp:40
LogCheckpointOptions checkpoints
Metadata bounds used when creating the default session.
Definition ui_log_view.hpp:42
LogSourceLimits limits
Bounded display payload caps, additionally constrained by the shared source ledger.
Definition ui_log_view.hpp:38
LogNavigation navigation
Optional explicit session reuse; omitted creates an independent scene-owned session.
Definition ui_log_view.hpp:41
bool followTail
Start at and follow the available tail when the provider supports it.
Definition ui_log_view.hpp:39