InputPrompt. I made the UserOK variable to change to false if the user clicks the Cancel button.
LuaWriter. Adding "end" after pressing Enter if the current line has "if", "for", etc. is now fixed. Also added some more edit menu items, like Undo, Redo, Cut, Copy, Paste, Select All, Search, Replace and Go To... Search and Replace still need to be implemente. Implemente Go To, if the user inserts an invalid text (letters, symbols, etc) it will not close and prompt an error. Otherwise, it will go to the specified line.
This commit is contained in:
parent
174dec1472
commit
bc39f81b8a
|
@ -14,7 +14,7 @@ namespace BizHawk.MultiClient
|
|||
/// </summary>
|
||||
public partial class InputPrompt : Form
|
||||
{
|
||||
public bool UserOK = false; //Will be true if the user selects Ok
|
||||
public bool UserOK; //Will be true if the user selects Ok
|
||||
public string UserText = ""; //What the user selected
|
||||
public bool HexOnly = false;
|
||||
public InputPrompt()
|
||||
|
@ -51,6 +51,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
UserOK = false;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,19 @@
|
|||
this.AutoCompleteView = new System.Windows.Forms.ListView();
|
||||
this.PositionLabel = new System.Windows.Forms.Label();
|
||||
this.ZoomLabel = new System.Windows.Forms.Label();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.goToToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.LuaText = new BizHawk.MultiClient.LuaWriterBox();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
|
@ -59,6 +72,7 @@
|
|||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.editToolStripMenuItem,
|
||||
this.configToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
|
@ -88,8 +102,8 @@
|
|||
// saveAsToolStripMenuItem
|
||||
//
|
||||
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.S)));
|
||||
this.saveAsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
|
||||
| System.Windows.Forms.Keys.S)));
|
||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(195, 22);
|
||||
this.saveAsToolStripMenuItem.Text = "Save &As...";
|
||||
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||
|
@ -179,12 +193,122 @@
|
|||
this.ZoomLabel.TabIndex = 5;
|
||||
this.ZoomLabel.Text = "Zoom: 100%";
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.undoToolStripMenuItem,
|
||||
this.redoToolStripMenuItem,
|
||||
this.toolStripSeparator2,
|
||||
this.cutToolStripMenuItem,
|
||||
this.copyToolStripMenuItem,
|
||||
this.pasteToolStripMenuItem,
|
||||
this.toolStripSeparator3,
|
||||
this.selectAllToolStripMenuItem,
|
||||
this.toolStripSeparator4,
|
||||
this.searchToolStripMenuItem,
|
||||
this.replaceToolStripMenuItem,
|
||||
this.goToToolStripMenuItem});
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
|
||||
this.editToolStripMenuItem.Text = "Edit";
|
||||
//
|
||||
// undoToolStripMenuItem
|
||||
//
|
||||
this.undoToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.undo;
|
||||
this.undoToolStripMenuItem.Name = "undoToolStripMenuItem";
|
||||
this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z)));
|
||||
this.undoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.undoToolStripMenuItem.Text = "Undo";
|
||||
this.undoToolStripMenuItem.Click += new System.EventHandler(this.undoToolStripMenuItem_Click);
|
||||
//
|
||||
// redoToolStripMenuItem
|
||||
//
|
||||
this.redoToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.redo;
|
||||
this.redoToolStripMenuItem.Name = "redoToolStripMenuItem";
|
||||
this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
|
||||
this.redoToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.redoToolStripMenuItem.Text = "Redo";
|
||||
this.redoToolStripMenuItem.Click += new System.EventHandler(this.redoToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(161, 6);
|
||||
//
|
||||
// cutToolStripMenuItem
|
||||
//
|
||||
this.cutToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.CutHS;
|
||||
this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
|
||||
this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X)));
|
||||
this.cutToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.cutToolStripMenuItem.Text = "Cut";
|
||||
this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click);
|
||||
//
|
||||
// copyToolStripMenuItem
|
||||
//
|
||||
this.copyToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Duplicate;
|
||||
this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
|
||||
this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
|
||||
this.copyToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.copyToolStripMenuItem.Text = "Copy";
|
||||
this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
|
||||
//
|
||||
// pasteToolStripMenuItem
|
||||
//
|
||||
this.pasteToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Paste;
|
||||
this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
|
||||
this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V)));
|
||||
this.pasteToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.pasteToolStripMenuItem.Text = "Paste";
|
||||
this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator3
|
||||
//
|
||||
this.toolStripSeparator3.Name = "toolStripSeparator3";
|
||||
this.toolStripSeparator3.Size = new System.Drawing.Size(161, 6);
|
||||
//
|
||||
// selectAllToolStripMenuItem
|
||||
//
|
||||
this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem";
|
||||
this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
|
||||
this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.selectAllToolStripMenuItem.Text = "Select All";
|
||||
this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator4
|
||||
//
|
||||
this.toolStripSeparator4.Name = "toolStripSeparator4";
|
||||
this.toolStripSeparator4.Size = new System.Drawing.Size(161, 6);
|
||||
//
|
||||
// searchToolStripMenuItem
|
||||
//
|
||||
this.searchToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.FindHS;
|
||||
this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
|
||||
this.searchToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
||||
this.searchToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.searchToolStripMenuItem.Text = "Search";
|
||||
//
|
||||
// replaceToolStripMenuItem
|
||||
//
|
||||
this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
|
||||
this.replaceToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H)));
|
||||
this.replaceToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.replaceToolStripMenuItem.Text = "Replace";
|
||||
//
|
||||
// goToToolStripMenuItem
|
||||
//
|
||||
this.goToToolStripMenuItem.Name = "goToToolStripMenuItem";
|
||||
this.goToToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
|
||||
this.goToToolStripMenuItem.Size = new System.Drawing.Size(164, 22);
|
||||
this.goToToolStripMenuItem.Text = "Go to...";
|
||||
this.goToToolStripMenuItem.Click += new System.EventHandler(this.goToToolStripMenuItem_Click);
|
||||
//
|
||||
// LuaText
|
||||
//
|
||||
this.LuaText.AcceptsTab = true;
|
||||
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.Right)));
|
||||
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.Right)));
|
||||
this.LuaText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.LuaText.EnableAutoDragDrop = true;
|
||||
this.LuaText.Location = new System.Drawing.Point(15, 50);
|
||||
|
@ -244,5 +368,18 @@
|
|||
private System.Windows.Forms.Label PositionLabel;
|
||||
private System.Windows.Forms.Label ZoomLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem restoreSettingsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem redoToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||
private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem goToToolStripMenuItem;
|
||||
}
|
||||
}
|
|
@ -443,6 +443,19 @@ namespace BizHawk.MultiClient
|
|||
|
||||
}
|
||||
|
||||
private int CountTabsAtBeginningOfLine(string line)
|
||||
{
|
||||
int tabs = 0;
|
||||
foreach (Char c in line)
|
||||
{
|
||||
if (c == '\t')
|
||||
tabs++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return tabs;
|
||||
}
|
||||
|
||||
private void Changes()
|
||||
{
|
||||
changes = true;
|
||||
|
@ -535,16 +548,25 @@ namespace BizHawk.MultiClient
|
|||
try
|
||||
{
|
||||
int linenumber = LuaText.GetLineFromCharIndex(LuaText.GetFirstCharIndexOfCurrentLine());
|
||||
if (LuaText.Lines[linenumber].Substring(0, Word.Length) == Word)
|
||||
int tabs = CountTabsAtBeginningOfLine(LuaText.Lines[linenumber]);
|
||||
if (LuaText.Lines[linenumber].Substring(0 + tabs, Word.Length) == Word)
|
||||
{
|
||||
string str = LuaText.Text.Insert(LuaText.SelectionStart, "\n\nend");
|
||||
string str, tabsStr = "";
|
||||
|
||||
for (int a = 1; a <= tabs; a++)
|
||||
tabsStr += "\t";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private string CurrentWord()
|
||||
|
@ -654,5 +676,63 @@ namespace BizHawk.MultiClient
|
|||
LuaText.ZoomFactor = 1;
|
||||
ZoomLabel.Text = "Zoom: 100%";
|
||||
}
|
||||
|
||||
private void goToToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
InputPrompt gotodialog = new InputPrompt();
|
||||
gotodialog.FormClosing += (s, a) =>
|
||||
{
|
||||
if (gotodialog.UserOK)
|
||||
{
|
||||
int x;
|
||||
|
||||
if (!int.TryParse(gotodialog.UserText, out x))
|
||||
{
|
||||
a.Cancel = true;
|
||||
MessageBox.Show("You must enter only numbers.", "Invalid text", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else if (Convert.ToInt32(gotodialog.UserText) > LuaText.Lines.Length)
|
||||
{
|
||||
a.Cancel = true;
|
||||
MessageBox.Show("You must enter a number between 1 and " + LuaText.Lines.Length.ToString() + '.', "Invalid Line number", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
};
|
||||
gotodialog.Text = "Go To Line";
|
||||
gotodialog.SetMessage("Line Number (1 - " + LuaText.Lines.Length.ToString() + ')');
|
||||
gotodialog.ShowDialog();
|
||||
int linepos = Convert.ToInt32(gotodialog.UserText) - 1;
|
||||
LuaText.Select(LuaText.GetFirstCharIndexFromLine(linepos) + CountTabsAtBeginningOfLine(LuaText.Lines[linepos]), 0);
|
||||
}
|
||||
|
||||
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.SelectAll();
|
||||
}
|
||||
|
||||
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.Cut();
|
||||
}
|
||||
|
||||
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.Copy();
|
||||
}
|
||||
|
||||
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.Paste();
|
||||
}
|
||||
|
||||
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.Undo();
|
||||
}
|
||||
|
||||
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
LuaText.Redo();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue