mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 06:52:35 +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 newText = string.Empty;
|
||||||
string[] parts = text.Trim().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
string[] parts = text.Trim().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
int noOfNames = 0;
|
int noOfNames = 0;
|
||||||
|
int count = 0;
|
||||||
|
bool removedInFirstLine = false;
|
||||||
|
bool removedInSecondLine = false;
|
||||||
foreach (string s in parts)
|
foreach (string s in parts)
|
||||||
{
|
{
|
||||||
int indexOfColon = s.IndexOf(":");
|
int indexOfColon = s.IndexOf(":");
|
||||||
@ -332,6 +335,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
newText = newText + Environment.NewLine + "(" + content;
|
newText = newText + Environment.NewLine + "(" + content;
|
||||||
else
|
else
|
||||||
newText = newText + Environment.NewLine + content;
|
newText = newText + Environment.NewLine + content;
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
removedInFirstLine = true;
|
||||||
|
else if (count == 1)
|
||||||
|
removedInSecondLine = true;
|
||||||
}
|
}
|
||||||
newText = newText.Trim();
|
newText = newText.Trim();
|
||||||
|
|
||||||
@ -378,6 +386,11 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
s2 = s2.Remove(0, colonIndex - endIndex);
|
s2 = s2.Remove(0, colonIndex - endIndex);
|
||||||
else if (endIndex > 0)
|
else if (endIndex > 0)
|
||||||
s2 = s2.Remove(endIndex + 1, colonIndex - endIndex);
|
s2 = s2.Remove(endIndex + 1, colonIndex - endIndex);
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
removedInFirstLine = true;
|
||||||
|
else if (count == 1)
|
||||||
|
removedInSecondLine = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newText = newText + Environment.NewLine + s2;
|
newText = newText + Environment.NewLine + s2;
|
||||||
@ -394,6 +407,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
newText = "<i>" + newText;
|
newText = "<i>" + newText;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
newText = newText.Trim();
|
newText = newText.Trim();
|
||||||
if (noOfNames > 0 && Utilities.CountTagInText(newText, Environment.NewLine) == 1)
|
if (noOfNames > 0 && Utilities.CountTagInText(newText, Environment.NewLine) == 1)
|
||||||
@ -420,6 +434,8 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
insertDash = false;
|
insertDash = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removedInFirstLine && !removedInSecondLine && !text.StartsWith("-") && !text.StartsWith("<i>-"))
|
||||||
|
insertDash = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insertDash)
|
if (insertDash)
|
||||||
@ -566,10 +582,13 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
if (part0.Length > 0 && ".!?".Contains(part0.Substring(part0.Length - 1)))
|
if (part0.Length > 0 && ".!?".Contains(part0.Substring(part0.Length - 1)))
|
||||||
{
|
{
|
||||||
if (!st.Pre.Contains("-"))
|
if (noOfNamesRemovedNotInLineOne > 0)
|
||||||
text = "- " + text.Replace(Environment.NewLine, Environment.NewLine + "- ");
|
{
|
||||||
if (!text.Contains(Environment.NewLine + "-") && !text.Contains(Environment.NewLine + "<i>-"))
|
if (!st.Pre.Contains("-"))
|
||||||
text = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
|
text = "- " + text.Replace(Environment.NewLine, Environment.NewLine + "- ");
|
||||||
|
if (!text.Contains(Environment.NewLine + "-") && !text.Contains(Environment.NewLine + "<i>-"))
|
||||||
|
text = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,10 +157,6 @@ namespace Test
|
|||||||
[DeploymentItem("SubtitleEdit.exe")]
|
[DeploymentItem("SubtitleEdit.exe")]
|
||||||
public void RemoveHISecondLineDelay()
|
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();
|
FormRemoveTextForHearImpaired_Accessor target = new FormRemoveTextForHearImpaired_Accessor();
|
||||||
string text = "- JOHN: Hey." + Environment.NewLine +
|
string text = "- JOHN: Hey." + Environment.NewLine +
|
||||||
"- ...hey.";
|
"- ...hey.";
|
||||||
|
Loading…
Reference in New Issue
Block a user