diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-10-18 00:45:42 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-10-18 00:45:42 +0800 |
| commit | 795126a90d651ede075e9a94741dae4841e4de62 (patch) | |
| tree | 817f4642c54240f255191dd28124206833f6f561 /src/tui/layout.cc | |
| parent | 6ac5c86e5d00e65f47a710e31f9c08b6a13f3bce (diff) | |
| download | rwebbrowser-795126a90d651ede075e9a94741dae4841e4de62.tar.gz rwebbrowser-795126a90d651ede075e9a94741dae4841e4de62.tar.xz | |
feat(tui): add structured selection text and clipboard messages
Diffstat (limited to 'src/tui/layout.cc')
| -rw-r--r-- | src/tui/layout.cc | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/src/tui/layout.cc b/src/tui/layout.cc index 5aebe17..fa6eaa6 100644 --- a/src/tui/layout.cc +++ b/src/tui/layout.cc @@ -17,6 +17,7 @@ */ #include "layout.hh" +#include "document_text.hh" #include <algorithm> #include <limits> @@ -161,38 +162,6 @@ private: } } - std::string control_text( const Control& control ) const - { - return std::visit( - [this, &control]( const auto& value ) -> std::string { - using Value = std::decay_t<decltype( value )>; - if constexpr ( std::is_same_v<Value, TextControl> ) { - if ( value.kind == TextControlKind::Password ) { - return std::string( text_.analyze( value.value, true, false ).graphemes.size(), '*' ); - } - return value.value; - } else if constexpr ( std::is_same_v<Value, Checkbox> || std::is_same_v<Value, RadioButton> ) { - return control.label; - } else if constexpr ( std::is_same_v<Value, SelectControl> ) { - std::string result; - for ( const auto& option : value.options ) { - if ( std::ranges::find( value.selected, option.id ) != value.selected.end() ) { - if ( !result.empty() ) { - result += ", "; - } - result += option.label; - } - } - return result; - } else if constexpr ( std::is_same_v<Value, Button> ) { - return control.label; - } else { - return value.description; - } - }, - control.content ); - } - void control_atoms( std::vector<Atom>& atoms, ControlId id, TextStyle base ) const { // A missing ID is a malformed document reference; map::at reports it directly. @@ -217,7 +186,7 @@ private: .style = style, .target = id } ); } - const auto display = control_text( control ); + const auto display = control_display_text( control, text_ ); const auto analysis = text_.analyze( display, multiline, false ); for ( const auto& glyph : analysis.graphemes ) { atoms.push_back( { .glyph = glyph, |
