Rename and move "Extend current line" to a separate method

And group it with the other Extend shortcuts.
This commit is contained in:
OmrSi 2020-10-09 04:35:52 +03:00
parent 7995f9919a
commit fdd6e7dd77
8 changed files with 75 additions and 72 deletions

View File

@ -2033,7 +2033,6 @@ can edit in same subtitle file (collaboration)</Information>
<AdjustSetStartTimeKeepDuration>Set start time, keep duration</AdjustSetStartTimeKeepDuration>
<AdjustSetEndAndOffsetTheRest>Set end, offset the rest</AdjustSetEndAndOffsetTheRest>
<AdjustSetEndAndOffsetTheRestAndGoToNext>Set end, offset the rest and go to next</AdjustSetEndAndOffsetTheRestAndGoToNext>
<AdjustExtendCurrentSubtitle>Extend current line to next subtitle or max duration</AdjustExtendCurrentSubtitle>
<AdjustSnapStartToNextSceneChange>Snap selected lines start to next scene change</AdjustSnapStartToNextSceneChange>
<AdjustSnapStartToNextSceneChangeWithGap>Snap selected lines start to next scene change with min. gap</AdjustSnapStartToNextSceneChangeWithGap>
<AdjustSnapEndToPreviousSceneChange>Snap selected lines end to previous scene change</AdjustSnapEndToPreviousSceneChange>
@ -2044,6 +2043,7 @@ can edit in same subtitle file (collaboration)</Information>
<AdjustExtendToPreviousSceneChangeWithGap>Extend selected lines to previous scene change with min. gap (or previous subtitle)</AdjustExtendToPreviousSceneChangeWithGap>
<AdjustExtendToNextSubtitle>Extend selected lines to next subtitle</AdjustExtendToNextSubtitle>
<AdjustExtendToPreviousSubtitle>Extend selected lines to previous subtitle</AdjustExtendToPreviousSubtitle>
<AdjustExtendCurrentSubtitle>Extend current line to next subtitle or max duration</AdjustExtendCurrentSubtitle>
<AdjustExtendPreviousLineEndToCurrentStart>Extend previous line's end to current's start</AdjustExtendPreviousLineEndToCurrentStart>
<AdjustExtendNextLineStartToCurrentEnd>Extend next line's start to current's end</AdjustExtendNextLineStartToCurrentEnd>
<RecalculateDurationOfCurrentSubtitle>Re-calculate duration of current subtitle</RecalculateDurationOfCurrentSubtitle>

View File

@ -2327,7 +2327,6 @@ can edit in same subtitle file (collaboration)",
AdjustSetStartTimeKeepDuration = "Set start time, keep duration",
AdjustSetEndAndOffsetTheRest = "Set end, offset the rest",
AdjustSetEndAndOffsetTheRestAndGoToNext = "Set end, offset the rest and go to next",
AdjustExtendCurrentSubtitle = "Extend current line to next subtitle or max duration",
AdjustSnapStartToNextSceneChange = "Snap selected lines start to next scene change",
AdjustSnapStartToNextSceneChangeWithGap = "Snap selected lines start to next scene change with min. gap",
AdjustSnapEndToPreviousSceneChange = "Snap selected lines end to previous scene change",
@ -2338,6 +2337,7 @@ can edit in same subtitle file (collaboration)",
AdjustExtendToPreviousSceneChangeWithGap = "Extend selected lines to previous scene change with min. gap (or previous subtitle)",
AdjustExtendToNextSubtitle = "Extend selected lines to next subtitle",
AdjustExtendToPreviousSubtitle = "Extend selected lines to previous subtitle",
AdjustExtendCurrentSubtitle = "Extend current line to next subtitle or max duration",
AdjustExtendPreviousLineEndToCurrentStart = "Extend previous line's end to current's start",
AdjustExtendNextLineStartToCurrentEnd = "Extend next line's start to current's end",
RecalculateDurationOfCurrentSubtitle = "Re-calculate duration of current subtitle",

View File

