Add syntax coloring for gaps that are too short

This commit is contained in:
Martijn van Berkel (Flitskikker) 2019-12-10 18:06:30 +01:00
parent dad17570f0
commit baac6ddf64
8 changed files with 49 additions and 5 deletions

View File

@ -2040,6 +2040,7 @@ can edit in same subtitle file (collaboration)</Information>
<SyntaxColorTextIfTooLong>Color text if too long</SyntaxColorTextIfTooLong>
<SyntaxColorTextMoreThanMaxLines>Color text if more than {0} lines</SyntaxColorTextMoreThanMaxLines>
<SyntaxColorOverlap>Color time code overlap</SyntaxColorOverlap>
<SyntaxColorGap>Color gap if too short</SyntaxColorGap>
<SyntaxErrorColor>Error color</SyntaxErrorColor>
<GoToFirstSelectedLine>Go to first selected line</GoToFirstSelectedLine>
<GoToNextEmptyLine>Go to next empty line</GoToNextEmptyLine>

View File

@ -2334,6 +2334,7 @@ can edit in same subtitle file (collaboration)",
SyntaxColorTextIfTooLong = "Color text if too long",
SyntaxColorTextMoreThanMaxLines = "Color text if more than {0} lines",
SyntaxColorOverlap = "Color time code overlap",
SyntaxColorGap = "Color gap if too short",
SyntaxErrorColor = "Error color",
GoToFirstSelectedLine = "Go to first selected line",
GoToNextEmptyLine = "Go to next empty line",

View File

@ -5542,6 +5542,9 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/SyntaxColorOverlap":
language.Settings.SyntaxColorOverlap = reader.Value;
break;
case "Settings/SyntaxColorGap":
language.Settings.SyntaxColorGap = reader.Value;
break;
case "Settings/SyntaxErrorColor":
language.Settings.SyntaxErrorColor = reader.Value;
break;

View File

@ -2206,6 +2206,7 @@
public string SyntaxColorTextIfTooLong { get; set; }
public string SyntaxColorTextMoreThanMaxLines { get; set; }
public string SyntaxColorOverlap { get; set; }
public string SyntaxColorGap { get; set; }
public string SyntaxErrorColor { get; set; }
public string GoToFirstSelectedLine { get; set; }
public string GoToNextEmptyLine { get; set; }

View File

