LuaConsole: Hides and Disables the new script button on debug mode.

LuaWriter: Automatically adds "end" after pressing enter when if the line has "if", "for", "while", or "function". Even though, it creates a new line before the statement
This commit is contained in:
adelikat 2012-07-25 22:53:11 +00:00
parent a5ed71269d
commit f93be79a47
3 changed files with 191 additions and 163 deletions

View File

@ -100,6 +100,11 @@ namespace BizHawk.MultiClient
LoadSessionFromRecent(Global.Config.RecentLuaSession.GetRecentFileByPosition(0));
}
}
newStripButton1.Visible = Global.MainForm.INTERIM;
newScriptToolStripMenuItem.Visible = Global.MainForm.INTERIM;
newStripButton1.Enabled = Global.MainForm.INTERIM;
newScriptToolStripMenuItem.Enabled = Global.MainForm.INTERIM;
}
private void StopScript(int x)

View File

@ -177,6 +177,7 @@
this.LuaText.TextChanged += new System.EventHandler(this.LuaText_TextChanged);
this.LuaText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyDown);
this.LuaText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyUp);
this.LuaText.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.LuaText_PreviewKeyDown);
//
// LuaWriter
//

View File

@ -489,8 +489,25 @@ namespace BizHawk.MultiClient
AutoCompleteView.Items.Add(item);
}
AutoCompleteView.Location = new Point(0, 0);
}
}
if (e.KeyCode == Keys.Enter)
{
string[] Words = { "if", "for", "while", "function" };
foreach (string Word in Words)
{
try
{
int linenumber = LuaText.GetLineFromCharIndex(LuaText.GetFirstCharIndexOfCurrentLine());
if (LuaText.Lines[linenumber].Substring(0, Word.Length) == Word)
{
string str = LuaText.Text.Insert(LuaText.SelectionStart, "\n\nend");
LuaText.Text = str;
break;
}
}
catch { }
}
}
}
@ -560,5 +577,10 @@ namespace BizHawk.MultiClient
PositionLabel.Text = string.Format("Line {0}/{1}, Column {2}", currentLineIndex + 1, lastLineIndex + 1, currentColumnIndex + 1);
}
}
private void LuaText_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
}
}
}