Some improvements for Remove Text for HI - thx Majid :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@915 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-01-10 07:12:56 +00:00
parent ee985bab84
commit 1e66a57260
2 changed files with 23 additions and 8 deletions

View File

@ -294,6 +294,9 @@ namespace Nikse.SubtitleEdit.Forms
string newText = string.Empty;
string[] parts = text.Trim().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int noOfNames = 0;
int count = 0;
bool removedInFirstLine = false;
bool removedInSecondLine = false;
foreach (string s in parts)
{
int indexOfColon = s.IndexOf(":");
@ -332,6 +335,11 @@ namespace Nikse.SubtitleEdit.Forms
newText = newText + Environment.NewLine + "(" + content;
else
newText = newText + Environment.NewLine + content;
if (count == 0)
removedInFirstLine = true;
else if (count == 1)
removedInSecondLine = true;
}
newText = newText.Trim();
@ -378,6 +386,11 @@ namespace Nikse.SubtitleEdit.Forms
s2 = s2.Remove(0, colonIndex - endIndex);
else if (endIndex > 0)
s2 = s2.Remove(endIndex + 1, colonIndex - endIndex);
if (count == 0)
removedInFirstLine = true;
else if (count == 1)
removedInSecondLine = true;
}
}
newText = newText + Environment.NewLine + s2;
@ -394,6 +407,7 @@ namespace Nikse.SubtitleEdit.Forms
newText = "<i>" + newText;
}
count++;
}
newText = newText.Trim();
if (noOfNames > 0 && Utilities.CountTagInText(newText, Environment.NewLine) == 1)
@ -420,6 +434,8 @@ namespace Nikse.SubtitleEdit.Forms
insertDash = false;
}
if (removedInFirstLine && !removedInSecondLine && !text.StartsWith("-") && !text.StartsWith("<i>-"))
insertDash = false;
}
if (insertDash)
@ -566,10 +582,13 @@ namespace Nikse.SubtitleEdit.Forms
{
if (part0.Length > 0 && ".!?".Contains(part0.Substring(part0.Length - 1)))
{
if (!st.Pre.Contains("-"))
text = "- " + text.Replace(Environment.NewLine, Environment.NewLine + "- ");
if (!text.Contains(Environment.NewLine + "-") && !text.Contains(Environment.NewLine + "<i>-"))
text = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
if (noOfNamesRemovedNotInLineOne > 0)
{
if (!st.Pre.Contains("-"))
text = "- " + text.Replace(Environment.NewLine, Environment.NewLine + "- ");
if (!text.Contains(Environment.NewLine + "-") && !text.Contains(Environment.NewLine + "<i>-"))
text = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
}
}
}
}

View File

@ -157,10 +157,6 @@ namespace Test
[DeploymentItem("SubtitleEdit.exe")]
public void RemoveHISecondLineDelay()
{
var config = new Nikse.SubtitleEdit.Logic.Configuration_Accessor();
config._settings.RemoveTextForHearingImpaired.RemoveInterjections = false;
config._settings.RemoveTextForHearingImpaired.RemoveTextBeforeColon = true;
config._settings.RemoveTextForHearingImpaired.RemoveTextBetweenCustom = false;
FormRemoveTextForHearImpaired_Accessor target = new FormRemoveTextForHearImpaired_Accessor();
string text = "- JOHN: Hey." + Environment.NewLine +
"- ...hey.";