LuaWriter. Fixed error that prevented coloring multiple strings in the text. Also made that Reserved Words will only color if there are no letters or numbers next to them.

This commit is contained in:
rolanmen1 2012-07-20 22:50:28 +00:00
parent 1a45b82d64
commit 9bca1b198d
2 changed files with 45 additions and 37 deletions

View File

@ -28,35 +28,35 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.LuaText = new System.Windows.Forms.RichTextBox();
this.timer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// LuaText
//
this.LuaText.Location = new System.Drawing.Point(12, 12);
this.LuaText.Name = "LuaText";
this.LuaText.Size = new System.Drawing.Size(819, 417);
this.LuaText.TabIndex = 0;
this.LuaText.Text = "";
this.LuaText.ZoomFactor = 1.2F;
//
// timer
//
this.timer.Enabled = true;
this.timer.Interval = 1000;
this.timer.Tick += new System.EventHandler(this.timer_Tick);
//
// LuaWriter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(843, 441);
this.Controls.Add(this.LuaText);
this.Name = "LuaWriter";
this.Text = "LuaWriter";
this.ResumeLayout(false);
this.components = new System.ComponentModel.Container();
this.LuaText = new System.Windows.Forms.RichTextBox();
this.timer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// LuaText
//
this.LuaText.Location = new System.Drawing.Point(12, 12);
this.LuaText.Name = "LuaText";
this.LuaText.Size = new System.Drawing.Size(819, 417);
this.LuaText.TabIndex = 0;
this.LuaText.Text = "";
this.LuaText.ZoomFactor = 2F;
//
// timer
//
this.timer.Enabled = true;
this.timer.Interval = 1000;
this.timer.Tick += new System.EventHandler(this.timer_Tick);
//
// LuaWriter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(843, 441);
this.Controls.Add(this.LuaText);
this.Name = "LuaWriter";
this.Text = "LuaWriter";
this.ResumeLayout(false);
}

View File

@ -43,24 +43,24 @@ namespace BizHawk.MultiClient
{
int stringStart = LuaText.SelectionStart;
int endLine = LuaText.GetFirstCharIndexFromLine(LuaText.GetLineFromCharIndex(stringStart) + 1) - 1;
int stringEnd = LuaText.Find("\"", stringStart + 1, endLine, RichTextBoxFinds.MatchCase);
int stringEnd = LuaText.Find("\"", stringStart + 1, endLine, RichTextBoxFinds.None);
if (stringEnd > 0)
{
LuaText.Select(stringStart, stringEnd - stringStart + 1);
firstQuote = LuaText.Find("\"", stringEnd + 1, RichTextBoxFinds.MatchCase);
LuaText.SelectionColor = Color.Gray;
firstQuote = LuaText.Find("\"", stringEnd + 1, RichTextBoxFinds.None);
}
else
{
LuaText.Select(stringStart, endLine - stringStart);
firstQuote = LuaText.Find("\"", endLine + 1, RichTextBoxFinds.MatchCase);
LuaText.SelectionColor = Color.Gray;
firstQuote = LuaText.Find("\"", endLine + 1, RichTextBoxFinds.None);
}
LuaText.SelectionColor = Color.Gray;
}
}
else
firstQuote = LuaText.Find("\"", LuaText.SelectionStart + 1, RichTextBoxFinds.MatchCase);
firstQuote = LuaText.Find("\"", LuaText.SelectionStart + 1, RichTextBoxFinds.None);
}
}
@ -99,9 +99,17 @@ namespace BizHawk.MultiClient
foreach (Match keyWordMatch in keyWords.Matches(LuaText.Text))
{
LuaText.Select(curPos, keyWordMatch.Index);
if (LuaText.SelectionColor != Color.Gray)
char before = ' ', after = ' ';
if (keyWordMatch.Index > 0)
before = LuaText.Text[keyWordMatch.Index - 1];
if (keyWordMatch.Index + keyWordMatch.Length != LuaText.Text.Length)
after = LuaText.Text[keyWordMatch.Index + keyWordMatch.Length];
if (!char.IsLetterOrDigit(before) && !char.IsLetterOrDigit(after))
{
LuaText.Select(curPos, keyWordMatch.Index);
LuaText.SelectionColor = Color.Black;
LuaText.Select(keyWordMatch.Index, keyWordMatch.Length);
LuaText.SelectionColor = Color.Blue;