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)); 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) private void StopScript(int x)

View File

@ -28,178 +28,179 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaWriter)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaWriter));
this.timer = new System.Windows.Forms.Timer(this.components); this.timer = new System.Windows.Forms.Timer(this.components);
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
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.MessageLabel = new System.Windows.Forms.Label(); this.MessageLabel = new System.Windows.Forms.Label();
this.AutoCompleteView = new System.Windows.Forms.ListView(); this.AutoCompleteView = new System.Windows.Forms.ListView();
this.PositionLabel = new System.Windows.Forms.Label(); this.PositionLabel = new System.Windows.Forms.Label();
this.LuaText = new BizHawk.MultiClient.LuaWriterBox(); this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// timer // timer
// //
this.timer.Enabled = true; this.timer.Enabled = true;
this.timer.Interval = 1000; this.timer.Interval = 1000;
this.timer.Tick += new System.EventHandler(this.timer_Tick); this.timer.Tick += new System.EventHandler(this.timer_Tick);
// //
// menuStrip1 // menuStrip1
// //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem, this.fileToolStripMenuItem,
this.configToolStripMenuItem}); this.configToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(843, 24); this.menuStrip1.Size = new System.Drawing.Size(843, 24);
this.menuStrip1.TabIndex = 1; this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// fileToolStripMenuItem // fileToolStripMenuItem
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.saveToolStripMenuItem, this.saveToolStripMenuItem,
this.saveAsToolStripMenuItem, this.saveAsToolStripMenuItem,
this.toolStripSeparator1, this.toolStripSeparator1,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File"; this.fileToolStripMenuItem.Text = "&File";
// //
// saveToolStripMenuItem // saveToolStripMenuItem
// //
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.saveToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.saveToolStripMenuItem.Text = "&Save"; this.saveToolStripMenuItem.Text = "&Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
// //
// saveAsToolStripMenuItem // saveAsToolStripMenuItem
// //
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
| System.Windows.Forms.Keys.S))); | System.Windows.Forms.Keys.S)));
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.saveAsToolStripMenuItem.Text = "Save &As..."; this.saveAsToolStripMenuItem.Text = "Save &As...";
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
// //
// toolStripSeparator1 // toolStripSeparator1
// //
this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(192, 6); this.toolStripSeparator1.Size = new System.Drawing.Size(192, 6);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4"; this.exitToolStripMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(195, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Text = "E&xit";
// //
// configToolStripMenuItem // configToolStripMenuItem
// //
this.configToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.configToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fontToolStripMenuItem, this.fontToolStripMenuItem,
this.syntaxHighlightingToolStripMenuItem}); this.syntaxHighlightingToolStripMenuItem});
this.configToolStripMenuItem.Name = "configToolStripMenuItem"; this.configToolStripMenuItem.Name = "configToolStripMenuItem";
this.configToolStripMenuItem.Size = new System.Drawing.Size(55, 20); this.configToolStripMenuItem.Size = new System.Drawing.Size(55, 20);
this.configToolStripMenuItem.Text = "&Config"; this.configToolStripMenuItem.Text = "&Config";
// //
// fontToolStripMenuItem // fontToolStripMenuItem
// //
this.fontToolStripMenuItem.Name = "fontToolStripMenuItem"; this.fontToolStripMenuItem.Name = "fontToolStripMenuItem";
this.fontToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.fontToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
this.fontToolStripMenuItem.Text = "&Font"; this.fontToolStripMenuItem.Text = "&Font";
this.fontToolStripMenuItem.Click += new System.EventHandler(this.fontToolStripMenuItem_Click); this.fontToolStripMenuItem.Click += new System.EventHandler(this.fontToolStripMenuItem_Click);
// //
// syntaxHighlightingToolStripMenuItem // syntaxHighlightingToolStripMenuItem
// //
this.syntaxHighlightingToolStripMenuItem.Name = "syntaxHighlightingToolStripMenuItem"; this.syntaxHighlightingToolStripMenuItem.Name = "syntaxHighlightingToolStripMenuItem";
this.syntaxHighlightingToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.syntaxHighlightingToolStripMenuItem.Size = new System.Drawing.Size(178, 22);
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);
// //
// MessageLabel // MessageLabel
// //
this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.MessageLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.MessageLabel.AutoSize = true; this.MessageLabel.AutoSize = true;
this.MessageLabel.Location = new System.Drawing.Point(15, 424); this.MessageLabel.Location = new System.Drawing.Point(15, 424);
this.MessageLabel.Name = "MessageLabel"; this.MessageLabel.Name = "MessageLabel";
this.MessageLabel.Size = new System.Drawing.Size(91, 13); this.MessageLabel.Size = new System.Drawing.Size(91, 13);
this.MessageLabel.TabIndex = 2; this.MessageLabel.TabIndex = 2;
this.MessageLabel.Text = " "; this.MessageLabel.Text = " ";
// //
// AutoCompleteView // AutoCompleteView
// //
this.AutoCompleteView.FullRowSelect = true; this.AutoCompleteView.FullRowSelect = true;
this.AutoCompleteView.Location = new System.Drawing.Point(695, 322); this.AutoCompleteView.Location = new System.Drawing.Point(695, 322);
this.AutoCompleteView.Name = "AutoCompleteView"; this.AutoCompleteView.Name = "AutoCompleteView";
this.AutoCompleteView.Size = new System.Drawing.Size(121, 97); this.AutoCompleteView.Size = new System.Drawing.Size(121, 97);
this.AutoCompleteView.TabIndex = 3; this.AutoCompleteView.TabIndex = 3;
this.AutoCompleteView.UseCompatibleStateImageBehavior = false; this.AutoCompleteView.UseCompatibleStateImageBehavior = false;
this.AutoCompleteView.View = System.Windows.Forms.View.List; this.AutoCompleteView.View = System.Windows.Forms.View.List;
this.AutoCompleteView.Visible = false; this.AutoCompleteView.Visible = false;
this.AutoCompleteView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.AutoCompleteView_MouseDoubleClick); this.AutoCompleteView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.AutoCompleteView_MouseDoubleClick);
// //
// PositionLabel // PositionLabel
// //
this.PositionLabel.AutoSize = true; this.PositionLabel.AutoSize = true;
this.PositionLabel.Location = new System.Drawing.Point(14, 30); this.PositionLabel.Location = new System.Drawing.Point(14, 30);
this.PositionLabel.Name = "PositionLabel"; this.PositionLabel.Name = "PositionLabel";
this.PositionLabel.Size = new System.Drawing.Size(46, 13); this.PositionLabel.Size = new System.Drawing.Size(46, 13);
this.PositionLabel.TabIndex = 4; this.PositionLabel.TabIndex = 4;
this.PositionLabel.Text = " "; this.PositionLabel.Text = " ";
// //
// LuaText // LuaText
// //
this.LuaText.AcceptsTab = true; this.LuaText.AcceptsTab = true;
this.LuaText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.LuaText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.LuaText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.LuaText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LuaText.EnableAutoDragDrop = true; this.LuaText.EnableAutoDragDrop = true;
this.LuaText.Location = new System.Drawing.Point(15, 50); this.LuaText.Location = new System.Drawing.Point(15, 50);
this.LuaText.Name = "LuaText"; this.LuaText.Name = "LuaText";
this.LuaText.Size = new System.Drawing.Size(813, 369); this.LuaText.Size = new System.Drawing.Size(813, 369);
this.LuaText.TabIndex = 0; this.LuaText.TabIndex = 0;
this.LuaText.Text = ""; this.LuaText.Text = "";
this.LuaText.WordWrap = false; this.LuaText.WordWrap = false;
this.LuaText.ZoomFactor = 2F; this.LuaText.ZoomFactor = 2F;
this.LuaText.SelectionChanged += new System.EventHandler(this.LuaText_SelectionChanged); this.LuaText.SelectionChanged += new System.EventHandler(this.LuaText_SelectionChanged);
this.LuaText.TextChanged += new System.EventHandler(this.LuaText_TextChanged); this.LuaText.TextChanged += new System.EventHandler(this.LuaText_TextChanged);
this.LuaText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyDown); this.LuaText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.LuaText_KeyDown);
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);
// LuaWriter //
// // LuaWriter
this.AllowDrop = true; //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AllowDrop = true;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.ClientSize = new System.Drawing.Size(843, 441); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.PositionLabel); this.ClientSize = new System.Drawing.Size(843, 441);
this.Controls.Add(this.AutoCompleteView); this.Controls.Add(this.PositionLabel);
this.Controls.Add(this.MessageLabel); this.Controls.Add(this.AutoCompleteView);
this.Controls.Add(this.LuaText); this.Controls.Add(this.MessageLabel);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.LuaText);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "LuaWriter"; this.MainMenuStrip = this.menuStrip1;
this.Text = "LuaWriter"; this.Name = "LuaWriter";
this.Load += new System.EventHandler(this.LuaWriter_Load); this.Text = "LuaWriter";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragDrop); this.Load += new System.EventHandler(this.LuaWriter_Load);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragEnter); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragDrop);
this.menuStrip1.ResumeLayout(false); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.LuaWriter_DragEnter);
this.menuStrip1.PerformLayout(); this.menuStrip1.ResumeLayout(false);
this.ResumeLayout(false); this.menuStrip1.PerformLayout();
this.PerformLayout(); this.ResumeLayout(false);
this.PerformLayout();
} }

View File

@ -489,10 +489,27 @@ namespace BizHawk.MultiClient
AutoCompleteView.Items.Add(item); AutoCompleteView.Items.Add(item);
} }
AutoCompleteView.Location = new Point(0, 0); 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 { }
}
}
} }
private string CurrentWord() private string CurrentWord()
@ -560,5 +577,10 @@ namespace BizHawk.MultiClient
PositionLabel.Text = string.Format("Line {0}/{1}, Column {2}", currentLineIndex + 1, lastLineIndex + 1, currentColumnIndex + 1); PositionLabel.Text = string.Format("Line {0}/{1}, Column {2}", currentLineIndex + 1, lastLineIndex + 1, currentColumnIndex + 1);
} }
} }
private void LuaText_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
}
} }
} }