Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
line_edit_text.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/line_edit.hpp>
6
7#include <string_view>
8
9namespace portals::detail {
14constexpr bool hasLineSeparator(std::string_view bytes) noexcept {
15 return bytes.find_first_of("\r\n") != std::string_view::npos || bytes.contains("\xe2\x80\xa8") ||
16 bytes.contains("\xe2\x80\xa9");
17}
18
22constexpr bool validLineEditDisplayMode(LineEditDisplayMode mode) noexcept {
25}
26
32inline std::expected<LineEditPlaceholder, TextError> prepareLineEditPlaceholder(LineEditOptions &options) {
33 if (!options.placeholder || options.placeholder->empty()) {
34 options.placeholder.reset();
35 return LineEditPlaceholder{};
36 }
37
38 auto text = GraphemeText::from(*options.placeholder, options.widthPolicy, options.limits);
39
40 if (!text) {
41 return std::unexpected(text.error());
42 }
43
44 auto prepared = std::make_unique<GraphemeText>(std::move(*text));
45 options.placeholder.reset();
46
47 return LineEditPlaceholder{std::move(prepared)};
48}
49} // namespace portals::detail
static std::expected< GraphemeText, TextError > from(std::string_view bytes, WidthPolicy policy={}, TextLimits limits={})
Validate, segment and measure a single logical UTF-8 buffer.
LineEditDisplayMode
Immutable presentation and outbound clipboard policy; plaintext model/history remain application-owne...
Definition line_edit.hpp:34
@ NORMAL
Render the draft using its actual grapheme widths; copying and cutting retain normal behavior.
Definition line_edit.hpp:35
@ NO_ECHO
Render no value or selection, with a fixed-origin caret and intrinsic width one; suppress copy/cut.
Definition line_edit.hpp:37
@ PASSWORD
Render one ASCII '*' per grapheme, revealing its count; suppress outbound copy/cut.
Definition line_edit.hpp:36
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
Already checked owning placeholder transferred by declarative construction before state publication.
Definition line_edit.hpp:193