aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-10-18 00:45:42 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-10-18 00:45:42 +0800
commit795126a90d651ede075e9a94741dae4841e4de62 (patch)
tree817f4642c54240f255191dd28124206833f6f561 /include
parent6ac5c86e5d00e65f47a710e31f9c08b6a13f3bce (diff)
downloadrwebbrowser-795126a90d651ede075e9a94741dae4841e4de62.tar.gz
rwebbrowser-795126a90d651ede075e9a94741dae4841e4de62.tar.xz
feat(tui): add structured selection text and clipboard messages
Diffstat (limited to 'include')
-rw-r--r--include/ricochet/tui/messages.hh39
-rw-r--r--include/ricochet/tui/view.hh3
2 files changed, 40 insertions, 2 deletions
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<std::string> 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<SyncTabs,
NavigationStarted,
CommitDocument,
UpdateDocument,
LocateView,
FormFeedback,
+ CopyResult,
ActionFailed,
ExitDecision>;
@@ -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<ViewSnapshot> views {};
};
-using UserAction
- = std::variant<OpenLocation, OpenLink, Navigate, CreateTab, CloseTab, FormAction, ExportSelection, RequestExit>;
+using UserAction = std::variant<OpenLocation,
+ OpenLink,
+ Navigate,
+ CreateTab,
+ CloseTab,
+ FormAction,
+ ExportSelection,
+ CopySelection,
+ RequestExit>;
} // 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