Skip to content

Commit 0e12683

Browse files
committed
More Results Panel Shortcuts
Added more options for results panel shortcuts. Fixed a bug of results panel context menu not updating shortcut key texts.
1 parent a047a4c commit 0e12683

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

External/Plugins/ResultsPanel/PluginMain.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class PluginMain : IPlugin
2929
public Keys PrevError = Keys.Shift | Keys.F12;
3030
public Keys CopyEntry = Keys.Control | Keys.C;
3131
public Keys IgnoreEntry = Keys.Delete;
32+
public Keys ClearResults = Keys.None;
33+
public Keys ClearIgnoredEntries = Keys.None;
3234

3335
#region Required Properties
3436

@@ -157,35 +159,31 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
157159

158160
case EventType.Keys:
159161
KeyEvent ke = (KeyEvent)e;
160-
if (ke.Value == this.NextError)
162+
if (ke.Value == this.pluginUI.nextEntry.ShortcutKeys)
161163
{
162164
ke.Handled = true;
163165
this.pluginUI.NextEntry(null, null);
164166
}
165-
else if (ke.Value == this.PrevError)
167+
else if (ke.Value == this.pluginUI.previousEntry.ShortcutKeys)
166168
{
167169
ke.Handled = true;
168170
this.pluginUI.PreviousEntry(null, null);
169171
}
170-
else if (ke.Value == this.CopyEntry)
172+
else if (ke.Value == this.pluginUI.copyEntryContextMenuItem.ShortcutKeys)
171173
{
172174
ke.Handled = pluginUI.CopyTextShortcut();
173175
}
174-
else if (ke.Value == this.IgnoreEntry)
176+
else if (ke.Value == this.pluginUI.ignoreEntryContextMenuItem.ShortcutKeys)
175177
{
176178
ke.Handled = pluginUI.IgnoreEntryShortcut();
177179
}
178-
break;
179-
180-
case EventType.Shortcut:
181-
DataEvent de = (DataEvent)e;
182-
if (de.Action == "ResultsPanel.ShowNextResult")
180+
else if (ke.Value == this.pluginUI.clearEntriesContextMenuItem.ShortcutKeys)
183181
{
184-
this.NextError = (Keys)de.Data;
182+
ke.Handled = pluginUI.ClearOutput();
185183
}
186-
else if (de.Action == "ResultsPanel.ShowPrevResult")
184+
else if (ke.Value == this.pluginUI.clearIgnoredEntriesContextMenuItem.ShortcutKeys)
187185
{
188-
this.PrevError = (Keys)de.Data;
186+
ke.Handled = pluginUI.ClearIgnoredEntries();
189187
}
190188
break;
191189
}
@@ -246,8 +244,11 @@ public void CreateMenuItem()
246244
String title = TextHelper.GetString("Label.ViewMenuItem");
247245
ToolStripMenuItem viewMenu = (ToolStripMenuItem)PluginBase.MainForm.FindMenuItem("ViewMenu");
248246
ToolStripMenuItem viewItem = new ToolStripMenuItem(title, this.pluginImage, new EventHandler(this.OpenPanel));
249-
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ShowNextResult", this.NextError);
250-
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ShowPrevResult", this.PrevError);
247+
PluginBase.MainForm.RegisterShortcutItem("ResultsPanel.ShowNextResult", this.pluginUI.nextEntry);
248+
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);
251252
PluginBase.MainForm.RegisterShortcutItem("ViewMenu.ShowResults", viewItem);
252253
viewMenu.DropDownItems.Add(viewItem);
253254
}
@@ -261,7 +262,7 @@ public void CreatePluginPanel()
261262
this.pluginUI.Text = TextHelper.GetString("Title.PluginPanel");
262263
this.pluginPanel = PluginBase.MainForm.CreateDockablePanel(this.pluginUI, this.pluginGuid, this.pluginImage, DockState.DockBottomAutoHide);
263264
}
264-
265+
265266
/// <summary>
266267
/// Opens the plugin panel if closed
267268
/// </summary>

