Add Unbreak / Auto-break / Split-rebalance / Evenly distribute to Selected Lines menu#11400
Merged
Merged
Conversation
…ed Lines menu
Four line-shaping operations were missing from the SubtitleGrid >
Selected Lines context submenu:
* Unbreak — wires existing UnbreakCommand to a menu entry. Reuses
Se.Language.General.Unbreak ("Unbreak text").
* Auto-break — wires existing AutoBreakCommand. Reuses
Se.Language.General.AutoBreak ("Auto-break text").
* Split/rebalance long lines — new
ShowToolsSplitBreakLongLinesSelectedLinesCommand opens the existing
SplitBreakLongLines dialog scoped to the current selection. On OK,
the selected items are removed from Subtitles and the dialog's
AllSubtitlesFixed result is spliced in at the lowest selected index.
Non-contiguous selections are compacted together at that index.
Reuses Se.Language.Main.Menu.SplitBreakLongLines.
* Evenly distribute lines (by CPS) — new
EvenlyDistributeSelectedLinesCommand ports the SE4 algorithm
(Forms/Main.cs:22773-22822). The span from the first selected
paragraph's start to the last selected paragraph's end is split
proportionally to each paragraph's character count (CPS-equalizing
redistribution), packing the result back-to-back with the configured
minimum gap between lines. Visible only when more than one line is
selected (HasMultipleLinesSelected binding). New strings:
Main.Menu.EvenlyDistributeLines and the status string
Main.NumberOfLinesEvenlyDistributedX.
Menu group is separated above and below by horizontal dividers to keep
the line-shaping operations together and away from the unrelated
entries.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues: 1. Pre-existing bug in SplitBreakLongLinesViewModel.UpdatePreview: the rebalance pass computed `rebalancedText` but never assigned it back to `item.Text`, so the dialog reported "X lines rebalanced" but the AllSubtitlesFixed output kept the original text. The bug affected the existing Tools menu entry too — only the split path actually mutated text. Add the missing `item.Text = rebalancedText` inside the change-detected branch. 2. ShowToolsSplitBreakLongLinesSelectedLines used Remove+Insert in a loop to splice the dialog result back into Subtitles. Switch to the standard Clear+AddRange pattern used everywhere else in this file: rebuild Subtitles by walking the original list in order, replacing the run of selected items with the dialog's AllSubtitlesFixed at the position of the first selected item, then Clear+AddRange. Same behavior for the common contiguous-selection case, but matches the project convention and avoids per-item ObservableCollection churn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Four line-shaping operations were missing from SubtitleGrid → Selected Lines in the context menu. This PR wires the existing
UnbreakandAutoBreakcommands into the submenu, adds a "Split/rebalance long lines…" entry that opens the existing Tools dialog scoped to the selected lines, and ports SE4's "Evenly distribute lines" as a new command.Changes
Unbreak / Auto-break (one-line additions)
The view-model methods already exist (
MainViewModel.cs:10704/10721) and iterateSubtitleGrid.SelectedItems. Just added menu entries bound toUnbreakCommand/AutoBreakCommand. ReusesSe.Language.General.UnbreakandSe.Language.General.AutoBreak(which already exist in every translation).Split/rebalance long lines (new — opens existing dialog scoped to selection)
ShowToolsSplitBreakLongLinesSelectedLinesCommand:SplitBreakLongLinesWindowwith only the selectedSubtitleLineViewModels.Subtitlesand splices the dialog'sAllSubtitlesFixedresult in at the lowest selected index.Non-contiguous selections are compacted together at that index. The existing full-subtitle entry under Tools menu is unchanged. Reuses
Se.Language.Main.Menu.SplitBreakLongLines.Evenly distribute lines (by CPS) — new, ported from SE4
EvenlyDistributeSelectedLinesCommandportsForms/Main.cs:22773-22822fromse4-legacy. Algorithm:(SelectedCount - 1) × MinimumBetweenLines.CountCharacters(true)(CPS-equalizing redistribution).Only visible when more than one line is selected (
HasMultipleLinesSelectedbinding). New language strings:Main.Menu.EvenlyDistributeLines= "Evenly distribute lines (by CPS)"Main.NumberOfLinesEvenlyDistributedX= "Evenly distributed {0} lines" (status message)Menu structure
The four new entries are wrapped in
Separators to keep line-shaping operations together and away from the unrelated entries above and below:Test plan
🤖 Generated with Claude Code