Skip to content

Commit 71b5ee2

Browse files
committed
More Results Panel Shortcuts update 1
1 parent 0e12683 commit 71b5ee2

File tree

2 files changed

+69
-61
lines changed

2 files changed

+69
-61
lines changed

External/Plugins/ResultsPanel/PluginMain.cs

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ public class PluginMain : IPlugin
2525
private Image pluginImage;
2626

2727
// Shortcut management
28-
public Keys NextError = Keys.F12;
29-
public Keys PrevError = Keys.Shift | Keys.F12;
30-
public Keys CopyEntry = Keys.Control | Keys.C;
31-
public Keys IgnoreEntry = Keys.Delete;
32-
public Keys ClearResults = Keys.None;
33-
public Keys ClearIgnoredEntries = Keys.None;
28+
public const Keys CopyEntryKeys = Keys.Control | Keys.C;
29+
public const Keys IgnoreEntryKeys = Keys.Delete;
3430

3531
#region Required Properties
3632

@@ -159,32 +155,28 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
159155

160156
case EventType.Keys:
161157
KeyEvent ke = (KeyEvent)e;
162-
if (ke.Value == this.pluginUI.nextEntry.ShortcutKeys)
158+
switch (PluginBase.MainForm.GetShortcutItemId(ke.Value))
163159
{
164-
ke.Handled = true;
165-
this.pluginUI.NextEntry(null, null);
166-
}
167-
else if (ke.Value == this.pluginUI.previousEntry.ShortcutKeys)
168-
{
169-
ke.Handled = true;
170-
this.pluginUI.PreviousEntry(null, null);
171-
}
172-
else if (ke.Value == this.pluginUI.copyEntryContextMenuItem.ShortcutKeys)
173-
{
174-
ke.Handled = pluginUI.CopyTextShortcut();
175-
}
176-
else if (ke.Value == this.pluginUI.ignoreEntryContextMenuItem.ShortcutKeys)
177-
{
178-
ke.Handled = pluginUI.IgnoreEntryShortcut();
179-
}
180-
else if (ke.Value == this.pluginUI.clearEntriesContextMenuItem.ShortcutKeys)
181-
{
182-
ke.Handled = pluginUI.ClearOutput();
183-
}
184-
else if (ke.Value == this.pluginUI.clearIgnoredEntriesContextMenuItem.ShortcutKeys)
185-
{
186-
ke.Handled = pluginUI.ClearIgnoredEntries();
160+
case null:
161+
break;
162+
case "ResultsPanel.ShowNextResult":
163+
ke.Handled = pluginUI.NextEntry();
164+
break;
165+
case "ResultsPanel.ShowPrevResult":
166+
ke.Handled = pluginUI.PreviousEntry();
167+
break;
168+
case "ResultsPanel.ClearResults":
169+
ke.Handled = pluginUI.ClearOutput();
170+
break;
171+
case "ResultsPanel.ClearIgnoredEntries":
172+
ke.Handled = pluginUI.ClearIgnoredEntries();
173+
break;
174+
default:
175+
if (ke.Value == CopyEntryKeys) ke.Handled = pluginUI.CopyTextShortcut();
176+
else if (ke.Value == IgnoreEntryKeys) ke.Handled = pluginUI.IgnoreEntryShortcut();
177+
break;
187178
}
179+
188180
break;
189181
}
190182
}
@@ -246,9 +238,8 @@ public void CreateMenuItem()
246238
ToolStripMenuItem viewItem = new ToolStripMenuItem(title, this.pluginImage, new EventHandler(this.OpenPanel));
247239
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ShowNextResult", this.pluginUI.nextEntry);
248240
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ShowPrevResult", this.pluginUI.previousEntry);
249-
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.IgnoreEntry", this.pluginUI.ignoreEntryContextMenuItem);
250-
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ClearResults", this.pluginUI.clearEntriesContextMenuItem);
251-
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ClearIgnoredEntries", this.pluginUI.clearIgnoredEntriesContextMenuItem);
241+
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ClearResults", this.pluginUI.clearEntries);
242+
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ClearIgnoredEntries", this.pluginUI.clearIgnoredEntries);
252243
PluginBase.MainForm.RegisterShortcutItem("ViewMenu.ShowResults", viewItem);
253244
viewMenu.DropDownItems.Add(viewItem);
254245
}

