Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
find_bar.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/controls.hpp>
6#include <portals/model.hpp>
7
8#include <memory>
9#include <string_view>
10
11namespace portals {
12class LineEdit;
13
14namespace ui::detail {
15struct Access;
16}
17
18namespace detail {
19struct FindResult;
20struct FindRecord;
21struct FindAccess;
22struct FindModelSource;
23} // namespace detail
24
30
32struct FindLimits {
33 static constexpr std::size_t MAX_DOCUMENT_BYTES = 1024 * 1024;
34 static constexpr std::size_t MAX_QUERY_BYTES = 16 * 1024;
35 static constexpr std::size_t MAX_MATCHES = 65536;
36 std::size_t maxDocumentBytes{65536};
37 std::size_t maxMatches{4096};
38};
39
42 std::size_t maxSourceRows{100000};
43 std::size_t maxProjectedBytes{32 * 1024 * 1024};
44 std::size_t maxRowBytes{1024 * 1024};
45 std::size_t maxQueryBytes{16 * 1024};
46 std::size_t maxMatches{4096};
47};
48
59
64class FindMatch {
65public:
67 FindMatch() = default;
69 explicit operator bool() const noexcept;
71 std::size_t begin() const noexcept;
73 std::size_t end() const noexcept;
75 std::size_t ordinal() const noexcept;
77 RowId rowId() const noexcept;
79 std::uint64_t sourceRevision() const noexcept;
81 std::optional<std::uint64_t> sourceByteOffset() const noexcept;
83 std::optional<std::uint64_t> sourceByteLength() const noexcept;
84
86 std::uint64_t queryGeneration() const noexcept;
88 std::size_t storedCount() const noexcept;
90 bool truncated() const noexcept;
92 std::string_view text() const noexcept;
97 std::string_view context(std::size_t maxBytes = 256) const noexcept;
98
99private:
100 friend struct detail::FindAccess;
101 std::shared_ptr<const detail::FindResult> result_;
102 std::size_t index_{};
103};
104
112
118class FindBar : public Column {
119public:
121 explicit FindBar(FindBarAppearance appearance = {});
123 ~FindBar() override;
128
129private:
130 friend struct ui::detail::Access;
131 friend struct detail::FindAccess;
132 std::shared_ptr<detail::FindRecord> record_;
133};
134} // namespace portals
Column(LinearOptions options={}, SizePolicy policy={})
Own settings and policies.
FindBar(FindBarAppearance appearance={})
FindMatch match() const
Node< Widget > editor() const
~FindBar() override
Retire callback bridges before child ownership is reclaimed.
Owning immutable selected range; retains original data, never a scene or widget. Empty handles repres...
Definition find_bar.hpp:64
std::string_view context(std::size_t maxBytes=256) const noexcept
std::string_view text() const noexcept
bool truncated() const noexcept
RowId rowId() const noexcept
std::size_t begin() const noexcept
std::optional< std::uint64_t > sourceByteLength() const noexcept
std::size_t ordinal() const noexcept
std::uint64_t sourceRevision() const noexcept
std::size_t end() const noexcept
std::optional< std::uint64_t > sourceByteOffset() const noexcept
FindMatch()=default
Construct an empty range without allocation.
std::size_t storedCount() const noexcept
std::uint64_t queryGeneration() const noexcept
UI-owned Unicode draft; mutate only through its scoped binding between frames. Cursor/anchor are UTF-...
Definition line_edit.hpp:205
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Public Portals API.
Definition action.hpp:8
FindSearchError
Model search failures, distinct from editor admission and scheduler/tree failures.
Definition find_bar.hpp:50
@ NOT_READY
Immutable provider range is pending or failed; no I/O was started.
Definition find_bar.hpp:54
@ INVALID_TEXT
Projected row is not admitted UTF-8 under the scene text policy.
Definition find_bar.hpp:53
@ CALLBACK_FAILED
A non-allocation exception escaped into a runner callback boundary.
Definition application.hpp:34
@ NO_MEMORY
Allocation failed at a runner exception boundary.
Definition application.hpp:33
@ CANCELLED
Explicit cancellation or replacement stopped the invocation.
Definition async.hpp:29
@ INVALID_ARGUMENT
Empty task, callback or immutable data owner, or invalid policy.
Definition async.hpp:26
@ LIMIT_EXCEEDED
A storage request cannot fit its configured aggregate budget.
Definition background_options.hpp:19
FindDirection
Direction through the stored bounded prefix; both directions wrap.
Definition find_bar.hpp:26
constexpr SizePolicy DEFAULT_FLEX_WIDTH_POLICY
Fill available width from a zero flex basis while retaining content height.
Definition layout.hpp:47
@ PREVIOUS
Last whole-grapheme match starting strictly before the requested anchor.
Definition document_search.hpp:12
@ NEXT
First whole-grapheme match starting at or after the requested anchor.
Definition document_search.hpp:11
Owning paint values; no theme engine or behavior is encoded here.
Definition controls.hpp:24
Manual child appearances and ordinary retained layout defaults.
Definition find_bar.hpp:106
LinearOptions layout
Existing outer vertical layout settings.
Definition find_bar.hpp:109
ControlStyle summaryStyle
Count/context manual defaults beneath child style rules.
Definition find_bar.hpp:108
SizePolicy policy
Existing outer layout constraints.
Definition find_bar.hpp:110
ControlStyle navigationStyle
Previous/Next/Clear manual defaults beneath child style rules.
Definition find_bar.hpp:107
Independent source/result caps; query admission uses the ordinary editor TextLimits.
Definition find_bar.hpp:32
static constexpr std::size_t MAX_QUERY_BYTES
Hard synchronous query ceiling.
Definition find_bar.hpp:34
static constexpr std::size_t MAX_MATCHES
Hard stored-range ceiling.
Definition find_bar.hpp:35
std::size_t maxMatches
Positive number of retained matches; additional results set truncated.
Definition find_bar.hpp:37
static constexpr std::size_t MAX_DOCUMENT_BYTES
Hard synchronous source ceiling.
Definition find_bar.hpp:33
std::size_t maxDocumentBytes
Owning UTF-8 source cap, including zero for empty sources only.
Definition find_bar.hpp:36
Independent worker scan and retained-result budgets for model-backed literal search.
Definition find_bar.hpp:41
std::size_t maxSourceRows
Full model row ceiling, including nonmatching rows.
Definition find_bar.hpp:42
std::size_t maxRowBytes
Maximum projected bytes in one row.
Definition find_bar.hpp:44
std::size_t maxQueryBytes
Search ceiling in addition to ordinary editor TextLimits.
Definition find_bar.hpp:45
std::size_t maxMatches
Positive retained prefix; one extra match marks truncation.
Definition find_bar.hpp:46
std::size_t maxProjectedBytes
Sum of projected UTF-8 bytes examined per query.
Definition find_bar.hpp:43
Owning linear container options.
Definition layout.hpp:193
Provider-assigned row identity, independent of position; increment generation on reuse.
Definition row_id.hpp:9
Owning independent policies for width and height.
Definition layout.hpp:35
Internal bridge for checked access to managed scene and recipe state.
Definition ui_recipe_access.hpp:28