@ -5521,9 +5521,6 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/AdjustSetEndAndOffsetTheRestAndGoToNext":
language.Settings.AdjustSetEndAndOffsetTheRestAndGoToNext = reader.Value;
break;
case "Settings/AdjustExtendCurrentSubtitle":
language.Settings.AdjustExtendCurrentSubtitle = reader.Value;
break;
case "Settings/AdjustSnapStartToNextSceneChange":
language.Settings.AdjustSnapStartToNextSceneChange = reader.Value;
break;
@ -5554,6 +5551,9 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/AdjustExtendToPreviousSubtitle":
language.Settings.AdjustExtendToPreviousSubtitle = reader.Value;
break;
case "Settings/AdjustExtendCurrentSubtitle":
language.Settings.AdjustExtendCurrentSubtitle = reader.Value;
break;
case "Settings/AdjustExtendPreviousLineEndToCurrentStart":
language.Settings.AdjustExtendPreviousLineEndToCurrentStart = reader.Value;
break;

View File

@ -2199,7 +2199,6 @@
public string AdjustSetStartTimeKeepDuration { get; set; }
public string AdjustSetEndAndOffsetTheRest { get; set; }
public string AdjustSetEndAndOffsetTheRestAndGoToNext { get; set; }
public string AdjustExtendCurrentSubtitle { get; set; }
public string AdjustSnapStartToNextSceneChange { get; set; }
public string AdjustSnapStartToNextSceneChangeWithGap { get; set; }
public string AdjustSnapEndToPreviousSceneChange { get; set; }
@ -2210,6 +2209,7 @@
public string AdjustExtendToPreviousSceneChangeWithGap { get; set; }
public string AdjustExtendToNextSubtitle { get; set; }
public string AdjustExtendToPreviousSubtitle { get; set; }
public string AdjustExtendCurrentSubtitle { get; set; }
public string AdjustExtendPreviousLineEndToCurrentStart { get; set; }
public string AdjustExtendNextLineStartToCurrentEnd { get; set; }
public string RecalculateDurationOfCurrentSubtitle { get; set; }

View File

