Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
key_hints.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4#include <portals/help_view.hpp>
5
6namespace portals {
7namespace detail {
8struct KeyHelpPresentation;
9}
10
14 ~KeyHintsOptions() = default;
16 std::string entrySeparator{" "};
17 std::string overflowMarker{"+"};
18 std::string emptyText = std::string(0, '\0');
19 std::string unavailableText{"?"};
20};
21
23class KeyHints : public Button {
24public:
29 : Button(std::move(text), style, policy, ButtonChrome::NONE) {
30 }
31
33 std::expected<CellSize, TreeError> measure(CellSize available) override;
35 std::expected<void, TreeError> arrange(CellRect local) override;
37 std::expected<void, TreeError> paint(PaintContext &context) override;
38
39private:
40 friend struct ui::detail::KeyHelpAccess;
41 std::shared_ptr<detail::KeyHelpPresentation> presentation_;
42 CellRect bounds_;
43};
44
45namespace ui {
49Description<KeyHints> keyHints(Ref<HelpView> help, KeyHintsOptions options = {}, ControlStyle style = {});
50} // namespace ui
51} // namespace portals
One-line button; registration is an explicit caller-owned ActionBinding.
Definition controls.hpp:161
Button(GraphemeText text, ControlStyle style={}, SizePolicy policy=DEFAULT_CONTENT_POLICY)
Construct an owning button with ASCII brackets on UI, normally through tree.emplace.
An owning, invariant-preserving half-open cell rectangle.
Definition geometry.hpp:81
const GraphemeText & text() const
Inspect the control's owning Unicode text on UI.
Owning validated UTF-8 and immutable extended grapheme measurements.
Definition text.hpp:145
KeyHints(GraphemeText text, ControlStyle style={}, SizePolicy policy=DEFAULT_FLEX_WIDTH_POLICY)
Definition key_hints.hpp:28
std::expected< void, TreeError > paint(PaintContext &context) override
std::expected< CellSize, TreeError > measure(CellSize available) override
std::expected< void, TreeError > arrange(CellRect local) override
Borrowed synchronous command sink supplied by the frame owner. submit must consume commands immediate...
Definition widget_types.hpp:66
Public Portals API.
Definition action.hpp:8
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
constexpr SizePolicy DEFAULT_FLEX_WIDTH_POLICY
Fill available width from a zero flex basis while retaining content height.
Definition layout.hpp:47
ButtonChrome
Button caption decoration; action routing and identity remain unchanged.
Definition controls.hpp:155
@ NONE
Caption only, including a single-glyph action button.
Definition controls.hpp:157
An owning available extent in terminal columns/rows.
Definition geometry.hpp:44
Owning paint values; no theme engine or behavior is encoded here.
Definition controls.hpp:24
Owning ASCII-first formatter settings; glyph support is never inferred.
Definition help_view.hpp:9
Single-row compact presentation options, bounded by the canonical registration limit.
Definition key_hints.hpp:12
~KeyHintsOptions()=default
Release the owning compact presentation options.
std::string overflowMarker
Marker followed by the number of omitted discoverable rows.
Definition key_hints.hpp:17
KeyFormatOptions format
Owning bounded formatter options.
Definition key_hints.hpp:15
std::string entrySeparator
Between complete named entries.
Definition key_hints.hpp:16
std::string unavailableText
Failed fresh projection marker, clipped at grapheme boundaries.
Definition key_hints.hpp:19
std::string emptyText
Empty-list presentation, empty by default.
Definition key_hints.hpp:18
Owning independent policies for width and height.
Definition layout.hpp:35