feat: bold, italic, underline and strikeout, written into the line's own text - #100
Merged
Conversation
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.
Summary
The panel gains the four inline style buttons. Select a word and press Bold and the word is wrapped in the tags that make it bold; press it again and the tags come off. With no selection the tag is written at the caret and takes effect to the end of the line. Each is its own undo step, and bold and italic on one line never merge into one.
The whole of it is one rule. The flag starts wherever the style the line names sets it, any tag already in force at the caret overrides that, and the opposite value is written there; then, for a selection, the original value is written back at the far end, shifted by however many bytes the first write inserted. That shift is why the writer returns one, and it is what the tag writer landed for.
It is planned and applied in Rust, not computed in the panel.
Edit::ToggleStylenames the cue, the flag and the two offsets, and everything that could corrupt a line happens behind the same plan, splice, re-parse and verify every other edit goes through. The panel's part is to say where the selection is, which it already reported for splitting and now reports both ends of.Verified on Linux: full gate green, battery green at 276 of 276, four Rust tests over the edit and one behavioural check over the button. The check was made to fail before being believed: with the far end of the selection ignored, "wraps the selected words in a style tag" reddens first, on a build seen compiling.
Changes
StyleFlagnames the four and says which tag carries each and what a style sets it to,flag_valuereads a tag's value, and the caret on a block boundary now takes the braced side, so a caret just past a closing brace is inside the block that closed rather than in the words after it.Edit::ToggleStyleandplan_toggle_style, which is the rule above.EditKind::ToggleStyle, carrying which flag, so two flags on one line are two steps.subtitle_toggle_styleand its registration.toggleStyleand the flag name it takes.EXPECTED_TESTSto 276.How to verify it by using the app
fixtures/subtitles/ass/clean/speakers.ass.harbour, then press Bold. The text becomesThe {\b1}harbour{\b0} freezes over by December.