@ -1749,7 +1749,6 @@ $HorzAlign = Center
public string GeneralGoToNextSubtitleAndFocusVideo { get; set; }
public string GeneralGoToPrevSubtitleAndPlay { get; set; }
public string GeneralGoToNextSubtitleAndPlay { get; set; }
public string GeneralExtendCurrentSubtitle { get; set; }
public string GeneralAutoCalcCurrentDuration { get; set; }
public string GeneralPlayFirstSelected { get; set; }
public string GeneralHelp { get; set; }
@ -1938,6 +1937,7 @@ $HorzAlign = Center
public string MainAdjustExtendToPreviousSceneChangeWithGap { get; set; }
public string MainAdjustExtendToNextSubtitle { get; set; }
public string MainAdjustExtendToPreviousSubtitle { get; set; }
public string MainAdjustExtendCurrentSubtitle { get; set; }
public string MainAdjustExtendPreviousLineEndToCurrentStart { get; set; }
public string MainAdjustExtendNextLineStartToCurrentEnd { get; set; }
public string MainInsertAfter { get; set; }
@ -2086,7 +2086,6 @@ $HorzAlign = Center
WaveformPlaySelectionEnd = string.Empty;
GeneralGoToNextSubtitleAndFocusVideo = string.Empty;
GeneralGoToPreviousSubtitleAndFocusVideo = string.Empty;
GeneralExtendCurrentSubtitle = string.Empty;
GeneralAutoCalcCurrentDuration = string.Empty;
GeneralPlayFirstSelected = string.Empty;
GeneralHelp = "F1";
@ -2108,6 +2107,7 @@ $HorzAlign = Center
MainAdjustExtendToPreviousSceneChangeWithGap = string.Empty;
MainAdjustExtendToNextSubtitle = "Control+Shift+E";
MainAdjustExtendToPreviousSubtitle = "Alt+Shift+E";
MainAdjustExtendCurrentSubtitle = string.Empty;
MainAdjustExtendPreviousLineEndToCurrentStart = string.Empty;
MainAdjustExtendNextLineStartToCurrentEnd = string.Empty;
}
@ -5917,12 +5917,6 @@ $HorzAlign = Center
settings.Shortcuts.GeneralGoToPreviousSubtitleAndFocusVideo = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralExtendCurrentSubtitle");
if (subNode != null)
{
settings.Shortcuts.GeneralExtendCurrentSubtitle = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralAutoCalcCurrentDuration");
if (subNode != null)
{
@ -7050,6 +7044,12 @@ $HorzAlign = Center
settings.Shortcuts.MainAdjustExtendToPreviousSubtitle = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainAdjustExtendCurrentSubtitle");
if (subNode != null)
{
settings.Shortcuts.MainAdjustExtendCurrentSubtitle = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainAdjustExtendPreviousLineEndToCurrentStart");
if (subNode != null)
{
@ -8136,7 +8136,6 @@ $HorzAlign = Center
textWriter.WriteElementString("GeneralGoToNextSubtitleAndFocusVideo", settings.Shortcuts.GeneralGoToNextSubtitleAndFocusVideo);
textWriter.WriteElementString("GeneralGoToPrevSubtitleAndPlay", settings.Shortcuts.GeneralGoToPrevSubtitleAndPlay);
textWriter.WriteElementString("GeneralGoToNextSubtitleAndPlay", settings.Shortcuts.GeneralGoToNextSubtitleAndPlay);
textWriter.WriteElementString("GeneralExtendCurrentSubtitle", settings.Shortcuts.GeneralExtendCurrentSubtitle);
textWriter.WriteElementString("GeneralAutoCalcCurrentDuration", settings.Shortcuts.GeneralAutoCalcCurrentDuration);
textWriter.WriteElementString("GeneralPlayFirstSelected", settings.Shortcuts.GeneralPlayFirstSelected);
textWriter.WriteElementString("GeneralHelp", settings.Shortcuts.GeneralHelp);
@ -8324,6 +8323,7 @@ $HorzAlign = Center
textWriter.WriteElementString("MainAdjustExtendToPreviousSceneChangeWithGap", settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap);
textWriter.WriteElementString("MainAdjustExtendToNextSubtitle", settings.Shortcuts.MainAdjustExtendToNextSubtitle);
textWriter.WriteElementString("MainAdjustExtendToPreviousSubtitle", settings.Shortcuts.MainAdjustExtendToPreviousSubtitle);
textWriter.WriteElementString("MainAdjustExtendCurrentSubtitle", settings.Shortcuts.MainAdjustExtendCurrentSubtitle);
textWriter.WriteElementString("MainAdjustExtendPreviousLineEndToCurrentStart", settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart);
textWriter.WriteElementString("MainAdjustExtendNextLineStartToCurrentEnd", settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd);
textWriter.WriteElementString("MainInsertAfter", settings.Shortcuts.MainInsertAfter);

View File

@ -14760,65 +14760,16 @@ namespace Nikse.SubtitleEdit.Forms
_makeHistoryPaused = false;
}
}
else if (_shortcuts.MainAdjustExtendCurrentSubtitle == e.KeyData)
{
if (SubtitleListview1.SelectedItems.Count == 1)
{
var historyAdded = false;
var idx = SubtitleListview1.SelectedItems[0].Index;
var p = _subtitle.Paragraphs[idx];
var next = _subtitle.GetParagraphOrDefault(idx + 1);
if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
historyAdded = true;
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
}
else
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
historyAdded = true;
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
{
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1);
if (originalNext == null || originalNext.StartTime.TotalMilliseconds > original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines)
{
if (!historyAdded)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
}
original.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
}
else
{
if (!historyAdded)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
}
original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
}
}
RefreshSelectedParagraph();
e.SuppressKeyPress = true;
}
e.SuppressKeyPress = true;
}
else if (e.KeyCode == Keys.F3 && e.Modifiers == Keys.Shift)
{
FindPrevious();
e.SuppressKeyPress = true;
}
else if (_shortcuts.MainAdjustExtendCurrentSubtitle == e.KeyData)
{
ExtendCurrentSubtitle();
e.SuppressKeyPress = true;
}
else if (_shortcuts.MainAdjustExtendToNextSubtitle == e.KeyData)
{
ExtendSelectedLinesToNextLine();
@ -15152,6 +15103,58 @@ namespace Nikse.SubtitleEdit.Forms
// put new entries above tabs
}
private void ExtendCurrentSubtitle()
{
if (SubtitleListview1.SelectedItems.Count == 1)
{
var historyAdded = false;
var idx = SubtitleListview1.SelectedItems[0].Index;
var p = _subtitle.Paragraphs[idx];
var next = _subtitle.GetParagraphOrDefault(idx + 1);
if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
historyAdded = true;
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
}
else
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
historyAdded = true;
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
{
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
if (original != null)
{
var originalNext = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) + 1);
if (originalNext == null || originalNext.StartTime.TotalMilliseconds > original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines)
{
if (!historyAdded)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
}
original.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds + Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds;
}
else
{
if (!historyAdded)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendCurrentSubtitle));
}
original.EndTime.TotalMilliseconds = originalNext.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
}
}
}
RefreshSelectedParagraph();
}
}
private void ExtendSelectedLinesToNextLine()
{
var historyAdded = false;

View File

@ -1351,7 +1351,6 @@ namespace Nikse.SubtitleEdit.Forms
AddNode(createAndAdjustNode, language.AdjustSetEndNextStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustSetEndNextStartAndGoToNext));
AddNode(createAndAdjustNode, language.AdjustViaEndAutoStart, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStart));
AddNode(createAndAdjustNode, language.AdjustViaEndAutoStartAndGoToNext, nameof(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStartAndGoToNext));
AddNode(createAndAdjustNode, language.AdjustExtendCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.GeneralExtendCurrentSubtitle));
AddNode(createAndAdjustNode, language.AdjustSelected100MsBack, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack));
AddNode(createAndAdjustNode, language.AdjustSelected100MsForward, nameof(Configuration.Settings.Shortcuts.MainAdjustSelected100MsForward));
AddNode(createAndAdjustNode, string.Format(language.AdjustStartXMsBack, Configuration.Settings.Tools.MoveStartEndMs), nameof(Configuration.Settings.Shortcuts.MainAdjustStartXMsBack));
@ -1377,6 +1376,7 @@ namespace Nikse.SubtitleEdit.Forms
AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSceneChangeWithGap, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap));
AddNode(createAndAdjustNode, language.AdjustExtendToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSubtitle));
AddNode(createAndAdjustNode, language.AdjustExtendToPreviousSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSubtitle));
AddNode(createAndAdjustNode, language.AdjustExtendCurrentSubtitle, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendCurrentSubtitle));
AddNode(createAndAdjustNode, language.AdjustExtendPreviousLineEndToCurrentStart, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart));
AddNode(createAndAdjustNode, language.AdjustExtendNextLineStartToCurrentEnd, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd));
if (createAndAdjustNode.Nodes.Count > 0)

