feat: function key mapping
This commit is contained in:
Binary file not shown.
@@ -35,6 +35,13 @@ class UiSmokeGoldenTest(unittest.TestCase):
|
||||
self.assertIn('id="function-bar"', body)
|
||||
self.assertIn('id="view-btn"', body)
|
||||
self.assertIn('id="edit-btn"', body)
|
||||
self.assertIn("F3", body)
|
||||
self.assertIn("F4", body)
|
||||
self.assertIn("F5", body)
|
||||
self.assertIn("F6", body)
|
||||
self.assertIn("F7", body)
|
||||
self.assertIn("F8", body)
|
||||
self.assertIn("Alt+R", body)
|
||||
self.assertIn('id="viewer-modal"', body)
|
||||
self.assertIn('id="viewer-content"', body)
|
||||
self.assertIn('id="editor-modal"', body)
|
||||
|
||||
@@ -662,6 +662,72 @@ function shouldHandleShortcut(target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function actionButton(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
function triggerActionButton(id) {
|
||||
const button = actionButton(id);
|
||||
if (!button || button.disabled) {
|
||||
return false;
|
||||
}
|
||||
button.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
function actionShortcutHandled(event) {
|
||||
const altOnly = event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
||||
const noModifiers = !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
||||
|
||||
if (noModifiers) {
|
||||
if (event.key === "F3") {
|
||||
return triggerActionButton("view-btn");
|
||||
}
|
||||
if (event.key === "F4") {
|
||||
return triggerActionButton("edit-btn");
|
||||
}
|
||||
if (event.key === "F5") {
|
||||
return triggerActionButton("copy-btn");
|
||||
}
|
||||
if (event.key === "F6") {
|
||||
return triggerActionButton("move-btn");
|
||||
}
|
||||
if (event.key === "F7") {
|
||||
return triggerActionButton("mkdir-btn");
|
||||
}
|
||||
if (event.key === "F8") {
|
||||
return triggerActionButton("delete-btn");
|
||||
}
|
||||
}
|
||||
|
||||
if (altOnly) {
|
||||
const key = event.key.toLowerCase();
|
||||
if (key === "3") {
|
||||
return triggerActionButton("view-btn");
|
||||
}
|
||||
if (key === "4") {
|
||||
return triggerActionButton("edit-btn");
|
||||
}
|
||||
if (key === "5") {
|
||||
return triggerActionButton("copy-btn");
|
||||
}
|
||||
if (key === "6") {
|
||||
return triggerActionButton("move-btn");
|
||||
}
|
||||
if (key === "7") {
|
||||
return triggerActionButton("mkdir-btn");
|
||||
}
|
||||
if (key === "8") {
|
||||
return triggerActionButton("delete-btn");
|
||||
}
|
||||
if (key === "r") {
|
||||
return triggerActionButton("rename-btn");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function wildcardPopupElements() {
|
||||
return {
|
||||
overlay: document.getElementById("wildcard-popup"),
|
||||
@@ -958,6 +1024,11 @@ function handleKeyboardShortcuts(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (actionShortcutHandled(event)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.shiftKey && event.key === "+") {
|
||||
event.preventDefault();
|
||||
openWildcardPopup("select");
|
||||
|
||||
@@ -62,13 +62,13 @@
|
||||
<section id="footer-bar">
|
||||
<div id="function-bar-meta" class="pathline compact-line">Active:<code id="active-pane-label">left</code></div>
|
||||
<div id="function-bar" class="toolbar compact-toolbar">
|
||||
<button id="view-btn" type="button" disabled>View</button>
|
||||
<button id="edit-btn" type="button" disabled>Edit</button>
|
||||
<button id="copy-btn" type="button" disabled>Copy</button>
|
||||
<button id="move-btn" type="button" disabled>Move</button>
|
||||
<button id="rename-btn" type="button" disabled>Rename</button>
|
||||
<button id="mkdir-btn" type="button">MKdir</button>
|
||||
<button id="delete-btn" type="button" disabled>Delete</button>
|
||||
<button id="view-btn" type="button" disabled><span class="shortcut-hint">F3</span><span>View</span></button>
|
||||
<button id="edit-btn" type="button" disabled><span class="shortcut-hint">F4</span><span>Edit</span></button>
|
||||
<button id="copy-btn" type="button" disabled><span class="shortcut-hint">F5</span><span>Copy</span></button>
|
||||
<button id="move-btn" type="button" disabled><span class="shortcut-hint">F6</span><span>Move</span></button>
|
||||
<button id="rename-btn" type="button" disabled><span class="shortcut-hint">Alt+R</span><span>Rename</span></button>
|
||||
<button id="mkdir-btn" type="button"><span class="shortcut-hint">F7</span><span>MKdir</span></button>
|
||||
<button id="delete-btn" type="button" disabled><span class="shortcut-hint">F8</span><span>Delete</span></button>
|
||||
</div>
|
||||
<div id="actions-error" class="error"></div>
|
||||
</section>
|
||||
|
||||
@@ -318,6 +318,18 @@ button:disabled {
|
||||
#function-bar button {
|
||||
min-width: 72px;
|
||||
padding: 3px 8px;
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.shortcut-hint {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.popup-overlay {
|
||||
|
||||
Reference in New Issue
Block a user