From 57a6ee71867d5bb99fc2a59d9df8df0e64dae9ff Mon Sep 17 00:00:00 2001 From: Ford Durbin Date: Sun, 24 Oct 2021 21:06:09 -0500 Subject: [PATCH] Add arrow glyphs #151 --- packages/commands/src/index.ts | 56 +++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/commands/src/index.ts b/packages/commands/src/index.ts index 81aad73ac..3db49daed 100644 --- a/packages/commands/src/index.ts +++ b/packages/commands/src/index.ts @@ -1062,6 +1062,26 @@ export namespace CommandRegistry { */ shift: boolean; + /** + * Whether `'ArrowLeft'` appears in the keystroke. + */ + arrowLeft: boolean; + + /** + * Whether `'ArrowUp'` appears in the keystroke. + */ + arrowUp: boolean; + + /** + * Whether `'ArrowRight'` appears in the keystroke. + */ + arrowRight: boolean; + + /** + * Whether `'ArrowDown'` appears in the keystroke. + */ + arrowDown: boolean; + /** * The primary key for the keystroke. */ @@ -1096,6 +1116,10 @@ export namespace CommandRegistry { let cmd = false; let ctrl = false; let shift = false; + let arrowLeft = false; + let arrowUp = false; + let arrowRight = false; + let arrowDown = false; for (let token of keystroke.split(/\s+/)) { if (token === 'Accel') { if (Platform.IS_MAC) { @@ -1111,11 +1135,29 @@ export namespace CommandRegistry { ctrl = true; } else if (token === 'Shift') { shift = true; + } else if (token === 'ArrowLeft') { + arrowLeft = true; + } else if (token === 'ArrowUp') { + arrowUp = true; + } else if (token === 'ArrowRight') { + arrowRight = true; + } else if (token === 'ArrowDown') { + arrowDown = true; } else if (token.length > 0) { key = token; } } - return { cmd, ctrl, alt, shift, key }; + return { + cmd, + ctrl, + alt, + shift, + key, + arrowLeft, + arrowUp, + arrowRight, + arrowDown + }; } /** @@ -1187,6 +1229,18 @@ export namespace CommandRegistry { if (parts.cmd) { mods += '\u2318 '; } + if (parts.arrowLeft) { + mods += '\u2190 '; + } + if (parts.arrowUp) { + mods += '\u2191 '; + } + if (parts.arrowRight) { + mods += '\u2192 '; + } + if (parts.arrowDown) { + mods += '\u2193 '; + } } else { if (parts.ctrl) { mods += 'Ctrl+';