View File

@ -62,7 +62,6 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainGoToNextSubtitleAndFocusVideo { get; set; }
public Keys MainGoToPrevSubtitleAndPlay { get; set; }
public Keys MainGoToNextSubtitleAndPlay { get; set; }
public Keys MainAdjustExtendCurrentSubtitle { get; set; }
public Keys MainAutoCalcCurrentDuration { get; set; }
public Keys MainUnbreakNoSpace { get; set; }
public Keys MainGeneralToggleBookmarks { get; set; }
@ -124,6 +123,7 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainAdjustExtendToPreviousSceneChangeWithGap { get; set; }
public Keys MainAdjustExtendToNextSubtitle { get; set; }
public Keys MainAdjustExtendToPreviousSubtitle { get; set; }
public Keys MainAdjustExtendCurrentSubtitle { get; set; }
public Keys MainAdjustExtendPreviousLineEndToCurrentStart { get; set; }
public Keys MainAdjustExtendNextLineStartToCurrentEnd { get; set; }
public Keys MainInsertAfter { get; set; }
@ -231,7 +231,6 @@ namespace Nikse.SubtitleEdit.Logic
MainGoToNextSubtitleAndFocusVideo = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndFocusVideo);
MainGoToPrevSubtitleAndPlay = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPrevSubtitleAndPlay);
MainGoToNextSubtitleAndPlay = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndPlay);
MainAdjustExtendCurrentSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralExtendCurrentSubtitle);
MainAutoCalcCurrentDuration = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralAutoCalcCurrentDuration);
MainUnbreakNoSpace = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralUnbrekNoSpace);
MainGeneralToggleBookmarks = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralToggleBookmarks);
@ -318,6 +317,7 @@ namespace Nikse.SubtitleEdit.Logic
MainAdjustExtendToPreviousSceneChangeWithGap = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap);
MainAdjustExtendToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToNextSubtitle);
MainAdjustExtendToPreviousSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendToPreviousSubtitle);
MainAdjustExtendCurrentSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendCurrentSubtitle);
MainAdjustExtendPreviousLineEndToCurrentStart = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart);
MainAdjustExtendNextLineStartToCurrentEnd = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd);
MainInsertAfter = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainInsertAfter);