Fix mouse-2 paste and RET in copy mode#254
Merged
Merged
Conversation
Two issues from #251: 1. `<mouse-2>' in semi-char or copy mode silently dropped the click — the bound handler `ghostel--mouse-release' only emits bytes when a DEC mouse-tracking mode (1000/1002/1003) is on, so middle-click paste, the standard X primary-selection paste on Linux, did nothing when no app was tracking. New wrappers `ghostel-mouse-down-2-or-noop' and `ghostel-mouse-paste-primary-or-release' forward to libghostty when tracking is on (TUI behaviour preserved) and otherwise feed `gui-get-primary-selection' to `ghostel--paste-text', which uses bracketed paste at the live prompt. In copy/Emacs mode with `ghostel-readonly-fast-exit' on, the wrapper exits to the prior input mode first so the paste lands at the prompt; with fast-exit off it pastes in place, mirroring `ghostel-yank' / C-y semantics. 2. RET in copy mode was eaten by `text-read-only' once `ghostel-mouse-press-or-copy-mode' (added in #242) flipped the buffer into copy mode on a focus click. Users would press RET expecting a prompt redraw and see nothing happen. New helper `ghostel-readonly-RET-or-exit-and-send' is bound to RET and `<return>' in `ghostel-readonly-fast-exit-mode-map' only. At a hyperlink it still calls `ghostel-open-link-at-point'; otherwise it exits read-only mode and forwards a CR via the encoder (skipped if we are returning to Emacs mode, which is also read-only). Without fast-exit the parent map's `ghostel-open-link-at-point' wins, so users who explicitly opted out of fast-exit see no change. Also: rename `C-c C-l' (exit-and-clear) to `C-c M-l' so the parent map's `ghostel-line-mode' binding is no longer shadowed, and add `C-c C-e' to the fast-exit map for symmetry with the semi-char-mode binding. Tests cover: tracking-on/off forwarding, empty primary, fast-exit on/off auto-exit, RET on/off link, the no-CR-when-returning-to-emacs path, and the keymap-binding gating. Fixes #251.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #251.
<mouse-2>) now pastes the X primary selection at the live prompt via bracketed paste, even when no DEC mouse-tracking mode (1000/1002/1003) is active. Selects the click's window first so middle-clicking an unfocused ghostel window pastes into that terminal, not whichever buffer happened to be current. In copy/Emacs mode withghostel-readonly-fast-exiton, the wrapper exits to the prior input mode first so the paste lands at the prompt.<return>inghostel-readonly-fast-exit-mode-mapno longer feels stuck after Auto-enter copy mode on mouse-1 click when no app tracks the mouse #242 flipped the buffer into copy mode on a focus click. Newghostel-readonly-RET-or-exit-and-sendopens a link at point if there is one, otherwise exits read-only and forwards a CR. Without fast-exit, the parent map'sghostel-open-link-at-pointstill wins.C-c C-ltoC-c M-lin the fast-exit map so the parent'sghostel-line-modebinding is no longer shadowed, and addC-c C-efor symmetry with semi-char mode.Test plan
make -j6 all(78 evil + 161 native + 331 elisp tests, 0 unexpected, lint clean)select-windowretarget regression, RET on/off a link, no-CR when returning to Emacs mode, fast-exit-only RET binding gatingRETin copy mode (with fast-exit) → exits to prior mode and prompt redrawsset -g mouse onand htop still receive forwarded mouse events when tracking is active