LuaWriter. Pressing Enter when there's no if, while, for, etc.. will add the tabs that the previous line had.
This commit is contained in:
parent
5239b4f55b
commit
4771ba0f15
|
@ -53,6 +53,7 @@
|
||||||
this.configToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.configToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.fontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.fontToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.syntaxHighlightingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.syntaxHighlightingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.backgroundColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.startWithEmptyScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.startWithEmptyScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.restoreSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.restoreSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
@ -61,7 +62,6 @@
|
||||||
this.PositionLabel = new System.Windows.Forms.Label();
|
this.PositionLabel = new System.Windows.Forms.Label();
|
||||||
this.ZoomLabel = new System.Windows.Forms.Label();
|
this.ZoomLabel = new System.Windows.Forms.Label();
|
||||||
this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
|
this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
|
||||||
this.backgroundColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -262,6 +262,13 @@
|
||||||
this.syntaxHighlightingToolStripMenuItem.Text = "&Syntax Highlighting";
|
this.syntaxHighlightingToolStripMenuItem.Text = "&Syntax Highlighting";
|
||||||
this.syntaxHighlightingToolStripMenuItem.Click += new System.EventHandler(this.syntaxHighlightingToolStripMenuItem_Click);
|
this.syntaxHighlightingToolStripMenuItem.Click += new System.EventHandler(this.syntaxHighlightingToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// backgroundColorToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.backgroundColorToolStripMenuItem.Name = "backgroundColorToolStripMenuItem";
|
||||||
|
this.backgroundColorToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
|
||||||
|
this.backgroundColorToolStripMenuItem.Text = "Background Color";
|
||||||
|
this.backgroundColorToolStripMenuItem.Click += new System.EventHandler(this.backgroundColorToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// toolStripSeparator5
|
// toolStripSeparator5
|
||||||
//
|
//
|
||||||
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
||||||
|
@ -342,13 +349,6 @@
|
||||||
this.LuaText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyUp);
|
this.LuaText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyUp);
|
||||||
this.LuaText.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.LuaText_PreviewKeyDown);
|
this.LuaText.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.LuaText_PreviewKeyDown);
|
||||||
//
|
//
|
||||||
// backgroundColorToolStripMenuItem
|
|
||||||
//
|
|
||||||
this.backgroundColorToolStripMenuItem.Name = "backgroundColorToolStripMenuItem";
|
|
||||||
this.backgroundColorToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
|
|
||||||
this.backgroundColorToolStripMenuItem.Text = "Background Color";
|
|
||||||
this.backgroundColorToolStripMenuItem.Click += new System.EventHandler(this.backgroundColorToolStripMenuItem_Click);
|
|
||||||
//
|
|
||||||
// LuaWriter
|
// LuaWriter
|
||||||
//
|
//
|
||||||
this.AllowDrop = true;
|
this.AllowDrop = true;
|
||||||
|
|
|
@ -129,7 +129,6 @@ namespace BizHawk.MultiClient
|
||||||
ending += tempBracket.Length - 1;
|
ending += tempBracket.Length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Validate if such text is not part of a comment
|
|
||||||
AddPosition(firstBracket, ending - firstBracket + 1, Global.Config.LuaStringColor, Global.Config.LuaStringBold);
|
AddPosition(firstBracket, ending - firstBracket + 1, Global.Config.LuaStringColor, Global.Config.LuaStringBold);
|
||||||
|
|
||||||
if (ending < temp.Length - 1)
|
if (ending < temp.Length - 1)
|
||||||
|
@ -252,7 +251,6 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
if (opening != temp.Length)
|
if (opening != temp.Length)
|
||||||
{
|
{
|
||||||
//Validate if such text is not part of a comment
|
|
||||||
AddPosition(opening, ending - opening + 1, Global.Config.LuaStringColor, Global.Config.LuaStringBold);
|
AddPosition(opening, ending - opening + 1, Global.Config.LuaStringColor, Global.Config.LuaStringBold);
|
||||||
|
|
||||||
if (ending >= temp.Length)
|
if (ending >= temp.Length)
|
||||||
|
@ -300,7 +298,6 @@ namespace BizHawk.MultiClient
|
||||||
else
|
else
|
||||||
endComment = temp.Length;
|
endComment = temp.Length;
|
||||||
|
|
||||||
//Validate if such text is not part of a string
|
|
||||||
AddPosition(match.Index, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold);
|
AddPosition(match.Index, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -310,7 +307,6 @@ namespace BizHawk.MultiClient
|
||||||
else
|
else
|
||||||
endComment = LuaText.GetFirstCharIndexFromLine(LuaText.GetLineFromCharIndex(match.Index) + 1) - match.Index;
|
endComment = LuaText.GetFirstCharIndexFromLine(LuaText.GetLineFromCharIndex(match.Index) + 1) - match.Index;
|
||||||
|
|
||||||
//Validate if such text is not part of a string
|
|
||||||
AddPosition(match.Index, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold);
|
AddPosition(match.Index, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,28 +656,33 @@ namespace BizHawk.MultiClient
|
||||||
if (e.KeyCode == Keys.Enter)
|
if (e.KeyCode == Keys.Enter)
|
||||||
{
|
{
|
||||||
string[] Words = { "if", "for", "while", "function" };
|
string[] Words = { "if", "for", "while", "function" };
|
||||||
foreach (string Word in Words)
|
string tabsStr = "";
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int linenumber = LuaText.GetLineFromCharIndex(LuaText.GetFirstCharIndexOfCurrentLine());
|
int linenumber = LuaText.GetLineFromCharIndex(LuaText.GetFirstCharIndexOfCurrentLine());
|
||||||
int tabs = CountTabsAtBeginningOfLine(LuaText.Lines[linenumber]);
|
int tabs = CountTabsAtBeginningOfLine(LuaText.Lines[linenumber]);
|
||||||
if (LuaText.Lines[linenumber].Substring(0 + tabs, Word.Length) == Word)
|
|
||||||
{
|
|
||||||
string str, tabsStr = "";
|
|
||||||
|
|
||||||
for (int a = 1; a <= tabs; a++)
|
for (int a = 1; a <= tabs; a++)
|
||||||
tabsStr += "\t";
|
tabsStr += "\t";
|
||||||
|
|
||||||
str = LuaText.Text.Insert(LuaText.SelectionStart, "\n" + tabsStr + "\t\n" + tabsStr + "end");
|
foreach (string Word in Words)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LuaText.Lines[linenumber].Substring(0 + tabs, Word.Length) == Word)
|
||||||
|
{
|
||||||
|
string str = LuaText.Text.Insert(LuaText.SelectionStart, "\n" + tabsStr + "\t\n" + tabsStr + "end");
|
||||||
LuaText.Text = str;
|
LuaText.Text = str;
|
||||||
LuaText.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + 1 + tabs, 0);
|
LuaText.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + 1 + tabs, 0);
|
||||||
e.SuppressKeyPress = true;
|
e.SuppressKeyPress = true;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string tempStr = LuaText.Text.Insert(LuaText.SelectionStart, "\n" + tabsStr);
|
||||||
|
LuaText.Text = tempStr;
|
||||||
|
LuaText.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + tabs, 0);
|
||||||
|
e.SuppressKeyPress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue