Skip to content

v0.7.0 — text selection and clipboard copy - #7

Merged
borghei merged 1 commit into
mainfrom
release/v0.7.0
Aug 14, 2026
Merged

v0.7.0 — text selection and clipboard copy#7
borghei merged 1 commit into
mainfrom
release/v0.7.0

Conversation

@borghei

@borghei borghei commented Aug 14, 2026

Copy link
Copy Markdown
Owner

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+u move the cursor end and the view follows it; y copies, Esc cancels.
  • Mouse drag selects and copies on release; double-click takes the word, triple-click the line.
  • c labels every code block on screen and copies the one you pick — raw source, no borders, no syntax escapes, no margin.
  • Y copies the current section's markdown source, down to the next heading of the same or higher level. Inside link-hint mode (f), Y flips the labels from "open this link" to "copy this URL".
  • Copies go out over OSC 52 (crosses SSH, wrapped for tmux) and through a native helper (pbcopy, wl-copy, xclip, xsel, clip.exe) when one is on PATH. No new dependencies. [behavior] clipboard = "auto" | "osc52" | "native" | "off" narrows or disables it.
  • New rebindable actions select_mode, select_line_mode, copy_code, copy_section. Visual-mode motions are a fixed table, as with search and slides.
  • Themes gained 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

  • Heading text is stripped of terminal control bytes where it is recorded, not only where it is drawn as a line. A heading carrying an ESC byte reached the TOC sidebar unfiltered before. Fence info strings get the same treatment.

Notes on the implementation

  • Selection lives in document coordinates measured in terminal cells, snapping to grapheme boundaries — scrolling, resize and --watch reloads cannot rot a selection, and a wide CJK glyph or ZWJ emoji is never cut in half.
  • Code blocks nested in lists/blockquotes are deliberately not offered by c: they are laid out in a sub-buffer with no absolute row, so labelling them would point at the wrong line.
  • v/V copy lines as drawn, ink's heading bars included — they select what you can see. c and Y are the tools for source.

QA (all local)

gate result
cargo test ✓ 190 passed
cargo clippy --all-targets -- -D warnings
cargo build --release
cargo check
cargo fmt --check
security review 0 critical / 0 high; OSC 52 payload is base64 so a hostile document cannot break out of the sequence; the native helper takes text on stdin, never through a shell
secret scan 0 hits
code review 1 critical found and fixed before commit: dedent measured 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.
test adequacy +58 tests — selection extraction and column math, clipboard payloads, code-block discovery, section boundaries, screen→document mapping, legacy theme loading, escape stripping

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 every clipboard config mode.

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.
@borghei
borghei merged commit 40a328b into main Aug 14, 2026
7 checks passed
@borghei
borghei deleted the release/v0.7.0 branch August 14, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant