Expand description
Panel-scoped text selection and clipboard copy for ratatui apps.
A terminal’s own click-drag selection can’t be confined to one panel — it spans the full terminal row, sweeping up borders and neighbouring panels. This crate lets an app capture the mouse itself and implement its own selection that is confined to a single panel’s rectangle, uses natural “stream” semantics (never a rectangular block), survives resizes, rewraps and scrolling (selections are stored as logical line/column positions, not stale screen cells), and stays cheap even for multi-megabyte content (only what’s on screen is ever wrapped or painted). On mouse-up the selected text is copied to the system clipboard, working both on a local desktop and over SSH/tmux (OSC 52 fallback).
§Two ways to use it
Batteries-included: SelectablePanel bundles the cache and
selection state into one object with a tiny API — set_content,
begin_selection, extend_selection, selected_text, copy_selection,
highlight_cells, visible_rows. See its module for a worked example.
MultiSelectPanel is a richer sibling for panels that need multiple
selection regions, keyboard extension, owned scrolling with drag
auto-scroll, and styled (syntax-highlighted) content.
Primitives: if your app already owns its selection state (e.g. you support multiple simultaneous selections or keyboard extension), use the stateless building blocks directly:
Re-exports§
pub use multiselect::AutoScroll;pub use multiselect::Motion;pub use multiselect::MultiSelectPanel;pub use panel::MouseAction;pub use panel::MouseConfig;pub use panel::SelectablePanel;pub use terminal::TerminalGuard;pub use wrapcache::PanelWrap;pub use wrapcache::TextPos;pub use wrapcache::WrapMarker;pub use wrapcache::WrapMode;
Modules§
- clipboard
- Copy-on-mouse-up for panel-scoped text selection.
- multiselect
- A batteries-included, multi-region text panel:
MultiSelectPanel. - panel
- A ready-to-use, batteries-included wrapper:
SelectablePanel. - selection
- Mouse (and keyboard-extended) text selection scoped to a single panel (Request JSON / Response).
- terminal
- Panic-safe terminal setup for mouse capture (feature
terminal-guard). - wrap
- Character-exact line wrapping primitives.
- wrapcache
- Shared line/wrap-structure cache backing both the Request JSON and Response panels’ rendering and their text selection.