Skip to content

feat: edit a declared style from the panel - #109

Merged
xAlcahest merged 2 commits into
mainfrom
style-editor
Sep 7, 2026
Merged

feat: edit a declared style from the panel#109
xAlcahest merged 2 commits into
mainfrom
style-editor

Conversation

@xAlcahest

Copy link
Copy Markdown
Owner

Summary

Edit beside the Style dropdown, which row one of the reference puts right after it and Sublore had nowhere. It opens a dialog over the shell holding the style's font, size, four colours and four flags, and each field is one write and one undo step.

It needed the first edit in this repository that changes no cue at all. Edit::SetStyleField splices the span the parser recorded for that column, and its expectation says no cue changed, which verify then proves by reading every one of them back and comparing. That is not ceremony: a style line that swallowed a comma would shift every column of every event under it, and this is the only place that would be seen. The check saves the file and compares every Dialogue: line byte for byte.

To make the flags writable the parser had to record where they sit, not only what they say, so AssStyle now carries the four spans beside the four booleans: a reader wants the meaning and a writer wants the bytes. And the patch every edit answers with now carries the styles, because a style write changes no cue and nothing else in that shape would tell the interface that one moved.

Two things are deliberately not in it, and both are filed rather than implied. The name is not a field: renaming a style means rewriting every event that names it, which is a different operation with its own undo step. And the dialog holds ten of a style's twenty-three columns, because the parser reads ten; the rest are not drawn as empty boxes, they are simply not there. That is BACKLOG N42.

Changes

  • crates/sublore-formats/src/document.rs and ass.rs: the four flag spans beside the four booleans.
  • crates/sublore-edit/src/plan.rs: AssStyleField, Edit::SetStyleField and plan_set_style_field, whose expectation asserts that not one cue moved.
  • crates/sublore-edit/src/splice.rs: its own edit kind and its own row, so a style write and a cue write are never one undo step.
  • crates/sublore-edit/tests/session.rs: the write and its undo, the refusals, and a style the document does not declare.
  • src-tauri/src/subtitle/mod.rs: subtitle_set_style_field, and the styles carried on every patch.
  • src-tauri/src/lib.rs: the command registered.
  • src/types/subtitle.ts: the field names and the styles on the patch.
  • src/hooks/useSubtitleFile.ts: setStyleField, and the patch's styles reaching the summary.
  • src/components/StyleEditor.tsx: the dialog, over the shell like About and closed the same three ways.
  • src/components/CurrentLine.tsx: Edit, right after the dropdown.
  • src/App.tsx: the dialog raised over the style the line names, and dropped if that style goes.
  • src/i18n/en.ts, src/styles/chrome.css, src/styles/tools.css: the words and the shape.
  • e2e/specs/style-editor.spec.js: three checks, the strongest of which saves and compares every event line.
  • e2e/specs/current-line-bands.spec.js: the reach pins, which grew because the first band now wraps at the narrow window.
  • e2e/wdio.conf.js: the count the guard holds.
  • BACKLOG.md: N42, the thirteen columns the parser does not read yet.

How to verify it by using the app

  1. Open fixtures/subtitles/ass/clean/basic.ass. Beside the Style dropdown there is an Edit button.
  2. Click it. A panel opens titled Default, with the font, the size and the four colours as the file spells them, and four checkboxes under them.
  3. Type a font name and press Enter. Close the panel and press Ctrl+S.
  4. Open the saved file in a text editor: the Style: line carries the new font, and every Dialogue: line is exactly the bytes it was.
  5. Open the panel again and tick Bold. Save. The style line's bold column is now -1 and the font is still there.
  6. Press Ctrl+Z. Open the panel once more: Bold is off again and the font is still what you typed, because each field is its own step.
  7. Move to a row whose style the file does not declare. Edit greys, because there is nothing to open it on.

Verified on Linux: full gate green step by step, and the battery green at 36 spec files of 36 with 295 checks. One mutation, a bold flag written into the font's own column, reddened the flag check first.

@xAlcahest
xAlcahest merged commit cab4db5 into main Sep 7, 2026
14 checks passed
@xAlcahest
xAlcahest deleted the style-editor branch September 7, 2026 00:06

@cakedsnowhites cakedsnowhites left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

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.

2 participants