140 lines
2.5 KiB
JavaScript
140 lines
2.5 KiB
JavaScript
import { goto } from '$app/navigation';
|
|
import { PUBLIC_TAURI } from '$env/static/public';
|
|
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
import { incTextSize, decTextSize, selectNextColor, toggleMenuOpen, appState } from "$lib/stores.svelte"
|
|
|
|
let fullscreen = true;
|
|
|
|
export const hotkeys = new Map();
|
|
|
|
hotkeys.set("Home", {
|
|
name: "Debug-ruta på/av",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
appState.debug = !appState.debug;
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F4", {
|
|
name: "Rensa textfält",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Clear text", appState.text)
|
|
appState.text = ""
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F5", {
|
|
name: "Öppna meny",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
toggleMenuOpen()
|
|
console.log("Menu open", appState.menuOpen)
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F6", {
|
|
name: "Minska textstorlek",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Decrease text size")
|
|
decTextSize()
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F7", {
|
|
name: "Öka textstorlek",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Increase text size")
|
|
incTextSize()
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F8", {
|
|
name: "Växla mellan färginställningar",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Cycle through text and background colors")
|
|
selectNextColor()
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F2", {
|
|
name: "Lägg till förkortning",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
toggleMenuOpen(false)
|
|
appState.open = "create"
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F11", {
|
|
name: "Växla fullskärmsläge",
|
|
action: (e) => {
|
|
console.log("Toggle fullscreen")
|
|
console.log(PUBLIC_TAURI)
|
|
if (PUBLIC_TAURI == true) {
|
|
e.preventDefault()
|
|
if (fullscreen) {
|
|
getCurrentWindow().setFullscreen(false).then(() => {
|
|
fullscreen = false
|
|
|
|
|
|
});
|
|
} else {
|
|
getCurrentWindow().setFullscreen(true).then(() => {
|
|
fullscreen = true
|
|
|
|
});
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
hotkeys.set("F12", {
|
|
name: "Visa statistik",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Open statistics modal")
|
|
appState.open = "statistics"
|
|
}
|
|
})
|
|
|
|
/*
|
|
hotkeys.set("F12", {
|
|
name: "Visa dialogrutan för import",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Open import")
|
|
goto("/import")
|
|
}
|
|
})
|
|
*/
|
|
|
|
hotkeys.set("Escape", {
|
|
name: "Stäng aktiva dialogrutor och fokusera på texten",
|
|
action: (e) => {
|
|
e.preventDefault()
|
|
console.log("Close stuff")
|
|
appState.open = ""
|
|
}
|
|
})
|
|
|
|
hotkeys.set("CTRL+0", {
|
|
name: "Visa 'Välj förkortningslistor'",
|
|
action: (e) => {
|
|
e.preventDefault();
|
|
appState.open = "selectLists";
|
|
}
|
|
})
|
|
|
|
hotkeys.set("CTRL+K", {
|
|
name: "Visa 'Konfigurera kortkommandon'",
|
|
action: (e) => {
|
|
e.preventDefault();
|
|
appState.open = "hotkeys";
|
|
}
|
|
});
|