Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arrow glyphs #151 #252

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion packages/commands/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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
};
}

/**
Expand Down Expand Up @@ -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 ';
}
Comment on lines +1232 to +1243
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only added to the Mac condition, this means that as-is the arrows are not displayed on other operating systems at all. I will fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 526b143.

} else {
if (parts.ctrl) {
mods += 'Ctrl+';
Expand Down