@ -113,6 +113,7 @@ namespace Nikse.SubtitleEdit.Core
public bool ListViewSyntaxColorDurationBig { get; set; }
public bool ListViewSyntaxColorOverlap { get; set; }
public bool ListViewSyntaxColorLongLines { get; set; }
public bool ListViewSyntaxColorGap { get; set; }
public bool ListViewSyntaxMoreThanXLines { get; set; }
public Color ListViewSyntaxErrorColor { get; set; }
public Color ListViewUnfocusedSelectedColor { get; set; }
@ -292,6 +293,7 @@ namespace Nikse.SubtitleEdit.Core
ListViewSyntaxColorOverlap = true;
ListViewSyntaxColorLongLines = true;
ListViewSyntaxMoreThanXLines = true;
ListViewSyntaxColorGap = true;
ListViewSyntaxErrorColor = Color.FromArgb(255, 180, 150);
ListViewUnfocusedSelectedColor = Color.LightBlue;
ListViewShowColumnEndTime = true;
@ -2735,6 +2737,12 @@ $HorzAlign = Center
settings.Tools.ListViewSyntaxColorOverlap = Convert.ToBoolean(subNode.InnerText);
}
subNode = node.SelectSingleNode("ListViewSyntaxColorGap");
if (subNode != null)
{
settings.Tools.ListViewSyntaxColorGap = Convert.ToBoolean(subNode.InnerText);
}
subNode = node.SelectSingleNode("ListViewSyntaxErrorColor");
if (subNode != null)
{
@ -6214,6 +6222,7 @@ $HorzAlign = Center
textWriter.WriteElementString("ListViewSyntaxColorLongLines", settings.Tools.ListViewSyntaxColorLongLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ListViewSyntaxMoreThanXLines", settings.Tools.ListViewSyntaxMoreThanXLines.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ListViewSyntaxColorOverlap", settings.Tools.ListViewSyntaxColorOverlap.ToString(CultureInfo.InvariantCulture));
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("ListViewShowColumnEndTime", settings.Tools.ListViewShowColumnEndTime.ToString(CultureInfo.InvariantCulture));

View File

@ -1351,6 +1351,19 @@ namespace Nikse.SubtitleEdit.Controls
}
}
if (_settings.Tools.ListViewSyntaxColorGap && i >= 0 && i < paragraphs.Count - 1 && ColumnIndexGap >= 0)
{
Paragraph next = paragraphs[i + 1];
if (next.StartTime.TotalMilliseconds - paragraph.EndTime.TotalMilliseconds < Configuration.Settings.General.MinimumMillisecondsBetweenLines)
{
item.SubItems[ColumnIndexGap].BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
}
else
{
item.SubItems[ColumnIndexGap].BackColor = BackColor;
}
}
if (ColumnIndexTextAlternate >= 0 && item.SubItems.Count >= ColumnIndexTextAlternate)
{
item.SubItems[ColumnIndexTextAlternate].BackColor = BackColor;

View File

@ -103,6 +103,7 @@
this.labelShortcut = new System.Windows.Forms.Label();
this.tabPageSyntaxColoring = new System.Windows.Forms.TabPage();
this.groupBoxListViewSyntaxColoring = new System.Windows.Forms.GroupBox();
this.checkBoxSyntaxColorGapTooSmall = new System.Windows.Forms.CheckBox();
this.checkBoxSyntaxColorTextMoreThanTwoLines = new System.Windows.Forms.CheckBox();
this.checkBoxSyntaxOverlap = new System.Windows.Forms.CheckBox();
this.checkBoxSyntaxColorDurationTooSmall = new System.Windows.Forms.CheckBox();
@ -1528,6 +1529,7 @@
this.groupBoxListViewSyntaxColoring.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorGapTooSmall);
this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorTextMoreThanTwoLines);
this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxOverlap);
this.groupBoxListViewSyntaxColoring.Controls.Add(this.checkBoxSyntaxColorDurationTooSmall);
@ -1542,6 +1544,16 @@
this.groupBoxListViewSyntaxColoring.TabStop = false;
this.groupBoxListViewSyntaxColoring.Text = "List view syntax coloring";
//
// checkBoxSyntaxColorGapTooSmall
//
this.checkBoxSyntaxColorGapTooSmall.AutoSize = true;
this.checkBoxSyntaxColorGapTooSmall.Location = new System.Drawing.Point(20, 186);
this.checkBoxSyntaxColorGapTooSmall.Name = "checkBoxSyntaxColorGapTooSmall";
this.checkBoxSyntaxColorGapTooSmall.Size = new System.Drawing.Size(132, 17);
this.checkBoxSyntaxColorGapTooSmall.TabIndex = 6;
this.checkBoxSyntaxColorGapTooSmall.Text = "Gap - color if too small";
this.checkBoxSyntaxColorGapTooSmall.UseVisualStyleBackColor = true;
//
// checkBoxSyntaxColorTextMoreThanTwoLines
//
this.checkBoxSyntaxColorTextMoreThanTwoLines.AutoSize = true;
@ -1555,7 +1567,7 @@
// checkBoxSyntaxOverlap
//
this.checkBoxSyntaxOverlap.AutoSize = true;
this.checkBoxSyntaxOverlap.Location = new System.Drawing.Point(20, 154);
this.checkBoxSyntaxOverlap.Location = new System.Drawing.Point(20, 151);
this.checkBoxSyntaxOverlap.Name = "checkBoxSyntaxOverlap";
this.checkBoxSyntaxOverlap.Size = new System.Drawing.Size(129, 17);
this.checkBoxSyntaxOverlap.TabIndex = 5;
@ -1574,10 +1586,10 @@
//
// buttonListViewSyntaxColorError
//
this.buttonListViewSyntaxColorError.Location = new System.Drawing.Point(20, 192);
this.buttonListViewSyntaxColorError.Location = new System.Drawing.Point(20, 224);
this.buttonListViewSyntaxColorError.Name = "buttonListViewSyntaxColorError";
this.buttonListViewSyntaxColorError.Size = new System.Drawing.Size(112, 21);
this.buttonListViewSyntaxColorError.TabIndex = 6;
this.buttonListViewSyntaxColorError.TabIndex = 7;
this.buttonListViewSyntaxColorError.Text = "Error color";
this.buttonListViewSyntaxColorError.UseVisualStyleBackColor = true;
this.buttonListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click);
@ -1605,10 +1617,10 @@
// panelListViewSyntaxColorError
//
this.panelListViewSyntaxColorError.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelListViewSyntaxColorError.Location = new System.Drawing.Point(142, 192);
this.panelListViewSyntaxColorError.Location = new System.Drawing.Point(142, 224);
this.panelListViewSyntaxColorError.Name = "panelListViewSyntaxColorError";
this.panelListViewSyntaxColorError.Size = new System.Drawing.Size(21, 20);
this.panelListViewSyntaxColorError.TabIndex = 7;
this.panelListViewSyntaxColorError.TabIndex = 8;
this.panelListViewSyntaxColorError.Click += new System.EventHandler(this.buttonListViewSyntaxColorError_Click);
//
// tabPageVideoPlayer
@ -4905,5 +4917,6 @@
private System.Windows.Forms.NumericUpDown numericUpDownToolsBreakPreferBottomHeavy;
private System.Windows.Forms.CheckBox checkBoxToolsBreakPreferBottomHeavy;
private System.Windows.Forms.Label labelToolsBreakBottomHeavyPercent;
private System.Windows.Forms.CheckBox checkBoxSyntaxColorGapTooSmall;
}
}

