Lua Writer - bold for syntax highlighting option
This commit is contained in:
parent
2e41102f8a
commit
754422b0e4
|
@ -552,12 +552,17 @@ namespace BizHawk.MultiClient
|
|||
|
||||
//LuaWriter Settings
|
||||
public int LuaDefaultTextColor = -16777216;
|
||||
|
||||
public int LuaKeyWordColor = -16776961;
|
||||
public bool LuaKeyWordBold = false;
|
||||
public int LuaCommentColor = -16744448;
|
||||
public bool LuaCommentBold = false;
|
||||
public int LuaStringColor = -8355712;
|
||||
public bool LuaStringBold = false;
|
||||
public int LuaSymbolColor = -16777216;
|
||||
//public int LuaLibraryColor = -6427649;
|
||||
public bool LuaSymbolBold = false;
|
||||
public int LuaLibraryColor = -16711681;
|
||||
public bool LuaLibraryBold = false;
|
||||
public float LuaWriterFontSize = 11;
|
||||
public string LuaWriterFont = "Courier New";
|
||||
public float LuaWriterZoom = 1;
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace BizHawk.MultiClient
|
|||
public Regex keyWords = new Regex("and|break|do|else|if|end|false|for|function|in|local|nil|not|or|repeat|return|then|true|until|while|elseif");
|
||||
char[] Symbols = { '+', '-', '*', '/', '%', '^', '#', '=', '<', '>', '(', ')', '{', '}', '[', ']', ';', ':', ',', '.' };
|
||||
public Regex libraryWords;
|
||||
public Regex LuaLibraryWords = new Regex("coroutine|package|debug|file|io|math|os|package|string|table");
|
||||
|
||||
public LuaWriter()
|
||||
{
|
||||
|
@ -81,42 +80,16 @@ namespace BizHawk.MultiClient
|
|||
|
||||
LuaText.SelectAll();
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaDefaultTextColor);
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Regular);
|
||||
|
||||
ColorReservedWords();
|
||||
ColorLibraries();
|
||||
ColorLuaLibraries();
|
||||
ColorComments();
|
||||
ColorStrings();
|
||||
ColorSymbols();
|
||||
LuaText.Select(selPos, selChars);
|
||||
}
|
||||
|
||||
private void ColorLuaLibraries()
|
||||
{
|
||||
foreach (Match libraryWordMatch in LuaLibraryWords.Matches(LuaText.Text))
|
||||
{
|
||||
if (libraryWordMatch.Index >= 0)
|
||||
{
|
||||
char before = ' ', after = ' ';
|
||||
|
||||
if (libraryWordMatch.Index > 0)
|
||||
before = LuaText.Text[libraryWordMatch.Index - 1];
|
||||
|
||||
if (libraryWordMatch.Index + libraryWordMatch.Length != LuaText.Text.Length)
|
||||
after = LuaText.Text[libraryWordMatch.Index + libraryWordMatch.Length];
|
||||
|
||||
if (!char.IsLetterOrDigit(before))
|
||||
{
|
||||
if (after == '.')
|
||||
{
|
||||
LuaText.Select(libraryWordMatch.Index, libraryWordMatch.Length);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaLibraryColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorSymbols()
|
||||
{
|
||||
foreach (char mark in Symbols)
|
||||
|
@ -126,6 +99,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (LuaText.SelectionColor.ToArgb() != Global.Config.LuaCommentColor && LuaText.SelectionColor.ToArgb() != Global.Config.LuaStringColor)
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaSymbolColor);
|
||||
if (Global.Config.LuaSymbolBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
currPos = LuaText.SelectionStart + 1;
|
||||
|
||||
if (currPos == LuaText.Text.Length)
|
||||
|
@ -184,6 +159,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
LuaText.Select(opening, ending - opening + 1);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaStringColor);
|
||||
if (Global.Config.LuaStringBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
if (ending >= LuaText.Text.Length)
|
||||
ending++;
|
||||
else
|
||||
|
@ -229,6 +206,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
LuaText.Select(CommentMatch.Index, endComment);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaCommentColor);
|
||||
if (Global.Config.LuaCommentBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,6 +218,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
LuaText.Select(CommentMatch.Index, endComment);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaCommentColor);
|
||||
if (Global.Config.LuaCommentBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,6 +242,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
LuaText.Select(keyWordMatch.Index, keyWordMatch.Length);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaKeyWordColor);
|
||||
if (Global.Config.LuaKeyWordBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,6 +268,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
LuaText.Select(libraryWordMatch.Index, libraryWordMatch.Length);
|
||||
LuaText.SelectionColor = Color.FromArgb(Global.Config.LuaLibraryColor);
|
||||
if (Global.Config.LuaLibraryBold)
|
||||
LuaText.SelectionFont = new Font(LuaText.SelectionFont, FontStyle.Bold);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +289,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
list.Append("|coroutine|package|debug|file|io|math|os|package|string|table");
|
||||
libraryWords = new Regex(list.ToString());
|
||||
}
|
||||
|
||||
|
@ -538,7 +524,6 @@ namespace BizHawk.MultiClient
|
|||
ListViewItem item = new ListViewItem(function);
|
||||
AutoCompleteView.Items.Add(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,6 +637,13 @@ namespace BizHawk.MultiClient
|
|||
Global.Config.LuaStringColor = -8355712;
|
||||
Global.Config.LuaSymbolColor = -16777216;
|
||||
Global.Config.LuaLibraryColor = -16711681;
|
||||
|
||||
Global.Config.LuaKeyWordBold = false;
|
||||
Global.Config.LuaCommentBold = false;
|
||||
Global.Config.LuaStringBold = false;
|
||||
Global.Config.LuaSymbolBold = false;
|
||||
Global.Config.LuaLibraryBold = false;
|
||||
|
||||
ProcessText();
|
||||
|
||||
Global.Config.LuaWriterFontSize = 11;
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
this.SymbolColorDialog = new System.Windows.Forms.ColorDialog();
|
||||
this.LibraryColorDialog = new System.Windows.Forms.ColorDialog();
|
||||
this.buttonDefaults = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.BoldKeyWords = new System.Windows.Forms.CheckBox();
|
||||
this.BoldComments = new System.Windows.Forms.CheckBox();
|
||||
this.BoldStrings = new System.Windows.Forms.CheckBox();
|
||||
this.BoldSymbols = new System.Windows.Forms.CheckBox();
|
||||
this.BoldLibraries = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// OK
|
||||
|
@ -73,7 +80,7 @@
|
|||
// panelKeyWord
|
||||
//
|
||||
this.panelKeyWord.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelKeyWord.Location = new System.Drawing.Point(105, 10);
|
||||
this.panelKeyWord.Location = new System.Drawing.Point(77, 12);
|
||||
this.panelKeyWord.Name = "panelKeyWord";
|
||||
this.panelKeyWord.Size = new System.Drawing.Size(20, 20);
|
||||
this.panelKeyWord.TabIndex = 1;
|
||||
|
@ -82,7 +89,7 @@
|
|||
// lblKeyWords
|
||||
//
|
||||
this.lblKeyWords.AutoSize = true;
|
||||
this.lblKeyWords.Location = new System.Drawing.Point(40, 17);
|
||||
this.lblKeyWords.Location = new System.Drawing.Point(12, 19);
|
||||
this.lblKeyWords.Name = "lblKeyWords";
|
||||
this.lblKeyWords.Size = new System.Drawing.Size(59, 13);
|
||||
this.lblKeyWords.TabIndex = 0;
|
||||
|
@ -91,7 +98,7 @@
|
|||
// lblComments
|
||||
//
|
||||
this.lblComments.AutoSize = true;
|
||||
this.lblComments.Location = new System.Drawing.Point(43, 57);
|
||||
this.lblComments.Location = new System.Drawing.Point(15, 59);
|
||||
this.lblComments.Name = "lblComments";
|
||||
this.lblComments.Size = new System.Drawing.Size(56, 13);
|
||||
this.lblComments.TabIndex = 2;
|
||||
|
@ -100,7 +107,7 @@
|
|||
// panelComment
|
||||
//
|
||||
this.panelComment.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelComment.Location = new System.Drawing.Point(105, 50);
|
||||
this.panelComment.Location = new System.Drawing.Point(77, 52);
|
||||
this.panelComment.Name = "panelComment";
|
||||
this.panelComment.Size = new System.Drawing.Size(20, 20);
|
||||
this.panelComment.TabIndex = 3;
|
||||
|
@ -109,7 +116,7 @@
|
|||
// panelString
|
||||
//
|
||||
this.panelString.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelString.Location = new System.Drawing.Point(105, 90);
|
||||
this.panelString.Location = new System.Drawing.Point(77, 92);
|
||||
this.panelString.Name = "panelString";
|
||||
this.panelString.Size = new System.Drawing.Size(20, 20);
|
||||
this.panelString.TabIndex = 5;
|
||||
|
@ -118,7 +125,7 @@
|
|||
// lblStrings
|
||||
//
|
||||
this.lblStrings.AutoSize = true;
|
||||
this.lblStrings.Location = new System.Drawing.Point(60, 97);
|
||||
this.lblStrings.Location = new System.Drawing.Point(32, 99);
|
||||
this.lblStrings.Name = "lblStrings";
|
||||
this.lblStrings.Size = new System.Drawing.Size(39, 13);
|
||||
this.lblStrings.TabIndex = 4;
|
||||
|
@ -127,7 +134,7 @@
|
|||
// panelSymbol
|
||||
//
|
||||
this.panelSymbol.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelSymbol.Location = new System.Drawing.Point(105, 130);
|
||||
this.panelSymbol.Location = new System.Drawing.Point(77, 132);
|
||||
this.panelSymbol.Name = "panelSymbol";
|
||||
this.panelSymbol.Size = new System.Drawing.Size(20, 20);
|
||||
this.panelSymbol.TabIndex = 7;
|
||||
|
@ -136,7 +143,7 @@
|
|||
// lblSymbols
|
||||
//
|
||||
this.lblSymbols.AutoSize = true;
|
||||
this.lblSymbols.Location = new System.Drawing.Point(53, 137);
|
||||
this.lblSymbols.Location = new System.Drawing.Point(25, 139);
|
||||
this.lblSymbols.Name = "lblSymbols";
|
||||
this.lblSymbols.Size = new System.Drawing.Size(46, 13);
|
||||
this.lblSymbols.TabIndex = 6;
|
||||
|
@ -145,7 +152,7 @@
|
|||
// panelLibrary
|
||||
//
|
||||
this.panelLibrary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.panelLibrary.Location = new System.Drawing.Point(105, 170);
|
||||
this.panelLibrary.Location = new System.Drawing.Point(77, 172);
|
||||
this.panelLibrary.Name = "panelLibrary";
|
||||
this.panelLibrary.Size = new System.Drawing.Size(20, 20);
|
||||
this.panelLibrary.TabIndex = 9;
|
||||
|
@ -154,7 +161,7 @@
|
|||
// lblLibraries
|
||||
//
|
||||
this.lblLibraries.AutoSize = true;
|
||||
this.lblLibraries.Location = new System.Drawing.Point(53, 177);
|
||||
this.lblLibraries.Location = new System.Drawing.Point(25, 179);
|
||||
this.lblLibraries.Name = "lblLibraries";
|
||||
this.lblLibraries.Size = new System.Drawing.Size(46, 13);
|
||||
this.lblLibraries.TabIndex = 8;
|
||||
|
@ -187,6 +194,79 @@
|
|||
this.buttonDefaults.UseVisualStyleBackColor = true;
|
||||
this.buttonDefaults.Click += new System.EventHandler(this.buttonDefaults_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.BoldLibraries);
|
||||
this.groupBox1.Controls.Add(this.BoldSymbols);
|
||||
this.groupBox1.Controls.Add(this.BoldStrings);
|
||||
this.groupBox1.Controls.Add(this.BoldComments);
|
||||
this.groupBox1.Controls.Add(this.BoldKeyWords);
|
||||
this.groupBox1.Controls.Add(this.panelKeyWord);
|
||||
this.groupBox1.Controls.Add(this.lblKeyWords);
|
||||
this.groupBox1.Controls.Add(this.panelLibrary);
|
||||
this.groupBox1.Controls.Add(this.lblComments);
|
||||
this.groupBox1.Controls.Add(this.lblLibraries);
|
||||
this.groupBox1.Controls.Add(this.panelComment);
|
||||
this.groupBox1.Controls.Add(this.panelSymbol);
|
||||
this.groupBox1.Controls.Add(this.lblStrings);
|
||||
this.groupBox1.Controls.Add(this.lblSymbols);
|
||||
this.groupBox1.Controls.Add(this.panelString);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(260, 202);
|
||||
this.groupBox1.TabIndex = 13;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// BoldKeyWords
|
||||
//
|
||||
this.BoldKeyWords.AutoSize = true;
|
||||
this.BoldKeyWords.Location = new System.Drawing.Point(132, 15);
|
||||
this.BoldKeyWords.Name = "BoldKeyWords";
|
||||
this.BoldKeyWords.Size = new System.Drawing.Size(47, 17);
|
||||
this.BoldKeyWords.TabIndex = 10;
|
||||
this.BoldKeyWords.Text = "Bold";
|
||||
this.BoldKeyWords.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BoldComments
|
||||
//
|
||||
this.BoldComments.AutoSize = true;
|
||||
this.BoldComments.Location = new System.Drawing.Point(132, 55);
|
||||
this.BoldComments.Name = "BoldComments";
|
||||
this.BoldComments.Size = new System.Drawing.Size(47, 17);
|
||||
this.BoldComments.TabIndex = 11;
|
||||
this.BoldComments.Text = "Bold";
|
||||
this.BoldComments.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BoldStrings
|
||||
//
|
||||
this.BoldStrings.AutoSize = true;
|
||||
this.BoldStrings.Location = new System.Drawing.Point(132, 95);
|
||||
this.BoldStrings.Name = "BoldStrings";
|
||||
this.BoldStrings.Size = new System.Drawing.Size(47, 17);
|
||||
this.BoldStrings.TabIndex = 12;
|
||||
this.BoldStrings.Text = "Bold";
|
||||
this.BoldStrings.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BoldSymbols
|
||||
//
|
||||
this.BoldSymbols.AutoSize = true;
|
||||
this.BoldSymbols.Location = new System.Drawing.Point(132, 135);
|
||||
this.BoldSymbols.Name = "BoldSymbols";
|
||||
this.BoldSymbols.Size = new System.Drawing.Size(47, 17);
|
||||
this.BoldSymbols.TabIndex = 13;
|
||||
this.BoldSymbols.Text = "Bold";
|
||||
this.BoldSymbols.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BoldLibraries
|
||||
//
|
||||
this.BoldLibraries.AutoSize = true;
|
||||
this.BoldLibraries.Location = new System.Drawing.Point(132, 175);
|
||||
this.BoldLibraries.Name = "BoldLibraries";
|
||||
this.BoldLibraries.Size = new System.Drawing.Size(47, 17);
|
||||
this.BoldLibraries.TabIndex = 14;
|
||||
this.BoldLibraries.Text = "Bold";
|
||||
this.BoldLibraries.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// LuaWriterColorConfig
|
||||
//
|
||||
this.AcceptButton = this.OK;
|
||||
|
@ -194,25 +274,17 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.Cancel;
|
||||
this.ClientSize = new System.Drawing.Size(284, 262);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.buttonDefaults);
|
||||
this.Controls.Add(this.panelLibrary);
|
||||
this.Controls.Add(this.lblLibraries);
|
||||
this.Controls.Add(this.panelSymbol);
|
||||
this.Controls.Add(this.lblSymbols);
|
||||
this.Controls.Add(this.panelString);
|
||||
this.Controls.Add(this.lblStrings);
|
||||
this.Controls.Add(this.panelComment);
|
||||
this.Controls.Add(this.lblComments);
|
||||
this.Controls.Add(this.lblKeyWords);
|
||||
this.Controls.Add(this.panelKeyWord);
|
||||
this.Controls.Add(this.Cancel);
|
||||
this.Controls.Add(this.OK);
|
||||
this.Name = "LuaWriterColorConfig";
|
||||
this.ShowIcon = false;
|
||||
this.Text = "Syntax Highlight Config";
|
||||
this.Load += new System.EventHandler(this.LuaWriterColorConfig_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
@ -236,5 +308,11 @@
|
|||
private System.Windows.Forms.ColorDialog SymbolColorDialog;
|
||||
private System.Windows.Forms.ColorDialog LibraryColorDialog;
|
||||
private System.Windows.Forms.Button buttonDefaults;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox BoldLibraries;
|
||||
private System.Windows.Forms.CheckBox BoldSymbols;
|
||||
private System.Windows.Forms.CheckBox BoldStrings;
|
||||
private System.Windows.Forms.CheckBox BoldComments;
|
||||
private System.Windows.Forms.CheckBox BoldKeyWords;
|
||||
}
|
||||
}
|
|
@ -31,6 +31,12 @@ namespace BizHawk.MultiClient.tools
|
|||
SetStringColor(StringColor);
|
||||
SetSymbolColor(SymbolColor);
|
||||
SetLibraryColor(LibraryColor);
|
||||
|
||||
BoldKeyWords.Checked = Global.Config.LuaKeyWordBold;
|
||||
BoldComments.Checked = Global.Config.LuaCommentBold;
|
||||
BoldStrings.Checked = Global.Config.LuaStringBold;
|
||||
BoldSymbols.Checked = Global.Config.LuaSymbolBold;
|
||||
BoldLibraries.Checked = Global.Config.LuaLibraryBold;
|
||||
}
|
||||
|
||||
private void SetKeyWordColor(int color)
|
||||
|
@ -61,7 +67,6 @@ namespace BizHawk.MultiClient.tools
|
|||
{
|
||||
LibraryColor = color; //Set new color
|
||||
panelLibrary.BackColor = Color.FromArgb(color); //Update panel color with new selection
|
||||
//MessageBox.Show(color.ToString());
|
||||
}
|
||||
|
||||
//Pop up color dialog when double-clicked
|
||||
|
@ -119,11 +124,19 @@ namespace BizHawk.MultiClient.tools
|
|||
|
||||
private void SaveData()
|
||||
{
|
||||
//Colors
|
||||
Global.Config.LuaKeyWordColor = KeyWordColor;
|
||||
Global.Config.LuaCommentColor = CommentColor;
|
||||
Global.Config.LuaStringColor = StringColor;
|
||||
Global.Config.LuaSymbolColor = SymbolColor;
|
||||
Global.Config.LuaLibraryColor = LibraryColor;
|
||||
|
||||
//Bold
|
||||
Global.Config.LuaKeyWordBold = BoldKeyWords.Checked;
|
||||
Global.Config.LuaCommentBold = BoldComments.Checked;
|
||||
Global.Config.LuaStringBold = BoldStrings.Checked;
|
||||
Global.Config.LuaSymbolBold = BoldSymbols.Checked;
|
||||
Global.Config.LuaLibraryBold = BoldLibraries.Checked;
|
||||
}
|
||||
|
||||
private void buttonDefaults_Click(object sender, EventArgs e)
|
||||
|
@ -133,6 +146,12 @@ namespace BizHawk.MultiClient.tools
|
|||
SetStringColor(-8355712);
|
||||
SetSymbolColor(-16777216);
|
||||
SetLibraryColor(-16711681);
|
||||
|
||||
BoldKeyWords.Checked = false;
|
||||
BoldComments.Checked = false;
|
||||
BoldStrings.Checked = false;
|
||||
BoldSymbols.Checked = false;
|
||||
BoldLibraries.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue