(token: string, mac = isMacPlatform())
| 1429 | } |
| 1430 | |
| 1431 | export function formatKeyToken(token: string, mac = isMacPlatform()): string { |
| 1432 | if (token.includes("+")) { |
| 1433 | const parts = token.split("+"); |
| 1434 | const base = parts.pop() ?? token; |
| 1435 | const prefix = parts |
| 1436 | .map((part) => formatKeyToken(part, mac)) |
| 1437 | .join(mac ? "" : "+"); |
| 1438 | return `${prefix}${mac ? "" : prefix ? "+" : ""}${formatKeyToken(base, mac)}`; |
| 1439 | } |
| 1440 | if (token === "Mod") return mac ? "⌘" : "Ctrl"; |
| 1441 | if (token === "Meta") return mac ? "⌘" : "Meta"; |
| 1442 | if (token === "Ctrl") return mac ? "⌃" : "Ctrl"; |
| 1443 | if (token === "Alt") return mac ? "⌥" : "Alt"; |
| 1444 | if (token === "Shift") return mac ? "⇧" : "Shift"; |
| 1445 | if (token === "Escape" || token === "Esc") return "Esc"; |
| 1446 | if (token === "Enter") return mac ? "↵" : "Enter"; |
| 1447 | if (token === "Tab") return "Tab"; |
| 1448 | if (token === "Space") return "Space"; |
| 1449 | if (token === "ArrowUp") return "↑"; |
| 1450 | if (token === "ArrowDown") return "↓"; |
| 1451 | if (token === "ArrowLeft") return "←"; |
| 1452 | if (token === "ArrowRight") return "→"; |
| 1453 | return token; |
| 1454 | } |
| 1455 | |
| 1456 | export function formatKeymapBinding(binding: string, kind: KeymapKind): string { |
| 1457 | if (kind === "shortcut") { |
no test coverage detected