View File

@ -305,6 +305,7 @@ namespace Nikse.SubtitleEdit.Forms
numericUpDownMaxNumberOfLines.Value = Configuration.Settings.General.MaxNumberOfLines;
}
checkBoxSyntaxOverlap.Checked = Configuration.Settings.Tools.ListViewSyntaxColorOverlap;
checkBoxSyntaxColorGapTooSmall.Checked = Configuration.Settings.Tools.ListViewSyntaxColorGap;
panelListViewSyntaxColorError.BackColor = Configuration.Settings.Tools.ListViewSyntaxErrorColor;
// Language
@ -901,6 +902,7 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxSyntaxColorTextTooLong.Text = language.SyntaxColorTextIfTooLong;
checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(language.SyntaxColorTextMoreThanMaxLines, Configuration.Settings.General.MaxNumberOfLines);
checkBoxSyntaxOverlap.Text = language.SyntaxColorOverlap;
checkBoxSyntaxColorGapTooSmall.Text = language.SyntaxColorGap;
buttonListViewSyntaxColorError.Text = language.SyntaxErrorColor;
UiUtil.FixLargeFonts(this, buttonOK);
@ -1682,6 +1684,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Tools.ListViewSyntaxColorLongLines = checkBoxSyntaxColorTextTooLong.Checked;
Configuration.Settings.Tools.ListViewSyntaxMoreThanXLines = checkBoxSyntaxColorTextMoreThanTwoLines.Checked;
Configuration.Settings.Tools.ListViewSyntaxColorOverlap = checkBoxSyntaxOverlap.Checked;
Configuration.Settings.Tools.ListViewSyntaxColorGap = checkBoxSyntaxColorGapTooSmall.Checked;
Configuration.Settings.Tools.ListViewSyntaxErrorColor = panelListViewSyntaxColorError.BackColor;
Configuration.Settings.VideoControls.WaveformDrawGrid = checkBoxWaveformShowGrid.Checked;