v0.7.0 — text selection and clipboard copy - #7
Merged
Merged
Conversation
ink captures the mouse for wheel-scroll, which meant giving up the terminal's own text selection. It now does the job itself. - v/V start a character- or line-wise selection; hjkl/arrows, w/b, 0/$, g/G and Ctrl+d/Ctrl+u move it, the view follows, y copies, Esc cancels - mouse drag selects and copies on release; double-click takes the word, triple-click the line - c labels the code blocks on screen and copies one's raw source - Y copies the current section's markdown; inside link hints it copies a URL instead of opening it - copies go out over OSC 52 (crosses SSH, wrapped for tmux) and through a native helper when one is on PATH; no new dependencies - selection edges are measured in terminal cells and snap to grapheme boundaries, so a wide glyph is never cut in half - themes gained optional selection_bg/selection_fg; older theme files still load and derive a legible selection from their existing colors Heading text and fence info strings are now sanitized where they are recorded rather than only where they are drawn as lines — they reach the TOC sidebar and the copy status line, neither of which is a StyledLine.
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.
0.7.0 — text selection and clipboard copy
ink captures the mouse for wheel-scroll, which meant giving up the terminal's own text selection. It now does the job itself — and does it better, because it knows where a code block starts and where ink's own decoration ends.
Added
v/V— character-wise / line-wise selection.hjkl/arrows,w/b,0/$,g/G,Ctrl+d/Ctrl+umove the cursor end and the view follows it;ycopies,Esccancels.clabels every code block on screen and copies the one you pick — raw source, no borders, no syntax escapes, no margin.Ycopies the current section's markdown source, down to the next heading of the same or higher level. Inside link-hint mode (f),Yflips the labels from "open this link" to "copy this URL".pbcopy,wl-copy,xclip,xsel,clip.exe) when one is onPATH. No new dependencies.[behavior] clipboard = "auto" | "osc52" | "native" | "off"narrows or disables it.select_mode,select_line_mode,copy_code,copy_section. Visual-mode motions are a fixed table, as with search and slides.selection_bg/selection_fg, both optional — a theme file written before this release still loads and derives a legible selection from its existing colors.Fixed
Notes on the implementation
--watchreloads cannot rot a selection, and a wide CJK glyph or ZWJ emoji is never cut in half.c: they are laid out in a sub-buffer with no absolute row, so labelling them would point at the wrong line.v/Vcopy lines as drawn, ink's heading bars included — they select what you can see.candYare the tools for source.QA (all local)
cargo testcargo clippy --all-targets -- -D warningscargo build --releasecargo checkcargo fmt --checkdedentmeasured the shared indent in bytes and sliced by byte offset, which panics on mixed-width leading whitespace (U+3000 + U+00A0). Now compares the actual character prefix; regression test included.Behaviour was also driven end to end against the real binary in a pty (synthetic keys and SGR mouse events, OSC 52 payload decoded back out of the terminal stream), covering drag, double/triple-click, word motions,
c,Y,f Y, and everyclipboardconfig mode.