From 510fd8cbe53abb39cba2c7cbaaefcf2783dc0066 Mon Sep 17 00:00:00 2001 From: "netop://ウィビ" Date: Fri, 24 Apr 2026 16:37:33 -0700 Subject: Implement v0.6-1.0: shortcuts, format, export/import, splitter, timing, APQ - v0.6: matchShortcut + format(); Cmd+Shift+Enter/W/F + Cmd+Alt+arrows - v0.7: SessionStore.exportAll/importTabs with version-1 validator - v0.8: Splitter component + four resize handles persisted under layout.* - v0.10: createApqFetcher (HTTP-only) wrapping shared http-body helpers - Drop .svelte re-exports from index.ts for multi-entry JSR/npm publishing --- source/library/state/keyboard.ts | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 source/library/state/keyboard.ts (limited to 'source/library/state/keyboard.ts') diff --git a/source/library/state/keyboard.ts b/source/library/state/keyboard.ts new file mode 100644 index 0000000..5f07b2c --- /dev/null +++ b/source/library/state/keyboard.ts @@ -0,0 +1,50 @@ + + + + +/*** EXPORT ------------------------------------------- ***/ + +export type ShortcutAction = + | { type: "closeTab" } + | { type: "format" } + | { type: "newTab" } + | { type: "nextTab" } + | { type: "prevTab" } + | { type: "run" }; + +export function matchShortcut(event: KeyboardEvent): ShortcutAction | null { + const meta = event.metaKey || event.ctrlKey; + + if (!meta) + return null; + + if (event.key === "Enter") { + if (event.shiftKey) + return { type: "newTab" }; + + if (!event.altKey) + return { type: "run" }; + + return null; + } + + if (event.shiftKey && !event.altKey) { + const key = event.key.toLowerCase(); + + if (key === "w") + return { type: "closeTab" }; + + if (key === "f") + return { type: "format" }; + } + + if (event.altKey && !event.shiftKey) { + if (event.key === "ArrowRight") + return { type: "nextTab" }; + + if (event.key === "ArrowLeft") + return { type: "prevTab" }; + } + + return null; +} -- cgit v1.2.3