This commit is contained in:
Nikolaj Olsson 2021-04-09 15:59:38 +02:00
commit 17fba4b214

View File

@ -3791,6 +3791,19 @@ namespace Nikse.SubtitleEdit.Forms
reopenToolStripMenuItem.DropDownItems.AddRange(dropDownItems.ToArray());
UiUtil.FixFonts(reopenToolStripMenuItem);
var tss = new ToolStripSeparator();
UiUtil.FixFonts(tss);
reopenToolStripMenuItem.DropDownItems.Add(tss);
var clearHistoryMenuItem = new ToolStripMenuItem(LanguageSettings.Current.DvdSubRip.Clear);
clearHistoryMenuItem.Click += (sender, args) =>
{
Configuration.Settings.RecentFiles.Files.Clear();
UpdateRecentFilesUI();
};
UiUtil.FixFonts(clearHistoryMenuItem);
reopenToolStripMenuItem.DropDownItems.Add(clearHistoryMenuItem);
}
else
{
@ -3835,12 +3848,20 @@ namespace Nikse.SubtitleEdit.Forms
{
Configuration.Settings.RecentFiles.Files = Configuration.Settings.RecentFiles.Files
.Where(p => !notExistingFiles.Contains(p.FileName)).ToList();
for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--)
if (Configuration.Settings.RecentFiles.Files.Count == 0)
{
ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index];
if (notExistingFiles.Contains((string)item.Tag))
reopenToolStripMenuItem.DropDownItems.Clear();
reopenToolStripMenuItem.Visible = false;
}
else
{
for (var index = reopenToolStripMenuItem.DropDownItems.Count - 1; index >= 0; index--)
{
reopenToolStripMenuItem.DropDownItems.RemoveAt(index);
ToolStripItem item = reopenToolStripMenuItem.DropDownItems[index];
if (notExistingFiles.Contains((string)item.Tag))
{
reopenToolStripMenuItem.DropDownItems.RemoveAt(index);
}
}
}
}
@ -7748,9 +7769,11 @@ namespace Nikse.SubtitleEdit.Forms
cm.Items.Add(tss);
// End time
var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(LanguageSettings.Current.General.EndTime);
contextMenuStripLvHeaderEndTimeToolStripMenuItem.CheckOnClick = true;
contextMenuStripLvHeaderEndTimeToolStripMenuItem.Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime;
var contextMenuStripLvHeaderEndTimeToolStripMenuItem = new ToolStripMenuItem(LanguageSettings.Current.General.EndTime)
{
CheckOnClick = true,
Checked = Configuration.Settings.Tools.ListViewShowColumnEndTime
};
contextMenuStripLvHeaderEndTimeToolStripMenuItem.Click += (sender2, e2) =>
{
SubtitleListview1.BeginUpdate();
@ -9691,30 +9714,12 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition)
{
var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
if (text != textBoxListViewText.Text)
{
MakeHistoryForUndo(string.Format(_language.BeforeReplace, LanguageSettings.Current.Settings.MainTextBoxAutoBreakFromPos));
textBoxListViewText.Text = text;
var lines = textBoxListViewText.Text.SplitToLines();
if (lines.Count > 0)
{
textBoxListViewText.SelectionStart = lines[0].Length;
}
}
AutoBreakAtFirstSpaceFromPos(textBoxListViewText);
e.SuppressKeyPress = true;
}
else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPositionAndGoToNext)
{
var text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
if (text != textBoxListViewText.Text)
{
MakeHistoryForUndo(string.Format(_language.BeforeReplace, LanguageSettings.Current.Settings.MainTextBoxAutoBreakFromPosAndGoToNext));
textBoxListViewText.Text = text;
ButtonNextClick(null, null);
}
AutoBreakAtFirstSpaceFromPos(textBoxListViewText, true);
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I)
@ -12096,6 +12101,29 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void AutoBreakAtFirstSpaceFromPos(SETextBox textBox, bool goToNext = false)
{
var text = Utilities.ReSplit(textBox.Text, textBox.SelectionStart);
if (text != textBox.Text)
{
MakeHistoryForUndo(string.Format(_language.BeforeX, LanguageSettings.Current.Settings.MainTextBoxAutoBreakFromPos));
textBox.Text = text;
if (goToNext)
{
ButtonNextClick(null, null);
}
else
{
var lines = textBox.Text.SplitToLines();
if (lines.Count > 0)
{
textBox.SelectionStart = lines[0].Length;
}
}
}
}
private void SwitchView(Control view)
{
if (InSourceView)
@ -24910,19 +24938,12 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPosition)
{
textBoxListViewTextOriginal.Text = Utilities.ReSplit(textBoxListViewTextOriginal.Text, textBoxListViewTextOriginal.SelectionStart);
var lines = textBoxListViewTextOriginal.Text.SplitToLines();
if (lines.Count > 0)
{
textBoxListViewTextOriginal.SelectionStart = lines[0].Length;
}
AutoBreakAtFirstSpaceFromPos(textBoxListViewTextOriginal);
e.SuppressKeyPress = true;
}
else if (e.KeyData == _shortcuts.MainTextBoxBreakAtCursorPositionAndGoToNext)
{
textBoxListViewText.Text = Utilities.ReSplit(textBoxListViewText.Text, textBoxListViewText.SelectionStart);
ButtonNextClick(null, null);
AutoBreakAtFirstSpaceFromPos(textBoxListViewTextOriginal, true);
e.SuppressKeyPress = true;
}
else if (e.Modifiers == Keys.Alt && e.KeyCode == Keys.I)