KeyShortcutHandler allow capital letters. close #68

This commit is contained in:
2022-06-18 19:26:11 +00:00
parent 6700c27157
commit fc431b164d
3 changed files with 14 additions and 5 deletions

View File

@@ -36,5 +36,7 @@
(case (id.toString)
((when (KEY_MAP.exists key) key)
(dictGet KEY_MAP key))
((when FlxG.keys.pressed.SHIFT key)
(.toUpperCase key))
(key (.toLowerCase key))
(otherwise (throw "FlxKey.toString returned null!")))))))

View File

@@ -51,7 +51,7 @@
((Some _)
(case (stream.takeUntilAndDrop "]")
((Some newShortcuts)
(extractKeyboardShortcuts str stream (+ shortcuts (newShortcuts.toLowerCase))))
(extractKeyboardShortcuts str stream (+ shortcuts newShortcuts)))
(otherwise
(tryCallOrThrow onBadShortcut "unclosed [ in $str" str null)
"")))

View File

@@ -106,15 +106,17 @@
vscode.ViewColumn.Two
(object
enableScripts true)))
(set keyListener (shortcutPanel.webview.onDidReceiveMessage ->:Void key (shortcutHandler.handleKey (the String key))))
(set keyListener
(shortcutPanel.webview.onDidReceiveMessage
->:Void key (shortcutHandler.handleKey (the String key))))
(set shortcutPanel.webview.html (shortcutPanelHtml prefixMap))
(shortcutPanel.webview.postMessage (object command "focus")))
(function shortcutPanelHtml [:PrefixMap<String> prefixMap]
(let [&mut unusedKeys "abcdefghijklmnopqrstuvwxyz1234567890-/"
(let [&mut unusedKeys "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-/"
shortcutParagraphs
(for =>key shortcutKey prefixMap
(set unusedKeys (unusedKeys.replace (key.toLowerCase) ""))
(set unusedKeys (unusedKeys.replace key ""))
"<p><strong>${key}</strong> - $(case shortcutKey
((Prefix innerMap)
"$(Lambda.count innerMap) shortcuts")
@@ -143,7 +145,12 @@
}
});
window.addEventListener('keydown', function (e) {
vscode.postMessage(e.key);
var key = e.key;
if (key == 'Shift')
return;
if (key.length == 1 && e.shiftKey)
key = key.toUpperCase();
vscode.postMessage(key);
});
</script>
</body>