From 795126a90d651ede075e9a94741dae4841e4de62 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sun, 18 Oct 2026 00:45:42 +0800 Subject: feat(tui): add structured selection text and clipboard messages --- src/tui/layout.cc | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'src/tui/layout.cc') 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 #include @@ -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; - if constexpr ( std::is_same_v ) { - 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 || std::is_same_v ) { - return control.label; - } else if constexpr ( std::is_same_v ) { - 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 ) { - return control.label; - } else { - return value.description; - } - }, - control.content ); - } - void control_atoms( std::vector& 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, -- cgit v1.2.3