mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 06:52:35 +01:00
Bug fix in "Remove text for HI" + suspicious fixes now colored in the list view - thx Alice :)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1764 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
90f66d00aa
commit
48f6da9da9
@ -13,6 +13,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
Subtitle _subtitle;
|
Subtitle _subtitle;
|
||||||
readonly LanguageStructure.RemoveTextFromHearImpaired _language;
|
readonly LanguageStructure.RemoveTextFromHearImpaired _language;
|
||||||
private List<string> _interjectionList;
|
private List<string> _interjectionList;
|
||||||
|
private List<int> _warnings;
|
||||||
|
private int _warningIndex;
|
||||||
|
|
||||||
public FormRemoveTextForHearImpaired()
|
public FormRemoveTextForHearImpaired()
|
||||||
{
|
{
|
||||||
@ -220,11 +222,20 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
GeneratePreview();
|
GeneratePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddWarning()
|
||||||
|
{
|
||||||
|
if (_warnings == null || _warningIndex < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_warnings.Add(_warningIndex);
|
||||||
|
}
|
||||||
|
|
||||||
private void GeneratePreview()
|
private void GeneratePreview()
|
||||||
{
|
{
|
||||||
if (_subtitle == null)
|
if (_subtitle == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
_warnings = new List<int>();
|
||||||
listViewFixes.BeginUpdate();
|
listViewFixes.BeginUpdate();
|
||||||
listViewFixes.Items.Clear();
|
listViewFixes.Items.Clear();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -237,6 +248,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
prevText = prev.Text;
|
prevText = prev.Text;
|
||||||
prevIndex++;
|
prevIndex++;
|
||||||
|
|
||||||
|
_warningIndex = prevIndex;
|
||||||
string newText = RemoveTextFromHearImpaired(p.Text, prevText);
|
string newText = RemoveTextFromHearImpaired(p.Text, prevText);
|
||||||
bool hit = p.Text.Replace(" ", string.Empty) != newText.Replace(" ", string.Empty);
|
bool hit = p.Text.Replace(" ", string.Empty) != newText.Replace(" ", string.Empty);
|
||||||
if (hit)
|
if (hit)
|
||||||
@ -324,7 +336,37 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
StripableText st = new StripableText(pre);
|
StripableText st = new StripableText(pre);
|
||||||
if (Utilities.CountTagInText(s, ":") == 1)
|
if (count == 1 && Utilities.CountTagInText(text, Environment.NewLine) == 1 && removedInFirstLine && Utilities.CountTagInText(s, ":") == 1 &&
|
||||||
|
!newText.EndsWith(".") && !newText.EndsWith("!") && !newText.EndsWith("?") && !newText.EndsWith(".</i>") && !newText.EndsWith("!</i>") && !newText.EndsWith("?</i>") &&
|
||||||
|
s != s.ToUpper())
|
||||||
|
{
|
||||||
|
if (pre.Contains("<i>") && s.Contains("</i>"))
|
||||||
|
newText = newText + Environment.NewLine + "<i>" + s;
|
||||||
|
else if (pre.Contains("<b>") && s.Contains("</b>"))
|
||||||
|
newText = newText + Environment.NewLine + "<b>" + s;
|
||||||
|
else if (pre.Contains("[") && s.Contains("]"))
|
||||||
|
newText = newText + Environment.NewLine + "[" + s;
|
||||||
|
else if (pre.Contains("(") && s.EndsWith(")"))
|
||||||
|
newText = newText + Environment.NewLine + "(" + s;
|
||||||
|
else
|
||||||
|
newText = newText + Environment.NewLine + s;
|
||||||
|
}
|
||||||
|
else if (count == 1 && Utilities.CountTagInText(text, Environment.NewLine) == 1 && indexOfColon > 15 && s.Substring(0, indexOfColon).Contains(" ") && Utilities.CountTagInText(s, ":") == 1 &&
|
||||||
|
!newText.EndsWith(".") && !newText.EndsWith("!") && !newText.EndsWith("?") && !newText.EndsWith(".</i>") && !newText.EndsWith("!</i>") && !newText.EndsWith("?</i>") &&
|
||||||
|
s != s.ToUpper())
|
||||||
|
{
|
||||||
|
if (pre.Contains("<i>") && s.Contains("</i>"))
|
||||||
|
newText = newText + Environment.NewLine + "<i>" + s;
|
||||||
|
else if (pre.Contains("<b>") && s.Contains("</b>"))
|
||||||
|
newText = newText + Environment.NewLine + "<b>" + s;
|
||||||
|
else if (pre.Contains("[") && s.Contains("]"))
|
||||||
|
newText = newText + Environment.NewLine + "[" + s;
|
||||||
|
else if (pre.Contains("(") && s.EndsWith(")"))
|
||||||
|
newText = newText + Environment.NewLine + "(" + s;
|
||||||
|
else
|
||||||
|
newText = newText + Environment.NewLine + s;
|
||||||
|
}
|
||||||
|
else if (Utilities.CountTagInText(s, ":") == 1)
|
||||||
{
|
{
|
||||||
bool remove = true;
|
bool remove = true;
|
||||||
if (indexOfColon > 0 && indexOfColon < s.Length - 1)
|
if (indexOfColon > 0 && indexOfColon < s.Length - 1)
|
||||||
@ -679,20 +721,38 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
text = text.TrimEnd(" ()[]?{}".ToCharArray());
|
text = text.TrimEnd(" ()[]?{}".ToCharArray());
|
||||||
text = text.TrimStart(" ()[]?{}".ToCharArray());
|
text = text.TrimStart(" ()[]?{}".ToCharArray());
|
||||||
|
|
||||||
|
if (text.Trim().Replace("mr. ", string.Empty).Replace("mrs. ", string.Empty).Replace("dr. ", string.Empty).Contains(" "))
|
||||||
|
AddWarning();
|
||||||
|
|
||||||
if (text == "sighing" ||
|
if (text == "sighing" ||
|
||||||
text == "laughs" ||
|
text == "cackles" ||
|
||||||
|
text == "cheers" ||
|
||||||
|
text == "chitters" ||
|
||||||
text == "chuckles" ||
|
text == "chuckles" ||
|
||||||
|
text == "exclaims" ||
|
||||||
|
text == "gasps" ||
|
||||||
|
text == "grunts" ||
|
||||||
|
text == "groans" ||
|
||||||
|
text == "growls" ||
|
||||||
|
text == "explosion" ||
|
||||||
|
text == "laughs" ||
|
||||||
|
text == "noise" ||
|
||||||
|
text.StartsWith("engine ") ||
|
||||||
|
text == "roars" ||
|
||||||
text == "scoff" ||
|
text == "scoff" ||
|
||||||
|
text == "screeches" ||
|
||||||
|
text == "shouts" ||
|
||||||
|
text == "shrieks" ||
|
||||||
|
text == "sigh" ||
|
||||||
text == "sighs" ||
|
text == "sighs" ||
|
||||||
|
text == "singing" ||
|
||||||
|
text == "snores" ||
|
||||||
|
text == "stutters" ||
|
||||||
|
text == "thuds" ||
|
||||||
|
text == "trumpets" ||
|
||||||
text == "whispers" ||
|
text == "whispers" ||
|
||||||
text == "whisper" ||
|
text == "whisper" ||
|
||||||
text == "grunts" ||
|
text == "whistles" ||
|
||||||
text == "explosion" ||
|
|
||||||
text == "noise" ||
|
|
||||||
text == "exclaims" ||
|
|
||||||
text.StartsWith("engine ") ||
|
|
||||||
text == "singing" ||
|
|
||||||
text == "stutters" ||
|
|
||||||
text.EndsWith("ing"))
|
text.EndsWith("ing"))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@ -914,7 +974,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
private void AddToListView(Paragraph p, string newText)
|
private void AddToListView(Paragraph p, string newText)
|
||||||
{
|
{
|
||||||
var item = new ListViewItem(string.Empty) {Tag = p, Checked = true};
|
var item = new ListViewItem(string.Empty) {Tag = p, Checked = true};
|
||||||
|
if (_warnings != null && _warnings.Contains(_warningIndex))
|
||||||
|
{
|
||||||
|
item.UseItemStyleForSubItems = true;
|
||||||
|
item.BackColor = Color.PeachPuff;
|
||||||
|
}
|
||||||
var subItem = new ListViewItem.ListViewSubItem(item, p.Number.ToString());
|
var subItem = new ListViewItem.ListViewSubItem(item, p.Number.ToString());
|
||||||
item.SubItems.Add(subItem);
|
item.SubItems.Add(subItem);
|
||||||
subItem = new ListViewItem.ListViewSubItem(item, p.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
|
subItem = new ListViewItem.ListViewSubItem(item, p.Text.Replace(Environment.NewLine, Configuration.Settings.General.ListViewLineSeparatorString));
|
||||||
|
Loading…
Reference in New Issue
Block a user