5#include <initializer_list>
6#include <portals/managed_diagnostics.hpp>
7#include <portals/shortcut.hpp>
8#include <portals/text_value.hpp>
9#include <portals/widget.hpp>
23struct ActionCancellation;
35 friend class ManagedScene;
37 std::uint64_t serial_{};
57using KeyTextResolver = std::function<std::expected<std::string, TextResourceError>(std::string_view)>;
75 std::shared_ptr<detail::KeyBindingSlot> publication_;
76 std::weak_ptr<const void> scopeIdentity_;
77 std::shared_ptr<detail::ActionCancellation> ownerLifetime_;
123 std::optional<KeyBindingId>
id{};
129 std::vector<KeyAction>
actions = std::vector<KeyAction>(0);
133 std::vector<KeyConflict>
conflicts = std::vector<KeyConflict>(0);
146 std::vector<KeyBindingView>(std::initializer_list<KeyBindingView>{});
161 std::expected<void, ManagedError>
setEnabled(
bool value)
const;
163 std::expected<void, ManagedError>
setVisible(
bool value)
const;
171 std::expected<void, ManagedError>
unbind()
const;
173 std::expected<void, ManagedError>
remove()
const;
176 friend class ManagedScene;
178 std::expected<ManagedScene *, ManagedError> scene()
const;
179 ManagedScene *scene_{};
180 std::weak_ptr<const void> lifetime_;
181 std::thread::id owner_{};
187struct KeyBindingSlot {
188 const std::thread::id owner = std::this_thread::get_id();
189 std::optional<KeyBinding> binding;
205 std::expected<KeyBindingId, ManagedError>
id()
const;
208 std::source_location origin = std::source_location::current())
const;
211 std::source_location origin = std::source_location::current())
const;
215 std::source_location origin = std::source_location::current())
const;
218 std::source_location origin = std::source_location::current())
const;
220 std::expected<void, ManagedError>
unbind(std::source_location origin = std::source_location::current())
const;
222 std::expected<void, ManagedError>
remove(std::source_location origin = std::source_location::current())
const;
225 friend class KeyInfo;
226 std::expected<KeyBinding, ManagedError> binding()
const;
227 std::shared_ptr<portals::detail::KeyBindingSlot> slot_;
Owning validated UTF-8 and immutable extended grapheme measurements.
Definition text.hpp:145
Scene-local, never reused registration identity; not a persistence key.
Definition key_binding.hpp:27
KeyBindingId()=default
Construct an invalid identity.
bool operator==(const KeyBindingId &other) const =default
Weak UI-affine command observation; destruction never unregisters the command.
Definition key_binding.hpp:150
std::expected< void, ManagedError > setVisible(bool value) const
std::expected< void, ManagedError > setEnabled(bool value) const
std::expected< void, ManagedError > unbind() const
KeyBinding()=default
Construct an empty, allocation-free observation.
KeyBindingId id() const noexcept
Definition key_binding.hpp:156
std::expected< void, ManagedError > setText(TextValue label, TextValue description, KeyTextResolver resolver={}) const
std::expected< void, ManagedError > remove() const
std::expected< void, ManagedError > rebind(const KeySelection &selection) const
Copyable immutable owning shortcut selection, or a deferred typed construction error....
Definition shortcut.hpp:171
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
Owning literal bytes or a resource key, measured only at resolution.
Definition text_value.hpp:42
Deferred observing slot, published only by a complete successful registration. Construction may alloc...
Definition key_binding.hpp:198
KeyBindingRef()
Create an unpublished slot; may throw std::bad_alloc.
Definition key_binding.hpp:201
std::expected< void, ManagedError > setText(TextValue label, TextValue description, KeyTextResolver resolver={}, std::source_location origin=std::source_location::current()) const
std::expected< void, ManagedError > setEnabled(bool value, std::source_location origin=std::source_location::current()) const
std::expected< void, ManagedError > rebind(const KeySelection &selection, std::source_location origin=std::source_location::current()) const
std::expected< KeyBindingId, ManagedError > id() const
std::expected< void, ManagedError > unbind(std::source_location origin=std::source_location::current()) const
std::expected< void, ManagedError > setVisible(bool value, std::source_location origin=std::source_location::current()) const
std::expected< void, ManagedError > remove(std::source_location origin=std::source_location::current()) const
Consuming metadata for one canonical annotated registration; refs resolve after complete mount.
Definition ui_key_info.hpp:10
Public Portals API.
Definition action.hpp:8
@ DISABLED
Recording is stopped; retained evidence remains available.
Definition diagnostics.hpp:72
std::function< std::expected< std::string, TextResourceError >(std::string_view)> KeyTextResolver
Same exact resolver type as ui::TextResolver; used only during checked normalization.
Definition key_binding.hpp:57
KeyEligibility
Eligibility observed for one immutable snapshot, not a universal conflict winner.
Definition key_binding.hpp:81
@ HIDDEN
Explicitly hidden from routing and projections.
Definition key_binding.hpp:84
@ UNBOUND
Identity retained without any key alternatives.
Definition key_binding.hpp:85
@ SCOPE_INACTIVE
Original scope is disconnected, ineligible or outside current focus.
Definition key_binding.hpp:88
@ TERMINAL_UNSUPPORTED
Every annotated phase is explicitly unsupported.
Definition key_binding.hpp:89
@ ELIGIBLE
Eligible for matching; conflict winner still depends on the event.
Definition key_binding.hpp:82
@ OWNER_INELIGIBLE
Live owner or ancestor is hidden or disabled.
Definition key_binding.hpp:86
@ OWNER_RETIRED
Original generational owner no longer exists.
Definition key_binding.hpp:87
KeyConflictKind
Conditional alternative overlap.
Definition key_binding.hpp:92
@ TERMINAL_PREFIX
One alternative ends while the other continues.
Definition key_binding.hpp:94
@ SHARED_PREFIX
Alternatives compete initially and diverge later.
Definition key_binding.hpp:95
@ UNKNOWN
EOF proved that the line does not exist.
Definition document_source.hpp:368
KeySupport
Explicit terminal phase knowledge; UNKNOWN does not suppress routing.
Definition key_binding.hpp:41
@ SUPPORTED
The application declares this native phase supported.
Definition key_binding.hpp:43
@ UNSUPPORTED
The application explicitly excludes this annotated phase.
Definition key_binding.hpp:44
@ UNKNOWN
No explicit support claim; annotated routing remains enabled.
Definition key_binding.hpp:42
NodeId owner
Diagnostic identity only.
Definition key_binding.hpp:130
KeyBindingView(GraphemeText caption, GraphemeText detail)
Definition key_binding.hpp:117
GraphemeText description
Independently owned text.
Definition key_binding.hpp:126
~KeyBindingView()=default
Release independently owned text, alternatives and relations.
GraphemeText label
Empty for unannotated legacy bindings.
Definition key_binding.hpp:125
std::optional< Shortcut > shortcut
Owning normalized alternatives, including sequences.
Definition key_binding.hpp:128
std::vector< KeyConflict > conflicts
Conditional alternative relations.
Definition key_binding.hpp:133
std::optional< KeyEvent > legacy
Original exact legacy key, if any.
Definition key_binding.hpp:127
std::vector< KeyAction > actions
Native admitted phases.
Definition key_binding.hpp:129
KeyEligibility eligibility
Observed admission reason.
Definition key_binding.hpp:132
NodeId scope
Diagnostic identity only.
Definition key_binding.hpp:131
std::size_t ordinal
Display-local registration position.
Definition key_binding.hpp:124
Independent historical read snapshot; scope disconnect is observed on the next UI admission/query.
Definition key_binding.hpp:137
std::vector< KeyBindingView > bindings
Owning rows in registration order.
Definition key_binding.hpp:145
std::uint64_t scopeGeneration
Exact cancellation-identity observation revision.
Definition key_binding.hpp:143
~KeyBindingsSnapshot()=default
Release this historical owning projection.
std::uint64_t revision
Canonical metadata revision.
Definition key_binding.hpp:140
KeyCapabilities capabilities
Explicit phase knowledge.
Definition key_binding.hpp:144
std::uint64_t inputGeneration
Tree eligibility observation.
Definition key_binding.hpp:142
std::uint64_t focusGeneration
Recovered focus observation.
Definition key_binding.hpp:141
Application-supplied native phase support, independent of physical-key identity.
Definition key_binding.hpp:48
KeySupport press
Native PRESS support.
Definition key_binding.hpp:49
KeySupport release
Native RELEASE support.
Definition key_binding.hpp:51
bool operator==(const KeyCapabilities &other) const =default
KeySupport repeat
Native REPEAT support.
Definition key_binding.hpp:50
One bounded pair relation; ordinals refer only to its owning snapshot.
Definition key_binding.hpp:99
std::size_t alternative
This alternative's index.
Definition key_binding.hpp:102
std::size_t sharedStrokes
Number of common leading strokes.
Definition key_binding.hpp:107
std::vector< KeyAction > overlapPhases
Actual overlapping native phases.
Definition key_binding.hpp:111
std::optional< KeyBindingId > otherId
Absent for legacy registrations.
Definition key_binding.hpp:104
std::size_t otherOrdinal
Other row's snapshot ordinal.
Definition key_binding.hpp:103
bool thisIsNewer
Registration priority, independent of scope depth.
Definition key_binding.hpp:108
~KeyConflict()=default
Release this independent owning relation.
std::size_t otherAlternative
Other alternative's index.
Definition key_binding.hpp:105
bool thisTerminalAtPrefix
This alternative ends at the common prefix.
Definition key_binding.hpp:109
bool otherTerminalAtPrefix
Other alternative ends at the common prefix.
Definition key_binding.hpp:110
KeyConflictKind kind
Exact, terminal prefix or shared-prefix competition.
Definition key_binding.hpp:106
TextValue label
Required resolved single-line label.
Definition key_binding.hpp:65
TextValue description
Optional owning explanation.
Definition key_binding.hpp:66
KeyTextResolver resolver
Not retained after successful normalization.
Definition key_binding.hpp:67
KeyInfo(TextValue value)
Definition key_binding.hpp:62
bool visible
Hidden commands neither route nor appear in projections.
Definition key_binding.hpp:71
Node< Widget > owner
Empty selects the scene root.
Definition key_binding.hpp:68
Node< Widget > scope
Empty is global; otherwise an exact declared focus scope.
Definition key_binding.hpp:69
bool enabled
Disabled commands remain visible in full help.
Definition key_binding.hpp:70
Owning identity, independent of addresses; zero is never a live identity.
Definition widget_types.hpp:15