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 --- include/ricochet/tui/messages.hh | 39 +++++++++++++++++++++++++++++++++++++-- include/ricochet/tui/view.hh | 3 +++ 2 files changed, 40 insertions(+), 2 deletions(-) (limited to 'include/ricochet') diff --git a/include/ricochet/tui/messages.hh b/include/ricochet/tui/messages.hh index e7dc417..9d51fa3 100644 --- a/include/ricochet/tui/messages.hh +++ b/include/ricochet/tui/messages.hh @@ -139,12 +139,30 @@ struct ExitDecision std::optional explanation {}; }; +enum class CopyStatus : std::uint8_t +{ + Confirmed, + Dispatched, + Unavailable, + Failed +}; + +// The host's injected clipboard provider completes a CopySelection request once. +// Dispatched must not be used as confirmation that a terminal accepted the text. +struct CopyResult +{ + RequestId request {}; + CopyStatus status { CopyStatus::Unavailable }; + std::string summary {}; +}; + using HostUpdate = std::variant; @@ -220,6 +238,16 @@ struct ExportSelection std::string text {}; }; +struct CopySelection +{ + RequestId request {}; + DocumentScope source {}; + DraftRevision draft_revision {}; + // Frozen before dispatch; later cursor/selection changes cannot change this copy. + // Password content is already masked. Clipboard providers never receive drafts. + std::string text {}; +}; + struct RequestExit { RequestId request {}; @@ -227,7 +255,14 @@ struct RequestExit std::vector views {}; }; -using UserAction - = std::variant; +using UserAction = std::variant; } // namespace ricochet::tui diff --git a/include/ricochet/tui/view.hh b/include/ricochet/tui/view.hh index d259cf3..f5f33d4 100644 --- a/include/ricochet/tui/view.hh +++ b/include/ricochet/tui/view.hh @@ -39,6 +39,9 @@ struct SelectionSnapshot // The normalized half-open range also covers any controls between its endpoints. DocumentRange range {}; SelectionDirection direction { SelectionDirection::Forward }; + // Inclusive endpoint units retain the anchor through reversal and history restore. + DocumentRange anchor {}; + DocumentRange active {}; }; struct HorizontalScroll -- cgit v1.2.3