External/Plugins/ResultsPanel/PluginUI.cs

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace ResultsPanel
1919
{
2020
public class PluginUI : DockPanelControl
2121
{
22-
public ToolStripMenuItem clearEntriesContextMenuItem;
22+
public ToolStripMenuItem clearEntries;
2323
public ToolStripMenuItem copyEntryContextMenuItem;
24-
public ToolStripMenuItem ignoreEntryContextMenuItem;
25-
public ToolStripMenuItem clearIgnoredEntriesContextMenuItem;
24+
public ToolStripMenuItem ignoreEntry;
25+
public ToolStripMenuItem clearIgnoredEntries;
2626
public ToolStripMenuItem nextEntry;
2727
public ToolStripMenuItem previousEntry;
2828

@@ -268,25 +268,25 @@ public void InitializeGraphics()
268268
public void InitializeContextMenu()
269269
{
270270
ContextMenuStrip menu = new ContextMenuStrip();
271-
this.clearEntriesContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ClearEntries"), null, new EventHandler(this.ClearOutputClick));
272-
this.clearEntriesContextMenuItem.ShortcutKeys = this.pluginMain.ClearResults;
273-
menu.Items.Add(this.clearEntriesContextMenuItem);
271+
272+
this.clearEntries = new ToolStripMenuItem(TextHelper.GetString("Label.ClearEntries"), null, new EventHandler(this.ClearOutputClick));
274273
this.copyEntryContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.CopyEntry"), null, new EventHandler(this.CopyTextClick));
275-
this.copyEntryContextMenuItem.ShortcutKeys = this.pluginMain.CopyEntry;
274+
this.ignoreEntry = new ToolStripMenuItem(TextHelper.GetString("Label.IgnoreEntry"), null, new EventHandler(this.IgnoreEntryClick));
275+
this.clearIgnoredEntries = new ToolStripMenuItem(TextHelper.GetString("Label.ClearIgnoredEntries"), null, new EventHandler(this.ClearIgnoredEntriesClick));
276+
this.nextEntry = new ToolStripMenuItem(TextHelper.GetString("Label.NextEntry"), null, new EventHandler(this.NextEntryClick));
277+
this.previousEntry = new ToolStripMenuItem(TextHelper.GetString("Label.PreviousEntry"), null, new EventHandler(this.PreviousEntryClick));
278+
279+
this.copyEntryContextMenuItem.ShortcutKeyDisplayString = DataConverter.KeysToString(PluginMain.CopyEntryKeys);
280+
this.ignoreEntry.ShortcutKeyDisplayString = DataConverter.KeysToString(PluginMain.IgnoreEntryKeys);
281+
282+
menu.Items.Add(this.clearEntries);
276283
menu.Items.Add(this.copyEntryContextMenuItem);
277-
this.ignoreEntryContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.IgnoreEntry"), null, new EventHandler(this.IgnoreEntryClick));
278-
this.ignoreEntryContextMenuItem.ShortcutKeys = this.pluginMain.IgnoreEntry;
279-
menu.Items.Add(this.ignoreEntryContextMenuItem);
280-
this.clearIgnoredEntriesContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ClearIgnoredEntries"), null, new EventHandler(this.ClearIgnoredEntriesClick));
281-
this.clearIgnoredEntriesContextMenuItem.ShortcutKeys = this.pluginMain.ClearIgnoredEntries;
282-
menu.Items.Add(this.clearIgnoredEntriesContextMenuItem);
284+
menu.Items.Add(this.ignoreEntry);
285+
menu.Items.Add(this.clearIgnoredEntries);
283286
menu.Items.Add(new ToolStripSeparator());
284-
this.nextEntry = new ToolStripMenuItem(TextHelper.GetString("Label.NextEntry"), null, new EventHandler(this.NextEntry));
285-
this.nextEntry.ShortcutKeys = this.pluginMain.NextError;
286287
menu.Items.Add(this.nextEntry);
287-
this.previousEntry = new ToolStripMenuItem(TextHelper.GetString("Label.PreviousEntry"), null, new EventHandler(this.PreviousEntry));
288-
this.previousEntry.ShortcutKeys = this.pluginMain.PrevError;
289288
menu.Items.Add(this.previousEntry);
289+
290290
this.entriesView.ContextMenuStrip = menu;
291291
menu.Font = PluginBase.Settings.DefaultFont;
292292
menu.Renderer = new DockPanelStripRenderer(false);
@@ -397,7 +397,7 @@ public void ClearIgnoredEntriesClick(Object sender, System.EventArgs e)
397397
ClearIgnoredEntries();
398398
}
399399

400-
public bool ClearIgnoredEntries()
400+
public Boolean ClearIgnoredEntries()
401401
{
402402
if (this.ignoredEntries.Count == 0) return false;
403403
this.ignoredEntries.Clear();
@@ -462,9 +462,9 @@ private void PluginUIResize(object sender, EventArgs e)
462462
/// </summary>
463463
private void ContextMenuOpening(object sender, System.ComponentModel.CancelEventArgs e)
464464
{
465-
this.nextEntry.Enabled = this.previousEntry.Enabled = this.clearEntriesContextMenuItem.Enabled = this.entriesView.Items.Count > 0;
466-
this.ignoreEntryContextMenuItem.Enabled = this.copyEntryContextMenuItem.Enabled = this.entriesView.SelectedItems.Count > 0;
467-
this.clearIgnoredEntriesContextMenuItem.Enabled = this.ignoredEntries.Count > 0;
465+
this.nextEntry.Enabled = this.previousEntry.Enabled = this.clearEntries.Enabled = this.entriesView.Items.Count > 0;
466+
this.ignoreEntry.Enabled = this.copyEntryContextMenuItem.Enabled = this.entriesView.SelectedItems.Count > 0;
467+
this.clearIgnoredEntries.Enabled = this.ignoredEntries.Count > 0;
468468
}
469469

470470
/// <summary>
@@ -566,10 +566,9 @@ private void MBSafeSetSelAndFocus(ScintillaControl sci, Int32 line, Int32 startP
566566
/// <summary>
567567
/// Clears the output
568568
/// </summary>
569-
public bool ClearOutput()
569+
public Boolean ClearOutput()
570570
{
571-
if (!this.clearEntriesContextMenuItem.Enabled) return false;
572-
571+
if (this.allListViewItems.Count == 0) return false;
573572
this.ClearSquiggles();
574573
this.allListViewItems.Clear();
575574
this.toolStripTextBoxFilter.Text = "";
@@ -950,9 +949,17 @@ private void ClearSquiggles()
950949
/// <summary>
951950
/// Goes to the next entry in the result list.
952951
/// </summary>
953-
public void NextEntry(Object sender, System.EventArgs e)
952+
public void NextEntryClick(Object sender, System.EventArgs e)
953+
{
954+
NextEntry();
955+
}
956+
957+
/// <summary>
958+
/// Goes to the next entry in the result list.
959+
/// </summary>
960+
public Boolean NextEntry()
954961
{
955-
if (this.entriesView.Items.Count == 0) return;
962+
if (this.entriesView.Items.Count == 0) return false;
956963
if (this.entryIndex >= 0 && this.entryIndex < this.entriesView.Items.Count)
957964
{
958965
this.entriesView.Items[this.entryIndex].ForeColor = this.entriesView.ForeColor;
@@ -963,14 +970,23 @@ public void NextEntry(Object sender, System.EventArgs e)
963970
this.entriesView.Items[this.entryIndex].ForeColor = PluginBase.MainForm.GetThemeColor("ListView.Highlight", SystemColors.Highlight);
964971
this.entriesView.EnsureVisible(this.entryIndex);
965972
this.EntriesViewDoubleClick(null, null);
973+
return true;
974+
}
975+
976+
/// <summary>
977+
/// Goes to the previous entry in the result list.
978+
/// </summary>
979+
public void PreviousEntryClick(Object sender, System.EventArgs e)
980+
{
981+
PreviousEntry();
966982
}
967983

968984
/// <summary>
969985
/// Goes to the previous entry in the result list.
970986
/// </summary>
971-
public void PreviousEntry(Object sender, System.EventArgs e)
987+
public Boolean PreviousEntry()
972988
{
973-
if (this.entriesView.Items.Count == 0) return;
989+
if (this.entriesView.Items.Count == 0) return false;
974990
if (this.entryIndex >= 0 && this.entryIndex < this.entriesView.Items.Count)
975991
{
976992
this.entriesView.Items[this.entryIndex].ForeColor = this.entriesView.ForeColor;
@@ -981,6 +997,7 @@ public void PreviousEntry(Object sender, System.EventArgs e)
981997
this.entriesView.Items[this.entryIndex].ForeColor = PluginBase.MainForm.GetThemeColor("ListView.Highlight", SystemColors.Highlight);
982998
this.entriesView.EnsureVisible(this.entryIndex);
983999
this.EntriesViewDoubleClick(null, null);
1000+
return true;
9841001
}
9851002

9861003
#endregion

0 commit comments

Comments
 (0)