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:
rolanmen1 2012-08-09 20:18:43 +00:00
parent 5239b4f55b
commit 4771ba0f15
2 changed files with 338 additions and 337 deletions

View File

@ -53,6 +53,7 @@
this.configToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fontToolStripMenuItem = 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.startWithEmptyScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -61,7 +62,6 @@
this.PositionLabel = new System.Windows.Forms.Label();
this.ZoomLabel = new System.Windows.Forms.Label();
this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
this.backgroundColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -262,6 +262,13 @@
this.syntaxHighlightingToolStripMenuItem.Text = "&Syntax Highlighting";
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
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
@ -342,13 +349,6 @@
this.LuaText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyUp);
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
//
this.AllowDrop = true;

View File

@ -129,7 +129,6 @@ namespace BizHawk.MultiClient
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);
if (ending < temp.Length - 1)
@ -252,7 +251,6 @@ namespace BizHawk.MultiClient
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);
if (ending >= temp.Length)
@ -300,7 +298,6 @@ namespace BizHawk.MultiClient
else
endComment = temp.Length;
//Validate if such text is not part of a string
AddPosition(match.Index, endComment, Global.Config.LuaCommentColor, Global.Config.LuaCommentBold);
}
else
@ -310,7 +307,6 @@ namespace BizHawk.MultiClient
else
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);
}
}
@ -660,28 +656,33 @@ namespace BizHawk.MultiClient
if (e.KeyCode == Keys.Enter)
{
string[] Words = { "if", "for", "while", "function" };
foreach (string Word in Words)
{
try
{
string tabsStr = "";
int linenumber = LuaText.GetLineFromCharIndex(LuaText.GetFirstCharIndexOfCurrentLine());
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++)
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.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + 1 + tabs, 0);
e.SuppressKeyPress = true;
break;
return;
}
}
catch { }
}
string tempStr = LuaText.Text.Insert(LuaText.SelectionStart, "\n" + tabsStr);
LuaText.Text = tempStr;
LuaText.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + tabs, 0);
e.SuppressKeyPress = true;
}
}