Skip to content

feat: copy cues to the clipboard, and paste lines back over them - #111

Merged
xAlcahest merged 2 commits into
mainfrom
clipboard-group
Sep 7, 2026
Merged

feat: copy cues to the clipboard, and paste lines back over them#111
xAlcahest merged 2 commits into
mainfrom
clipboard-group

Conversation

@xAlcahest

@xAlcahest xAlcahest commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

The clipboard group of the Edit menu: copy cues, paste over cues, select all cues, in the positions the reference's own Edit menu gives them.

The page cannot reach the clipboard at all. Measured on 2026-09-07 inside the app's own page: WebKitGTK answers both navigator.clipboard.writeText and readText with NotAllowedError. So the copy and the read go through the backend and GTK's own clipboard, which is already linked because Tauri pulls gtk in on Linux; nothing new is downloaded for it. Windows gets a stub that returns an error rather than one that silently succeeds, because a stub that succeeded would be a claim about a platform whose behaviour is not run here.

What a copy carries is the raw line and not the text: the cue, its times and its fields, which is what makes it paste back as a cue rather than as a sentence. A paste over reads those lines behind this document's own header, so an ASS event is parsed with the Format: line that names its columns and a VTT cue with the file's first word, and a copy from one document lands in another of the same format spelt that document's way.

A second commit fixes a defect the first one had, found by asking what two cues would do where one had been checked. An SRT or VTT block is followed by a blank line and a copy of two cues left it out, so reading them back gave one cue with the other's words stuck on. The copy now puts the separator between them, and the check copies the whole file over itself and asserts all three rows come home unchanged, which a single cue could never have seen.

One defect came out of it and is fixed here. A document editor gave up every chord a text field owns, a c v x y z, so that Ctrl+Z over a line being typed would be the document's undo. That was right while the shell had no command on the other four. The moment Ctrl+A became one, typing into the grid broke: forty-nine checks went red because selecting a field's text now selected every cue instead. Only the two history chords are taken now, which is what the keyboard spec's two contexts say and what every editor does.

Changes

  • src-tauri/src/clipboard.rs: the system clipboard through GTK on Linux, and a stub that says so anywhere else.
  • src-tauri/src/subtitle/mod.rs: subtitle_copy_cues, which hands back the raw lines, and subtitle_paste_over, which reads a fragment behind this document's own header.
  • src-tauri/src/lib.rs: the four commands registered.
  • src/keyboard.ts: a document editor keeps its own selection and clipboard, and gives up only undo and redo.
  • src/hooks/useSubtitleFile.ts: copyCues, which does not queue behind edits because it changes nothing, and pasteOver.
  • src/App.tsx: the three commands and the two helpers that reach the clipboard.
  • src/i18n/en.ts: their words and their accelerators.
  • e2e/specs/clipboard.spec.js: the greying, select all, the round trip out to the clipboard and back over another row, and the same for two cues with the blank line between them.
  • e2e/specs/command-registry.spec.js: the three in the declared list and the Edit menu.
  • e2e/wdio.conf.js: the count the guard holds.
  • BACKLOG.md: N43, cut and paste and the paste-over dialog; N44, the clipboard on Windows.

How to verify it by using the app

  1. Open fixtures/subtitles/srt/clean/basic-lf.srt. Edit now has Copy cues, Paste over cues and Select all cues.
  2. Click the first row and choose Copy cues. Paste into any other program: the whole cue is there, its number, its times and its line.
  3. Click the third row and choose Paste over cues. The third row now reads the first row's line, and its own times are untouched.
  4. Press Ctrl+Z once. The third row is back.
  5. Choose Select all cues, or press Ctrl+A over the grid. Every row is selected.
  6. Click into the text box and press Ctrl+A there. It selects the words in the box, not the cues, and typing replaces them.
  7. Nothing was written to disk by any of it: the file changes when you save and not before.

Verified on Linux: full gate green step by step, and the battery green at 37 spec files of 37 with 300 checks. Two mutations, each reddening its own check first: a clipboard write that puts an empty string where the lines were, and a copy that leaves out the blank line between two cues.

@xAlcahest
xAlcahest merged commit 4dc177d into main Sep 7, 2026
14 checks passed
@xAlcahest
xAlcahest deleted the clipboard-group branch September 7, 2026 01:59
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