diff options
| author | Zack Drach <zackdrach@gmail.com> | 2026-05-26 03:40:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-26 13:40:29 +0300 |
| commit | 6c4a947244b7be05496f9d3bd5ad2d00a69cca03 (patch) | |
| tree | 421b4a009e2a201c9be65806fd0e13fe9899c73a /src/app/runtime.rs | |
| parent | 33e71ed2f50e5ca8950029f89f41e0ec135b87c0 (diff) | |
Add tmux-style double-click word copy (#296)
* feat: add tmux-style double-click copy
Double-clicking terminal output now selects and copies the token under the cursor, similar to tmux. The copied token briefly stays highlighted as feedback, and token detection handles common shell output like paths, URLs, variables, CJK text, and surrounding punctuation.
Mouse events are still forwarded unchanged when the child terminal has mouse reporting enabled.
refs #142
* fix: tighten double-click copy
refs #142
---------
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/runtime.rs')
| -rw-r--r-- | src/app/runtime.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/app/runtime.rs b/src/app/runtime.rs index 85bdb8dd..bbef7444 100644 --- a/src/app/runtime.rs +++ b/src/app/runtime.rs @@ -179,6 +179,8 @@ impl App { changed = true; } + changed |= self.clear_due_selection_highlight(now); + self.start_git_status_refresh_if_due(now); if self @@ -199,6 +201,28 @@ impl App { changed } + /// Clears temporary copied-token highlights, such as after double-click copy. + pub(crate) fn clear_due_selection_highlight(&mut self, now: Instant) -> bool { + if self + .selection_highlight_clear_deadline + .is_none_or(|deadline| now < deadline) + { + return false; + } + + self.selection_highlight_clear_deadline = None; + if self + .state + .selection + .as_ref() + .is_some_and(|selection| !selection.is_in_progress()) + { + self.state.clear_selection(); + return true; + } + false + } + pub(crate) fn sync_animation_timer(&mut self, now: Instant) { self.sync_animation_timer_with_interval(now, ANIMATION_INTERVAL); } @@ -412,6 +436,7 @@ impl App { self.next_auto_update_check, self.session_save_deadline, self.selection_autoscroll_deadline, + self.selection_highlight_clear_deadline, render_deadline, ] .into_iter() |