External/Plugins/ResultsPanel/PluginUI.cs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ namespace ResultsPanel
1919
{
2020
public class PluginUI : DockPanelControl
2121
{
22+
public ToolStripMenuItem clearEntriesContextMenuItem;
23+
public ToolStripMenuItem copyEntryContextMenuItem;
24+
public ToolStripMenuItem ignoreEntryContextMenuItem;
25+
public ToolStripMenuItem clearIgnoredEntriesContextMenuItem;
26+
public ToolStripMenuItem nextEntry;
27+
public ToolStripMenuItem previousEntry;
28+
2229
private ListViewEx entriesView;
2330
private ColumnHeader entryFile;
2431
private ColumnHeader entryDesc;
2532
private ColumnHeader entryLine;
2633
private ColumnHeader entryPath;
2734
private ColumnHeader entryType;
28-
private ToolStripMenuItem nextEntry;
29-
private ToolStripMenuItem previousEntry;
30-
private ToolStripMenuItem ignoreEntriesContextMenuItem;
31-
private ToolStripMenuItem ignoreEntryContextMenuItem;
32-
private ToolStripMenuItem copyEntryContextMenuItem;
33-
private ToolStripMenuItem clearIgnoredEntriesContextMenuItem;
3435
private IDictionary<String, Boolean> ignoredEntries;
3536
private List<ListViewItem> allListViewItems = new List<ListViewItem>();
3637
private ToolStripButton toolStripButtonError;
@@ -267,22 +268,24 @@ public void InitializeGraphics()
267268
public void InitializeContextMenu()
268269
{
269270
ContextMenuStrip menu = new ContextMenuStrip();
270-
this.ignoreEntriesContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ClearEntries"), null, new EventHandler(this.ClearOutputClick));
271-
menu.Items.Add(this.ignoreEntriesContextMenuItem);
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);
272274
this.copyEntryContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.CopyEntry"), null, new EventHandler(this.CopyTextClick));
273-
this.copyEntryContextMenuItem.ShortcutKeyDisplayString = DataConverter.KeysToString(this.pluginMain.CopyEntry);
275+
this.copyEntryContextMenuItem.ShortcutKeys = this.pluginMain.CopyEntry;
274276
menu.Items.Add(this.copyEntryContextMenuItem);
275277
this.ignoreEntryContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.IgnoreEntry"), null, new EventHandler(this.IgnoreEntryClick));
276-
this.ignoreEntryContextMenuItem.ShortcutKeyDisplayString = DataConverter.KeysToString(this.pluginMain.IgnoreEntry);
278+
this.ignoreEntryContextMenuItem.ShortcutKeys = this.pluginMain.IgnoreEntry;
277279
menu.Items.Add(this.ignoreEntryContextMenuItem);
278-
this.clearIgnoredEntriesContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ClearIgnoredEntries"), null, new EventHandler(this.ClearIgnoredEntries));
280+
this.clearIgnoredEntriesContextMenuItem = new ToolStripMenuItem(TextHelper.GetString("Label.ClearIgnoredEntries"), null, new EventHandler(this.ClearIgnoredEntriesClick));
281+
this.clearIgnoredEntriesContextMenuItem.ShortcutKeys = this.pluginMain.ClearIgnoredEntries;
279282
menu.Items.Add(this.clearIgnoredEntriesContextMenuItem);
280283
menu.Items.Add(new ToolStripSeparator());
281284
this.nextEntry = new ToolStripMenuItem(TextHelper.GetString("Label.NextEntry"), null, new EventHandler(this.NextEntry));
282-
this.nextEntry.ShortcutKeyDisplayString = DataConverter.KeysToString(this.pluginMain.NextError);
285+
this.nextEntry.ShortcutKeys = this.pluginMain.NextError;
283286
menu.Items.Add(this.nextEntry);
284287
this.previousEntry = new ToolStripMenuItem(TextHelper.GetString("Label.PreviousEntry"), null, new EventHandler(this.PreviousEntry));
285-
this.previousEntry.ShortcutKeyDisplayString = DataConverter.KeysToString(this.pluginMain.PrevError);
288+
this.previousEntry.ShortcutKeys = this.pluginMain.PrevError;
286289
menu.Items.Add(this.previousEntry);
287290
this.entriesView.ContextMenuStrip = menu;
288291
menu.Font = PluginBase.Settings.DefaultFont;
@@ -389,10 +392,17 @@ public void CopyTextClick(Object sender, System.EventArgs e)
389392
/// <summary>
390393
/// Clears any result entries that are ignored. Invoked from the context menu.
391394
/// </summary>
392-
public void ClearIgnoredEntries(Object sender, System.EventArgs e)
395+
public void ClearIgnoredEntriesClick(Object sender, System.EventArgs e)
396+
{
397+
ClearIgnoredEntries();
398+
}
399+
400+
public bool ClearIgnoredEntries()
393401
{
402+
if (this.ignoredEntries.Count == 0) return false;
394403
this.ignoredEntries.Clear();
395404
this.FilterResults(false);
405+
return true;
396406
}
397407

398408
/// <summary>
@@ -452,7 +462,7 @@ private void PluginUIResize(object sender, EventArgs e)
452462
/// </summary>
453463
private void ContextMenuOpening(object sender, System.ComponentModel.CancelEventArgs e)
454464
{
455-
this.nextEntry.Enabled = this.previousEntry.Enabled = this.ignoreEntriesContextMenuItem.Enabled = this.entriesView.Items.Count > 0;
465+
this.nextEntry.Enabled = this.previousEntry.Enabled = this.clearEntriesContextMenuItem.Enabled = this.entriesView.Items.Count > 0;
456466
this.ignoreEntryContextMenuItem.Enabled = this.copyEntryContextMenuItem.Enabled = this.entriesView.SelectedItems.Count > 0;
457467
this.clearIgnoredEntriesContextMenuItem.Enabled = this.ignoredEntries.Count > 0;
458468
}
@@ -556,8 +566,10 @@ private void MBSafeSetSelAndFocus(ScintillaControl sci, Int32 line, Int32 startP
556566
/// <summary>
557567
/// Clears the output
558568
/// </summary>
559-
public void ClearOutput()
569+
public bool ClearOutput()
560570
{
571+
if (!this.clearEntriesContextMenuItem.Enabled) return false;
572+
561573
this.ClearSquiggles();
562574
this.allListViewItems.Clear();
563575
this.toolStripTextBoxFilter.Text = "";
@@ -566,6 +578,7 @@ public void ClearOutput()
566578
this.DisableContextMenuItems();
567579
this.entryIndex = -1;
568580
this.UpdateButtons();
581+
return true;
569582
}
570583

571584
/// <summary>

0 commit comments

Comments
 (0)