mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Add two more extend shortcuts
This commit is contained in:
parent
beec80a7df
commit
7995f9919a
@ -2044,6 +2044,8 @@ 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>
|
||||
<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>
|
||||
<MainCreateStartDownEndUp>Insert new subtitle at key-down, set end time at key-up</MainCreateStartDownEndUp>
|
||||
<MergeDialog>Merge dialog (insert dashes)</MergeDialog>
|
||||
|
@ -2338,6 +2338,8 @@ 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",
|
||||
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",
|
||||
MainCreateStartDownEndUp = "Insert new subtitle at key-down, set end time at key-up",
|
||||
MergeDialog = "Merge dialog (insert dashes)",
|
||||
|
@ -5554,6 +5554,12 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "Settings/AdjustExtendToPreviousSubtitle":
|
||||
language.Settings.AdjustExtendToPreviousSubtitle = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustExtendPreviousLineEndToCurrentStart":
|
||||
language.Settings.AdjustExtendPreviousLineEndToCurrentStart = reader.Value;
|
||||
break;
|
||||
case "Settings/AdjustExtendNextLineStartToCurrentEnd":
|
||||
language.Settings.AdjustExtendNextLineStartToCurrentEnd = reader.Value;
|
||||
break;
|
||||
case "Settings/RecalculateDurationOfCurrentSubtitle":
|
||||
language.Settings.RecalculateDurationOfCurrentSubtitle = reader.Value;
|
||||
break;
|
||||
|
@ -2210,6 +2210,8 @@
|
||||
public string AdjustExtendToPreviousSceneChangeWithGap { get; set; }
|
||||
public string AdjustExtendToNextSubtitle { get; set; }
|
||||
public string AdjustExtendToPreviousSubtitle { get; set; }
|
||||
public string AdjustExtendPreviousLineEndToCurrentStart { get; set; }
|
||||
public string AdjustExtendNextLineStartToCurrentEnd { get; set; }
|
||||
public string RecalculateDurationOfCurrentSubtitle { get; set; }
|
||||
public string MainCreateStartDownEndUp { get; set; }
|
||||
public string MergeDialog { get; set; }
|
||||
|
@ -1938,6 +1938,8 @@ $HorzAlign = Center
|
||||
public string MainAdjustExtendToPreviousSceneChangeWithGap { get; set; }
|
||||
public string MainAdjustExtendToNextSubtitle { get; set; }
|
||||
public string MainAdjustExtendToPreviousSubtitle { get; set; }
|
||||
public string MainAdjustExtendPreviousLineEndToCurrentStart { get; set; }
|
||||
public string MainAdjustExtendNextLineStartToCurrentEnd { get; set; }
|
||||
public string MainInsertAfter { get; set; }
|
||||
public string MainTextBoxAutoBreak { get; set; }
|
||||
public string MainTextBoxBreakAtPosition { get; set; }
|
||||
@ -2106,6 +2108,8 @@ $HorzAlign = Center
|
||||
MainAdjustExtendToPreviousSceneChangeWithGap = string.Empty;
|
||||
MainAdjustExtendToNextSubtitle = "Control+Shift+E";
|
||||
MainAdjustExtendToPreviousSubtitle = "Alt+Shift+E";
|
||||
MainAdjustExtendPreviousLineEndToCurrentStart = string.Empty;
|
||||
MainAdjustExtendNextLineStartToCurrentEnd = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7046,6 +7050,18 @@ $HorzAlign = Center
|
||||
settings.Shortcuts.MainAdjustExtendToPreviousSubtitle = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustExtendPreviousLineEndToCurrentStart");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainAdjustExtendNextLineStartToCurrentEnd");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainInsertAfter");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -8308,6 +8324,8 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("MainAdjustExtendToPreviousSceneChangeWithGap", settings.Shortcuts.MainAdjustExtendToPreviousSceneChangeWithGap);
|
||||
textWriter.WriteElementString("MainAdjustExtendToNextSubtitle", settings.Shortcuts.MainAdjustExtendToNextSubtitle);
|
||||
textWriter.WriteElementString("MainAdjustExtendToPreviousSubtitle", settings.Shortcuts.MainAdjustExtendToPreviousSubtitle);
|
||||
textWriter.WriteElementString("MainAdjustExtendPreviousLineEndToCurrentStart", settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart);
|
||||
textWriter.WriteElementString("MainAdjustExtendNextLineStartToCurrentEnd", settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd);
|
||||
textWriter.WriteElementString("MainInsertAfter", settings.Shortcuts.MainInsertAfter);
|
||||
textWriter.WriteElementString("MainTextBoxAutoBreak", settings.Shortcuts.MainTextBoxAutoBreak);
|
||||
textWriter.WriteElementString("MainTextBoxBreakAtPosition", settings.Shortcuts.MainTextBoxBreakAtPosition);
|
||||
|
@ -14829,6 +14829,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ExtendSelectedLinesToPreviousLine();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart == e.KeyData)
|
||||
{
|
||||
ExtendPreviousEndToCurrentStart();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustExtendNextLineStartToCurrentEnd == e.KeyData)
|
||||
{
|
||||
ExtendNextStartToCurrentEnd();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (_shortcuts.MainAdjustSnapStartToNextSceneChange == e.KeyData)
|
||||
{
|
||||
SnapSelectedLinesStartToNextSceneChange();
|
||||
@ -15193,11 +15203,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var previous = _subtitle.GetParagraphOrDefault(idx - 1);
|
||||
if (previous != null)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle));
|
||||
historyAdded = true;
|
||||
}
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
|
||||
@ -15216,6 +15221,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSubtitle));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
p.StartTime.TotalMilliseconds = previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
|
||||
@ -15223,6 +15235,88 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtendPreviousEndToCurrentStart()
|
||||
{
|
||||
if (SubtitleListview1.SelectedItems.Count == 1)
|
||||
{
|
||||
var historyAdded = false;
|
||||
var idx = SubtitleListview1.SelectedItems[0].Index;
|
||||
var p = _subtitle.Paragraphs[idx];
|
||||
var previous = _subtitle.GetParagraphOrDefault(idx - 1);
|
||||
if (previous != null)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart));
|
||||
historyAdded = true;
|
||||
}
|
||||
previous.EndTime.TotalMilliseconds = p.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 originalPrevious = _subtitleAlternate.GetParagraphOrDefault(_subtitleAlternate.GetIndex(original) - 1);
|
||||
if (originalPrevious != null)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendPreviousLineEndToCurrentStart));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
originalPrevious.EndTime.TotalMilliseconds = original.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(idx - 1, previous, _subtitle.GetParagraphOrDefault(idx), _subtitle.GetParagraphOrDefault(idx - 2));
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtendNextStartToCurrentEnd()
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd));
|
||||
historyAdded = true;
|
||||
}
|
||||
next.StartTime.TotalMilliseconds = p.EndTime.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)
|
||||
{
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendNextLineStartToCurrentEnd));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
originalNext.StartTime.TotalMilliseconds = original.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleListview1.SetStartTimeAndDuration(idx + 1, next, _subtitle.GetParagraphOrDefault(idx + 2), _subtitle.GetParagraphOrDefault(idx));
|
||||
}
|
||||
}
|
||||
|
||||
private void SnapSelectedLinesStartToNextSceneChange(bool withGap = false)
|
||||
{
|
||||
var historyAdded = false;
|
||||
@ -15431,11 +15525,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
double nearestSceneChange = previousSceneChanges.Aggregate((x, y) => Math.Abs(x - p.StartTime.TotalSeconds) < Math.Abs(y - p.StartTime.TotalSeconds) ? x : y);
|
||||
double nearestEndTimeWithGap = previous != null ? previous.EndTime.TotalMilliseconds + Configuration.Settings.General.MinimumMillisecondsBetweenLines : -9999;
|
||||
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(idx, p, _subtitleAlternate.Paragraphs);
|
||||
@ -15461,6 +15550,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (!historyAdded)
|
||||
{
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeX, Configuration.Settings.Language.Settings.AdjustExtendToPreviousSceneChange));
|
||||
historyAdded = true;
|
||||
}
|
||||
|
||||
if (!withGap)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = Math.Max(nearestSceneChange * 1000, nearestEndTimeWithGap);
|
||||
|
@ -1377,6 +1377,8 @@ 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.AdjustExtendPreviousLineEndToCurrentStart, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart));
|
||||
AddNode(createAndAdjustNode, language.AdjustExtendNextLineStartToCurrentEnd, nameof(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd));
|
||||
if (createAndAdjustNode.Nodes.Count > 0)
|
||||
{
|
||||
_shortcuts.Nodes.Add(createAndAdjustNode);
|
||||
|
@ -124,6 +124,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public Keys MainAdjustExtendToPreviousSceneChangeWithGap { get; set; }
|
||||
public Keys MainAdjustExtendToNextSubtitle { get; set; }
|
||||
public Keys MainAdjustExtendToPreviousSubtitle { get; set; }
|
||||
public Keys MainAdjustExtendPreviousLineEndToCurrentStart { get; set; }
|
||||
public Keys MainAdjustExtendNextLineStartToCurrentEnd { get; set; }
|
||||
public Keys MainInsertAfter { get; set; }
|
||||
public Keys MainInsertBefore { get; set; }
|
||||
public Keys MainTextBoxAutoBreak { get; set; }
|
||||
@ -316,6 +318,8 @@ 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);
|
||||
MainAdjustExtendPreviousLineEndToCurrentStart = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendPreviousLineEndToCurrentStart);
|
||||
MainAdjustExtendNextLineStartToCurrentEnd = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainAdjustExtendNextLineStartToCurrentEnd);
|
||||
MainInsertAfter = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainInsertAfter);
|
||||
MainInsertBefore = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainInsertBefore);
|
||||
MainTextBoxAutoBreak = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainTextBoxAutoBreak);
|
||||
|
Loading…
Reference in New Issue
Block a user