Skip to content

Commit 9ff9b28

Browse files
committed
Keyboard shortcuts help menu
Document built-in keyboard shortcuts
1 parent e686960 commit 9ff9b28

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

css/ui.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,4 +902,12 @@ div.scripting-cell button.scripting-enabled {
902902
#settingsForm .disabled {
903903
opacity: 0.5;
904904
}
905-
905+
.keyboard-shortcuts td {
906+
vertical-align: top;
907+
}
908+
.keyboard-shortcuts td:first-child {
909+
text-align: right;
910+
padding-right: 12px;
911+
padding-bottom: 2px;
912+
min-width: 160px;
913+
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<a tabindex="-1" href="javascript:void(0)">Help</a>
118118
<ul class="dropdown-menu" id="help_menu">
119119
<li><a class="dropdown-item" target="_8bws_help" href="https://8bitworkshop.com/docs/docs/ide.html">IDE Help</a></li>
120+
<li><a class="dropdown-item" href="javascript:void(0)" id="item_keyboard_shortcuts">Keyboard Shortcuts</a></li>
120121
</ul>
121122
</li>
122123
<li class="dropdown dropdown-submenu">

src/ide/ui.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ function setupDebugControls() {
15081508
$("#item_addfile_link").click(_addLinkFile);
15091509
$("#item_request_persist").click(() => requestPersistPermission(true, false));
15101510
$("#item_settings").click(openSettings);
1511+
$("#item_keyboard_shortcuts").click(openKeyboardShortcuts);
15111512
updateDebugWindows();
15121513
// code analyzer?
15131514
if (platform.newCodeAnalyzer) {
@@ -1533,6 +1534,41 @@ function setupDebugControls() {
15331534
}
15341535
}
15351536

1537+
function openKeyboardShortcuts() {
1538+
const isMac = /Mac|iPhone|iPad/.test(navigator.platform);
1539+
const mod = isMac ? '&#8984;' : 'Ctrl';
1540+
const alt = isMac ? '&#8997;' : 'Alt';
1541+
const shift = isMac ? '&#8679;' : 'Shift';
1542+
const shortcut = (keys: string, desc: string) =>
1543+
`<tr><td><kbd>${keys}</kbd></td><td>${desc}</td></tr>`;
1544+
bootbox.dialog({
1545+
title: "Keyboard shortcuts",
1546+
onEscape: true,
1547+
message: `
1548+
<table class="keyboard-shortcuts">
1549+
<tr><th colspan="2">Custom</th></tr>
1550+
${shortcut(`${shift}+${alt}+F`, 'Format document, or selected range(s)')}
1551+
${shortcut('Tab', 'Insert to next tab stop, or indent selected range(s)')}
1552+
${shortcut(`${shift}+Tab`, 'Outdent line(s) or selected range(s)')}
1553+
${shortcut(`Enter`, 'Insert newline, keep cursor at same column pos')}
1554+
<tr><th colspan="2">Standard</th></tr>
1555+
<tr>
1556+
<td>Built-in</td>
1557+
<td>
1558+
Included CodeMirror shortcuts:<br>
1559+
<a target="_blank" href="https://codemirror.net/docs/ref/#commands.defaultKeymap">defaultKeymap</a>,
1560+
<a target="_blank" href="https://codemirror.net/docs/ref/#commands.standardKeymap">standardKeymap</a>,
1561+
<a target="_blank" href="https://codemirror.net/docs/ref/#commands.historyKeymap">historyKeymap</a>,
1562+
<a target="_blank" href="https://codemirror.net/docs/ref/#search.searchKeymap">searchKeymap</a>
1563+
</td>
1564+
</tr>
1565+
</table>`,
1566+
buttons: {
1567+
ok: { label: "OK", className: "btn-primary" }
1568+
}
1569+
});
1570+
}
1571+
15361572
function setupReplaySlider() {
15371573
var replayslider = $("#replayslider");
15381574
var clockslider = $("#clockslider");

0 commit comments

Comments
 (0)