LuaWriter. Now colors Strings. TODO: Allow to color multiple Strings in the same line.
This commit is contained in:
parent
5f4ad218a2
commit
1a45b82d64
|
@ -22,20 +22,50 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
int selPos = LuaText.SelectionStart;
|
int selPos = LuaText.SelectionStart;
|
||||||
int selChars = LuaText.SelectedText.Length;
|
int selChars = LuaText.SelectedText.Length;
|
||||||
int curPos = 0;
|
|
||||||
|
|
||||||
foreach (Match keyWordMatch in keyWords.Matches(LuaText.Text))
|
ColorReservedWords();
|
||||||
{
|
|
||||||
LuaText.Select(curPos, keyWordMatch.Index);
|
ColorComments();
|
||||||
LuaText.SelectionColor = Color.Black;
|
|
||||||
LuaText.Select(keyWordMatch.Index, keyWordMatch.Length);
|
ColorStrings();
|
||||||
LuaText.SelectionColor = Color.Blue;
|
|
||||||
curPos = keyWordMatch.Index + keyWordMatch.Length;
|
LuaText.Select(selPos, selChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaText.Select(curPos, selPos);
|
private void ColorStrings()
|
||||||
LuaText.SelectionColor = Color.Black;
|
{
|
||||||
|
int firstQuote = LuaText.Find("\"", 0);
|
||||||
|
while (firstQuote > 0)
|
||||||
|
{
|
||||||
|
if (LuaText.SelectionColor != Color.Green)
|
||||||
|
{
|
||||||
|
if (LuaText.Text[LuaText.SelectionStart - 1] != '\\')
|
||||||
|
{
|
||||||
|
int stringStart = LuaText.SelectionStart;
|
||||||
|
int endLine = LuaText.GetFirstCharIndexFromLine(LuaText.GetLineFromCharIndex(stringStart) + 1) - 1;
|
||||||
|
int stringEnd = LuaText.Find("\"", stringStart + 1, endLine, RichTextBoxFinds.MatchCase);
|
||||||
|
|
||||||
|
if (stringEnd > 0)
|
||||||
|
{
|
||||||
|
LuaText.Select(stringStart, stringEnd - stringStart + 1);
|
||||||
|
firstQuote = LuaText.Find("\"", stringEnd + 1, RichTextBoxFinds.MatchCase);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LuaText.Select(stringStart, endLine - stringStart);
|
||||||
|
firstQuote = LuaText.Find("\"", endLine + 1, RichTextBoxFinds.MatchCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaText.SelectionColor = Color.Gray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
firstQuote = LuaText.Find("\"", LuaText.SelectionStart + 1, RichTextBoxFinds.MatchCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ColorComments()
|
||||||
|
{
|
||||||
foreach (Match CommentMatch in new Regex("--").Matches(LuaText.Text))
|
foreach (Match CommentMatch in new Regex("--").Matches(LuaText.Text))
|
||||||
{
|
{
|
||||||
int endComment;
|
int endComment;
|
||||||
|
@ -61,8 +91,26 @@ namespace BizHawk.MultiClient
|
||||||
LuaText.SelectionColor = Color.Green;
|
LuaText.SelectionColor = Color.Green;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LuaText.Select(selPos, selChars);
|
private void ColorReservedWords()
|
||||||
|
{
|
||||||
|
int curPos = 0;
|
||||||
|
|
||||||
|
foreach (Match keyWordMatch in keyWords.Matches(LuaText.Text))
|
||||||
|
{
|
||||||
|
LuaText.Select(curPos, keyWordMatch.Index);
|
||||||
|
if (LuaText.SelectionColor != Color.Gray)
|
||||||
|
{
|
||||||
|
LuaText.SelectionColor = Color.Black;
|
||||||
|
LuaText.Select(keyWordMatch.Index, keyWordMatch.Length);
|
||||||
|
LuaText.SelectionColor = Color.Blue;
|
||||||
|
}
|
||||||
|
curPos = keyWordMatch.Index + keyWordMatch.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaText.Select(curPos, LuaText.Text.Length);
|
||||||
|
LuaText.SelectionColor = Color.Black;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue