janitorial work
This commit is contained in:
@@ -4,11 +4,18 @@
|
||||
*/
|
||||
|
||||
import { useKeyboard, useRenderer } from "@opentui/solid"
|
||||
import type { TabId } from "../components/Tab"
|
||||
import type { Accessor } from "solid-js"
|
||||
|
||||
const TAB_ORDER: TabId[] = ["feed", "shows", "discover", "search", "player", "settings"]
|
||||
|
||||
type TabId =
|
||||
| "feed"
|
||||
| "shows"
|
||||
| "discover"
|
||||
| "search"
|
||||
| "player"
|
||||
| "settings"
|
||||
|
||||
type ShortcutOptions = {
|
||||
activeTab: TabId
|
||||
onTabChange: (tab: TabId) => void
|
||||
@@ -53,8 +60,9 @@ export function useAppKeyboard(options: ShortcutOptions) {
|
||||
return
|
||||
}
|
||||
|
||||
// Return key cycles tabs (equivalent to Tab)
|
||||
if (key.name === "return") {
|
||||
options.onAction?.("enter")
|
||||
options.onTabChange(getNextTab(options.activeTab))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { useKeyboard, useRenderer } from "@opentui/solid"
|
||||
|
||||
type ShortcutOptions = {
|
||||
onSave?: () => void
|
||||
onQuit?: () => void
|
||||
onTabNext?: () => void
|
||||
onTabPrev?: () => void
|
||||
}
|
||||
|
||||
export function useKeyboardShortcuts(options: ShortcutOptions) {
|
||||
const renderer = useRenderer()
|
||||
|
||||
useKeyboard((key) => {
|
||||
if (key.ctrl && key.name === "q") {
|
||||
if (options.onQuit) {
|
||||
options.onQuit()
|
||||
} else {
|
||||
renderer.destroy()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (key.ctrl && key.name === "s") {
|
||||
options.onSave?.()
|
||||
return
|
||||
}
|
||||
|
||||
if (key.name === "right") {
|
||||
options.onTabNext?.()
|
||||
return
|
||||
}
|
||||
|
||||
if (key.name === "left") {
|
||||
options.onTabPrev?.()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user