Working on spell check...

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2426 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2014-01-25 14:32:23 +00:00
parent 94f43418e1
commit b486843237

View File

@ -175,68 +175,24 @@ namespace Nikse.SubtitleEdit.Forms
richTextBoxParagraph.SelectionColor = Color.Black; richTextBoxParagraph.SelectionColor = Color.Black;
richTextBoxParagraph.SelectionLength = 0; richTextBoxParagraph.SelectionLength = 0;
int newLine1 = int.MaxValue; for (int i = 0; i < 10; i++)
int newLine2 = int.MaxValue;
if (word.Text.Contains(Environment.NewLine))
{ {
newLine1 = word.Text.IndexOf(Environment.NewLine); int idx = word.Index - i;
if (word.Text.IndexOf(Environment.NewLine, newLine1 + 1) > 0) if (i >= 0 && i < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text))
newLine2 = word.Text.IndexOf(Environment.NewLine, newLine1 + 1); {
} richTextBoxParagraph.SelectionStart = idx;
richTextBoxParagraph.SelectionLength = word.Text.Length;
int idx = word.Index; richTextBoxParagraph.SelectionColor = Color.Red;
if (idx > 0 && !richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text)) break;
idx--; }
idx = word.Index + i;
if (richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text)) if (i >= 0 && i < richTextBoxParagraph.Text.Length && richTextBoxParagraph.Text.Substring(idx).StartsWith(word.Text))
{ {
if (idx > newLine1) richTextBoxParagraph.SelectionStart = idx;
idx--; richTextBoxParagraph.SelectionLength = word.Text.Length;
if (idx > newLine2) richTextBoxParagraph.SelectionColor = Color.Red;
idx--; break;
richTextBoxParagraph.SelectionStart = idx; }
richTextBoxParagraph.SelectionLength = word.Text.Length;
richTextBoxParagraph.SelectionColor = Color.Red;
}
else if (richTextBoxParagraph.Text.Substring(idx + 1).StartsWith(word.Text))
{
if (idx > newLine1)
idx--;
if (idx > newLine2)
idx--;
richTextBoxParagraph.SelectionStart = idx + 1;
richTextBoxParagraph.SelectionLength = word.Text.Length;
richTextBoxParagraph.SelectionColor = Color.Red;
}
else if (richTextBoxParagraph.Text.Substring(idx + 2).StartsWith(word.Text))
{
if (idx > newLine1)
idx--;
if (idx > newLine2)
idx--;
richTextBoxParagraph.SelectionStart = idx + 2;
richTextBoxParagraph.SelectionLength = word.Text.Length;
richTextBoxParagraph.SelectionColor = Color.Red;
}
else if (richTextBoxParagraph.Text.Substring(idx + 3).StartsWith(word.Text))
{
if (idx > newLine1)
idx--;
if (idx > newLine2)
idx--;
richTextBoxParagraph.SelectionStart = idx + 3;
richTextBoxParagraph.SelectionLength = word.Text.Length;
richTextBoxParagraph.SelectionColor = Color.Red;
}
else if (idx > 2 && richTextBoxParagraph.Text.Substring(idx -2).StartsWith(word.Text))
{
if (idx > newLine1)
idx--;
if (idx > newLine2)
idx--;
richTextBoxParagraph.SelectionStart = idx -2;
richTextBoxParagraph.SelectionLength = word.Text.Length;
richTextBoxParagraph.SelectionColor = Color.Red;
} }
} }