1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-07-25 14:24:13 +00:00

Add keyboard shortcuts for applying hints

Each is a two-key combo.  Hit Ctrl+H, then Ctrl+C/D/I/R as desired.
Hitting Ctrl+H followed by any other key results in an error beep.
This commit is contained in:
Andy McFadden
2018-10-07 21:13:37 -07:00
parent 360204a16d
commit 93c76e219f
5 changed files with 80 additions and 28 deletions

View File

@@ -151,6 +151,11 @@ namespace SourceGen.AppForms {
/// </summary>
private int mTargetHighlightIndex = -1;
/// <summary>
/// Set to true if the last key hit was Ctrl+H.
/// </summary>
private bool mCtrlHSeen;
/// <summary>
/// CPU definition used when the Formatter was created. If the CPU choice or
/// inclusion of undocumented opcodes changes, we need to wipe the formatter.
@@ -1130,6 +1135,36 @@ namespace SourceGen.AppForms {
// regardless of which has focus, making it useful for keyboard shortcuts.
// Return true to indicate that we've handled the key.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
// Handle the Ctrl+H chord.
if (mCtrlHSeen) {
if (keyData == (Keys.Control | Keys.C)) {
if (hintAsCodeToolStripMenuItem.Enabled) {
MarkAsCode_Click(null, null);
}
} else if (keyData == (Keys.Control | Keys.D)) {
if (hintAsDataToolStripMenuItem.Enabled) {
MarkAsData_Click(null, null);
}
} else if (keyData == (Keys.Control | Keys.I)) {
if (hintAsInlineDataToolStripMenuItem.Enabled) {
MarkAsInlineData_Click(null, null);
}
} else if (keyData == (Keys.Control | Keys.R)) {
if (removeHintToolStripMenuItem.Enabled) {
MarkAsNoHint_Click(null, null);
}
} else {
System.Media.SystemSounds.Beep.Play();
}
mCtrlHSeen = false;
toolStripStatusLabel.Text = Properties.Resources.STATUS_READY;
return true;
} else if (keyData == (Keys.Control | Keys.H)) {
mCtrlHSeen = true;
toolStripStatusLabel.Text = Properties.Resources.STATUS_CTRL_H_HIT;
return true;
}
// Ctrl-Shift-Z is an alias for Redo (Ctrl-Y).
if (keyData == (Keys.Control | Keys.Shift | Keys.Z)) {
if (redoToolStripMenuItem.Enabled) {