mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Add toggle color shortcuts - thx Jan :)
This commit is contained in:
parent
29a5260866
commit
63c67f888f
@ -152,6 +152,10 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
public bool ListViewSyntaxMoreThanXLines { get; set; }
|
||||
public Color ListViewSyntaxErrorColor { get; set; }
|
||||
public Color ListViewUnfocusedSelectedColor { get; set; }
|
||||
public Color Color1ForShortcut { get; set; }
|
||||
public Color Color2ForShortcut { get; set; }
|
||||
public Color Color3ForShortcut { get; set; }
|
||||
public Color Color4ForShortcut { get; set; }
|
||||
public bool ListViewShowColumnEndTime { get; set; }
|
||||
public bool ListViewShowColumnDuration { get; set; }
|
||||
public bool ListViewShowColumnCharsPerSec { get; set; }
|
||||
@ -354,6 +358,10 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
ListViewSyntaxColorGap = true;
|
||||
ListViewSyntaxErrorColor = Color.FromArgb(255, 180, 150);
|
||||
ListViewUnfocusedSelectedColor = Color.LightBlue;
|
||||
Color1ForShortcut = Color.Yellow;
|
||||
Color2ForShortcut = Color.Red;
|
||||
Color3ForShortcut = Color.Green;
|
||||
Color4ForShortcut = Color.Cyan;
|
||||
ListViewShowColumnEndTime = true;
|
||||
ListViewShowColumnDuration = true;
|
||||
SplitAdvanced = false;
|
||||
@ -1897,6 +1905,10 @@ $HorzAlign = Center
|
||||
public string MainListViewAlignmentN7 { get; set; }
|
||||
public string MainListViewAlignmentN8 { get; set; }
|
||||
public string MainListViewAlignmentN9 { get; set; }
|
||||
public string MainListViewColor1 { get; set; }
|
||||
public string MainListViewColor2 { get; set; }
|
||||
public string MainListViewColor3 { get; set; }
|
||||
public string MainListViewColor4 { get; set; }
|
||||
public string MainRemoveFormatting { get; set; }
|
||||
public string MainListViewCopyText { get; set; }
|
||||
public string MainListViewCopyTextFromOriginalToCurrent { get; set; }
|
||||
@ -3783,6 +3795,30 @@ $HorzAlign = Center
|
||||
settings.Tools.ListViewUnfocusedSelectedColor = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("Color1ForShortcut");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.Color1ForShortcut = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("Color2ForShortcut");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.Color2ForShortcut = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("Color3ForShortcut");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.Color3ForShortcut = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("Color4ForShortcut");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.Color4ForShortcut = Color.FromArgb(int.Parse(subNode.InnerText, CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("ListViewShowColumnEndTime");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -6917,6 +6953,30 @@ $HorzAlign = Center
|
||||
shortcuts.MainListViewAlignmentN9 = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewColor1");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.MainListViewColor1 = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewColor2");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.MainListViewColor2 = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewColor3");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.MainListViewColor3 = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainListViewColor4");
|
||||
if (subNode != null)
|
||||
{
|
||||
shortcuts.MainListViewColor4 = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("MainRemoveFormatting");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -7876,6 +7936,10 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("ListViewSyntaxColorGap", settings.Tools.ListViewSyntaxColorGap.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ListViewSyntaxErrorColor", settings.Tools.ListViewSyntaxErrorColor.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ListViewUnfocusedSelectedColor", settings.Tools.ListViewUnfocusedSelectedColor.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("Color1ForShortcut", settings.Tools.Color1ForShortcut.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("Color2ForShortcut", settings.Tools.Color2ForShortcut.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("Color3ForShortcut", settings.Tools.Color3ForShortcut.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("Color4ForShortcut", settings.Tools.Color4ForShortcut.ToArgb().ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ListViewShowColumnEndTime", settings.Tools.ListViewShowColumnEndTime.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ListViewShowColumnDuration", settings.Tools.ListViewShowColumnDuration.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ListViewShowColumnCharsPerSec", settings.Tools.ListViewShowColumnCharsPerSec.ToString(CultureInfo.InvariantCulture));
|
||||
@ -8467,6 +8531,10 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("MainListViewAlignmentN7", shortcuts.MainListViewAlignmentN7);
|
||||
textWriter.WriteElementString("MainListViewAlignmentN8", shortcuts.MainListViewAlignmentN8);
|
||||
textWriter.WriteElementString("MainListViewAlignmentN9", shortcuts.MainListViewAlignmentN9);
|
||||
textWriter.WriteElementString("MainListViewColor1", shortcuts.MainListViewColor1);
|
||||
textWriter.WriteElementString("MainListViewColor2", shortcuts.MainListViewColor2);
|
||||
textWriter.WriteElementString("MainListViewColor3", shortcuts.MainListViewColor3);
|
||||
textWriter.WriteElementString("MainListViewColor4", shortcuts.MainListViewColor4);
|
||||
textWriter.WriteElementString("MainRemoveFormatting", shortcuts.MainRemoveFormatting);
|
||||
textWriter.WriteElementString("MainListViewCopyText", shortcuts.MainListViewCopyText);
|
||||
textWriter.WriteElementString("MainListViewCopyTextFromOriginalToCurrent", shortcuts.MainListViewCopyTextFromOriginalToCurrent);
|
||||
|
@ -2487,6 +2487,7 @@ can edit in same subtitle file (collaboration)",
|
||||
AlignmentN7 = "Alignment top left - {\\an7}",
|
||||
AlignmentN8 = "Alignment top center - {\\an8}",
|
||||
AlignmentN9 = "Alignment top right - {\\an9}",
|
||||
ColorX = "Color {0} ({1})",
|
||||
CopyTextOnly = "Copy text only to clipboard (selected lines)",
|
||||
CopyTextOnlyFromOriginalToCurrent = "Copy text from original to current",
|
||||
AutoDurationSelectedLines = "Auto-duration (selected lines)",
|
||||
|
@ -2347,6 +2347,7 @@
|
||||
public string AlignmentN7 { get; set; }
|
||||
public string AlignmentN8 { get; set; }
|
||||
public string AlignmentN9 { get; set; }
|
||||
public string ColorX { get; set; }
|
||||
public string CopyTextOnly { get; set; }
|
||||
public string CopyTextOnlyFromOriginalToCurrent { get; set; }
|
||||
public string AutoDurationSelectedLines { get; set; }
|
||||
|
@ -32,13 +32,13 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
private TextBox _textBox;
|
||||
private int _mouseMoveSelectionLength;
|
||||
private WebBrowserEditBox _htmlBox;
|
||||
private bool _useWebBrowser = false;
|
||||
|
||||
public SETextBox()
|
||||
{
|
||||
Initialize(Configuration.Settings.General.SubtitleTextBoxSyntaxColor);
|
||||
}
|
||||
|
||||
private bool _useWebBrowser = false;
|
||||
public void Initialize(bool useSyntaxColoring)
|
||||
{
|
||||
ContextMenuStrip oldContextMenuStrip = null;
|
||||
|
@ -17,7 +17,7 @@ namespace Nikse.SubtitleEdit.Controls.WebBrowser
|
||||
private bool _center;
|
||||
private long _lastKeyOrClick = -1;
|
||||
private bool _lastKeyOrClickActivity;
|
||||
private System.Windows.Forms.Timer _timerSyntaxColor;
|
||||
private readonly System.Windows.Forms.Timer _timerSyntaxColor;
|
||||
|
||||
public new event EventHandler TextChanged;
|
||||
public new event KeyEventHandler KeyDown;
|
||||
|
@ -626,6 +626,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetAlignment("{\\an9}", false);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor1)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color1ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor2)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color2ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor3)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color3ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor4)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color4ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeWaveformZoomDropdown()
|
||||
@ -9501,6 +9521,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetAlignment("{\\an9}", false);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor1)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color1ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor2)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color2ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor3)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color3ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor4)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color4ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewToggleMusicSymbols)
|
||||
{
|
||||
textBoxListViewText.Text = ToogleMusicSymbols("♪", textBoxListViewText.Text);
|
||||
@ -11842,29 +11882,57 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
color = Utilities.ColorToHex(colorDialog1.Color);
|
||||
}
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeSettingColor);
|
||||
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
|
||||
SetListViewColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetListViewColor(string color)
|
||||
{
|
||||
MakeHistoryForUndo(_language.BeforeSettingColor);
|
||||
var remove = true;
|
||||
|
||||
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(item.Index);
|
||||
if (p != null)
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(item.Index);
|
||||
if (p != null)
|
||||
var s = Utilities.RemoveSsaTags(p.Text);
|
||||
if (!s.StartsWith("<font ", StringComparison.OrdinalIgnoreCase) || !s.Contains(color, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
remove = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
|
||||
{
|
||||
var p = _subtitle.GetParagraphOrDefault(item.Index);
|
||||
if (p != null)
|
||||
{
|
||||
if (remove)
|
||||
{
|
||||
p.Text = HtmlUtil.RemoveOpenCloseTags(p.Text, HtmlUtil.TagFont);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFontColor(p, color);
|
||||
SubtitleListview1.SetText(item.Index, p.Text);
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible)
|
||||
}
|
||||
|
||||
SubtitleListview1.SetText(item.Index, p.Text);
|
||||
if (_subtitleAlternate != null && Configuration.Settings.General.AllowEditOfOriginalSubtitle && SubtitleListview1.IsAlternateTextColumnVisible)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
var original = Utilities.GetOriginalParagraph(item.Index, p, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
SetFontColor(original, color);
|
||||
SubtitleListview1.SetAlternateText(item.Index, original.Text);
|
||||
}
|
||||
SetFontColor(original, color);
|
||||
SubtitleListview1.SetAlternateText(item.Index, original.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshSelectedParagraph();
|
||||
|
||||
}
|
||||
|
||||
RefreshSelectedParagraph();
|
||||
}
|
||||
|
||||
private static void SetFontColor(Paragraph p, string color)
|
||||
@ -17277,6 +17345,26 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SetAlignment("{\\an9}", true);
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor1)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color1ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor2)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color2ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor3)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color3ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewColor4)
|
||||
{
|
||||
SetListViewColor(ColorTranslator.ToHtml(Configuration.Settings.Tools.Color4ForShortcut));
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
else if (e.KeyData == _shortcuts.MainListViewFocusWaveform)
|
||||
{
|
||||
if (audioVisualizer.CanFocus)
|
||||
@ -25293,7 +25381,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
int extraNewLineLength = Environment.NewLine.Length - 1;
|
||||
|
||||
|
||||
int lineBreakPos = text.IndexOf(Environment.NewLine, StringComparison.Ordinal);
|
||||
int pos = textBox.SelectionStart;
|
||||
var s = HtmlUtil.RemoveHtmlTags(text, true).Replace(Environment.NewLine, string.Empty); // we don't count new line in total length... correct?
|
||||
|
@ -1283,6 +1283,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
AddNode(listViewAndTextBoxNode, language.AlignmentN7, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN7));
|
||||
AddNode(listViewAndTextBoxNode, language.AlignmentN8, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN8));
|
||||
AddNode(listViewAndTextBoxNode, language.AlignmentN9, nameof(Configuration.Settings.Shortcuts.MainListViewAlignmentN9));
|
||||
AddNode(listViewAndTextBoxNode, string.Format(language.ColorX, "1", ColorTranslator.ToHtml(Configuration.Settings.Tools.Color1ForShortcut)), nameof(Configuration.Settings.Shortcuts.MainListViewColor1));
|
||||
AddNode(listViewAndTextBoxNode, string.Format(language.ColorX, "2", ColorTranslator.ToHtml(Configuration.Settings.Tools.Color2ForShortcut)), nameof(Configuration.Settings.Shortcuts.MainListViewColor2));
|
||||
AddNode(listViewAndTextBoxNode, string.Format(language.ColorX, "3", ColorTranslator.ToHtml(Configuration.Settings.Tools.Color3ForShortcut)), nameof(Configuration.Settings.Shortcuts.MainListViewColor3));
|
||||
AddNode(listViewAndTextBoxNode, string.Format(language.ColorX, "4", ColorTranslator.ToHtml(Configuration.Settings.Tools.Color4ForShortcut)), nameof(Configuration.Settings.Shortcuts.MainListViewColor4));
|
||||
AddNode(listViewAndTextBoxNode, Configuration.Settings.Language.Main.Menu.ContextMenu.RemoveFormattingAll, nameof(Configuration.Settings.Shortcuts.MainRemoveFormatting), true);
|
||||
AddNode(listViewAndTextBoxNode, language.RemoveTimeCodes, nameof(Configuration.Settings.Shortcuts.MainListViewRemoveTimeCodes));
|
||||
if (listViewAndTextBoxNode.Nodes.Count > 0)
|
||||
|
@ -154,6 +154,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public Keys MainListViewAlignmentN7 { get; set; }
|
||||
public Keys MainListViewAlignmentN8 { get; set; }
|
||||
public Keys MainListViewAlignmentN9 { get; set; }
|
||||
public Keys MainListViewColor1 { get; set; }
|
||||
public Keys MainListViewColor2 { get; set; }
|
||||
public Keys MainListViewColor3 { get; set; }
|
||||
public Keys MainListViewColor4 { get; set; }
|
||||
public Keys MainListViewFocusWaveform { get; set; }
|
||||
public Keys MainListViewGoToNextError { get; set; }
|
||||
public Keys MainListViewRemoveTimeCodes { get; set; }
|
||||
@ -268,6 +272,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MainListViewAlignmentN7 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignmentN7);
|
||||
MainListViewAlignmentN8 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignmentN8);
|
||||
MainListViewAlignmentN9 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewAlignmentN9);
|
||||
MainListViewColor1 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColor1);
|
||||
MainListViewColor2 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColor2);
|
||||
MainListViewColor3 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColor3);
|
||||
MainListViewColor4 = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewColor4);
|
||||
MainListViewFocusWaveform = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewFocusWaveform);
|
||||
MainListViewGoToNextError = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewGoToNextError);
|
||||
MainListViewRemoveTimeCodes = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewRemoveTimeCodes);
|
||||
|
Loading…
Reference in New Issue
Block a user