Skip to content

feat: choose any of a line's four colours at the caret - #101

Merged
2 commits merged into
mainfrom
colour-pickers
Sep 6, 2026
Merged

feat: choose any of a line's four colours at the caret#101
2 commits merged into
mainfrom
colour-pickers

Conversation

@xAlcahest

@xAlcahest xAlcahest commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

The current line's third row now carries the four colour buttons, and each opens a small picker that writes the ASS colour tag where the caret is. It sits on a new Edit::SetOverrideTag in crates/sublore-edit/src/plan.rs, which writes a tag with a value the caller chose rather than one it worked out, and refuses a name that is not a name and a value carrying a brace, because that value would close the block it is written into. Sixteen colours are offered by name and any other is typed as #RRGGBB.

Two defects came out of building it and are fixed here. tags_in read a tag name as a backslash and the letters after it, so \2c, \3c, \4c and the four alphas parsed as nothing at all, and a block holding only one of them read as a note rather than as styling; a name may now carry one digit before its letters, which is the whole of what ASS puts there. And the four style buttons were alive on a format that carries no override tags, where the planner then refused the write; the condition they grey on now carries the format, so the colours and the four flags grey together on an SRT.

Row three's style buttons became the letters B, I, U and S, each drawn in the style it writes. Four more buttons in that row wrapped it at the narrowest window and pushed Next line behind the panel's scroll; the letters take back more room than the colours cost, so the sweep without a waveform is clean at every interface size again and only the 110 per cent floor still needs the scroll, where the controls on either side of the colours were already pinned.

A second commit rides here rather than in a branch of its own, because the check it is aimed at is what blocks this one from going green. useVideoPlayer wrote every answer it got back, whatever file it was about: a command sent against the file that was open could still be in flight when the next one opened, and its refusal then put a sentence on the status bar about a document nobody asked about. Each command now carries the open it belongs to, and an older answer is dropped. Found by reading while looking for BACKLOG N40, the check in video-aspect.spec.js that fails on the runner and never here. Whether it is that check's cause is not proven, and cannot be here: two attempts to reproduce it by taking the audio output away did not.

Changes

  • crates/sublore-formats/src/override_tags.rs: a tag name may carry one digit before its letters, so \2c and \1a are names, and a braced run holding one of them is styling; two tests.
  • crates/sublore-edit/src/plan.rs: Edit::SetOverrideTag and plan_set_override_tag, which write one tag at the caret and refuse a name or a value that could break the line.
  • crates/sublore-edit/src/splice.rs: the edit kind the undo label carries.
  • crates/sublore-edit/tests/session.rs: a tag written and undone, a numbered colour replaced rather than repeated, and the two refusals.
  • src-tauri/src/subtitle/mod.rs: subtitle_set_override_tag, with the tag, the value and the stretch grouped into one value.
  • src-tauri/src/lib.rs: the command registered.
  • src/hooks/useSubtitleFile.ts: setOverrideTag.
  • src/components/CurrentLine.tsx: the four colour buttons, the picker over them with its sixteen colours and its typed field, and the four style buttons drawn as letters.
  • src/App.tsx: one condition for both sets of buttons, now carrying the format, read again where the write happens.
  • src/i18n/en.ts: the four spoken names and the picker's own field.
  • src/styles/tools.css: the two groups of four, the picker, its swatches and its field.
  • e2e/specs/current-line-bands.spec.js: the colour picked and the colour typed, and the pin that records what a short panel does not show at once.
  • e2e/wdio.conf.js: the count the anti-zero guard holds.
  • BACKLOG.md: N39, the font button and the two halves of the picker that are not built.
  • src/hooks/useVideoPlayer.ts: an open counter every command captures before it is sent and every answer is checked against before it writes state.

How to verify it by using the app

  1. Open fixtures/subtitles/ass/clean/speakers.ass.
  2. Click a row. The four small buttons after B I U S are greyed, because there is no caret in the text box yet.
  3. Click in the text box, just before a word. The four wake up.
  4. Click the third of them, Outline colour. A panel of sixteen colours opens under it, with a field below.
  5. Click the red square. The text box now reads {\3c&H0000FF&} before that word.
  6. Press Ctrl+Z once. The tag is gone in one step.
  7. Click the first button, Primary colour, type #12AB34 into its field and press Enter. {\c&H34AB12&} is written at the caret. ASS writes a colour blue first, which is why the digits come back reversed.
  8. Type #12AB instead, with four digits, and press Enter. The field is marked as wrong and nothing is written.
  9. Open an SRT instead of the ASS. All four buttons are still drawn, and all four are greyed: an SRT holds no override tags.

Verified on Linux: full gate green, and the battery green at 33 spec files of 33 with 278 checks. Two mutations each reddened its own check first, the byte order of the colour and the greying rule.

@xAlcahest xAlcahest closed this pull request by merging all changes into main in e60dea8 Sep 6, 2026
@xAlcahest
xAlcahest deleted the colour-pickers branch September 6, 2026 20:18
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