From 945c12eb1313af92e1c8303e2bfa4f9b4a12121b Mon Sep 17 00:00:00 2001 From: rolanmen1 Date: Thu, 9 Aug 2012 21:53:49 +0000 Subject: [PATCH] LuaWriter. AutoCompleteView will change through selected items by pressing Up/Down while keeping focus of the textbox. This will work once a highlight issue get solved. --- .../tools/LuaWriter.Designer.cs | 2 + BizHawk.MultiClient/tools/LuaWriter.cs | 46 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/BizHawk.MultiClient/tools/LuaWriter.Designer.cs b/BizHawk.MultiClient/tools/LuaWriter.Designer.cs index b0170fccde..5038478999 100644 --- a/BizHawk.MultiClient/tools/LuaWriter.Designer.cs +++ b/BizHawk.MultiClient/tools/LuaWriter.Designer.cs @@ -302,7 +302,9 @@ // this.AutoCompleteView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.AutoCompleteView.FullRowSelect = true; + this.AutoCompleteView.HideSelection = false; this.AutoCompleteView.Location = new System.Drawing.Point(324, 322); + this.AutoCompleteView.MultiSelect = false; this.AutoCompleteView.Name = "AutoCompleteView"; this.AutoCompleteView.Size = new System.Drawing.Size(121, 97); this.AutoCompleteView.TabIndex = 3; diff --git a/BizHawk.MultiClient/tools/LuaWriter.cs b/BizHawk.MultiClient/tools/LuaWriter.cs index f2f7e7fc37..437612b7b6 100644 --- a/BizHawk.MultiClient/tools/LuaWriter.cs +++ b/BizHawk.MultiClient/tools/LuaWriter.cs @@ -684,19 +684,60 @@ namespace BizHawk.MultiClient LuaText.Select(LuaText.GetFirstCharIndexFromLine(linenumber + 1) + tabs, 0); e.SuppressKeyPress = true; } + + if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) + { + if (AutoCompleteView.Visible) + { + e.SuppressKeyPress = true; + SelectNextItem(e.KeyCode == Keys.Down); + } + } + + } + private void SelectNextItem(bool Next) + { + if (AutoCompleteView.SelectedItems.Count > 0) + { + if (Next) + { + if (AutoCompleteView.FocusedItem == AutoCompleteView.Items[AutoCompleteView.Items.Count - 1]) + return; + + AutoCompleteView.FocusedItem = AutoCompleteView.Items[AutoCompleteView.Items.IndexOf(AutoCompleteView.SelectedItems[0]) + 1]; + } + else + { + if (AutoCompleteView.FocusedItem == AutoCompleteView.Items[0]) + return; + + AutoCompleteView.FocusedItem = AutoCompleteView.Items[AutoCompleteView.Items.IndexOf(AutoCompleteView.SelectedItems[0]) - 1]; + } + } + else + { + if(Next) + AutoCompleteView.FocusedItem = AutoCompleteView.Items[0]; + } + } + private string CurrentWord() { int last = LuaText.SelectionStart; int lastSpace = LuaText.Text.Substring(0, last).LastIndexOf(' '); + int lastTab = LuaText.Text.Substring(0, last).LastIndexOf('\t'); int lastLine = LuaText.Text.Substring(0, last).LastIndexOf('\n'); int start = 0; - if (lastSpace > lastLine) + if (lastSpace > lastLine || lastTab > lastLine) { - start = lastSpace; + if (lastSpace > lastTab) + start = lastSpace; + else + start = lastTab; } else { @@ -733,6 +774,7 @@ namespace BizHawk.MultiClient int start = LuaText.SelectionStart; LuaText.Text = LuaText.Text.Insert(start, str); AutoCompleteView.Visible = false; + LuaText.Select(start + str.Length, 0); } }