mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
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:
parent
ee985bab84
commit
1e66a57260
@ -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)
|
||||
@ -565,6 +581,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (!part0.EndsWith(",") && (!part0.EndsWith("-") || noOfNamesRemovedNotInLineOne > 0))
|
||||
{
|
||||
if (part0.Length > 0 && ".!?".Contains(part0.Substring(part0.Length - 1)))
|
||||
{
|
||||
if (noOfNamesRemovedNotInLineOne > 0)
|
||||
{
|
||||
if (!st.Pre.Contains("-"))
|
||||
text = "- " + text.Replace(Environment.NewLine, Environment.NewLine + "- ");
|
||||
@ -573,6 +591,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
text = st.Pre + text + st.Post;
|
||||
|
@ -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.";
|
||||
|
Loading…
Reference in New Issue
Block a user