Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use mod for default keybinds #488

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions src/components/tabs/BoardsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,18 @@ export default function BoardsPage() {

const keyMap = useAtomValue(keyMapAtom);
useHotkeys([
[keyMap.CLOSE_TAB.keys, () => closeTab(activeTab)],
[keyMap.CYCLE_TABS.keys, () => cycleTabs()],
[keyMap.REVERSE_CYCLE_TABS.keys, () => cycleTabs(true)],
["alt+1", () => selectTab(0)],
["ctrl+1", () => selectTab(0)],
["alt+2", () => selectTab(1)],
["ctrl+2", () => selectTab(1)],
["alt+3", () => selectTab(2)],
["ctrl+3", () => selectTab(2)],
["alt+4", () => selectTab(3)],
["ctrl+4", () => selectTab(3)],
["alt+5", () => selectTab(4)],
["ctrl+5", () => selectTab(4)],
["alt+6", () => selectTab(5)],
["ctrl+6", () => selectTab(5)],
["alt+7", () => selectTab(6)],
["ctrl+7", () => selectTab(6)],
["alt+8", () => selectTab(7)],
["ctrl+8", () => selectTab(7)],
["alt+9", () => selectTab(tabs.length - 1)],
["ctrl+9", () => selectTab(tabs.length - 1)],
[keyMap.CLOSE_BOARD_TAB.keys, () => closeTab(activeTab)],
[keyMap.CYCLE_BOARD_TABS.keys, () => cycleTabs()],
[keyMap.REVERSE_CYCLE_BOARD_TABS.keys, () => cycleTabs(true)],
[keyMap.BOARD_TAB_ONE.keys, () => selectTab(0)],
[keyMap.BOARD_TAB_TWO.keys, () => selectTab(1)],
[keyMap.BOARD_TAB_THREE.keys, () => selectTab(2)],
[keyMap.BOARD_TAB_FOUR.keys, () => selectTab(3)],
[keyMap.BOARD_TAB_FIVE.keys, () => selectTab(4)],
[keyMap.BOARD_TAB_SIX.keys, () => selectTab(5)],
[keyMap.BOARD_TAB_SEVEN.keys, () => selectTab(6)],
[keyMap.BOARD_TAB_EIGHT.keys, () => selectTab(7)],
[keyMap.BOARD_TAB_LAST.keys, () => selectTab(tabs.length - 1)],
]);

return (
Expand Down
5 changes: 3 additions & 2 deletions src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ function RootLayout() {

const [keyMap] = useAtom(keyMapAtom);

useHotkeys(keyMap.NEW_TAB.keys, createNewTab);
useHotkeys(keyMap.NEW_BOARD_TAB.keys, createNewTab);
useHotkeys(keyMap.OPEN_FILE.keys, openNewFile);
useHotkeys(keyMap.EXIT_APP.keys, () => exit(0));
const [opened, setOpened] = useState(false);

const menuActions: MenuGroup[] = useMemo(
Expand All @@ -143,7 +144,7 @@ function RootLayout() {
{
label: t("Menu.File.NewTab"),
id: "new_tab",
shortcut: keyMap.NEW_TAB.keys,
shortcut: keyMap.NEW_BOARD_TAB.keys,
action: createNewTab,
},
{
Expand Down
31 changes: 22 additions & 9 deletions src/state/keybinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@ import type {
} from "jotai/vanilla/utils/atomWithStorage";

const keys = {
NEW_TAB: { name: "New tab", keys: "ctrl+t" },
CLOSE_TAB: { name: "Close tab", keys: "ctrl+w" },
OPEN_FILE: { name: "Open File", keys: "ctrl+o" },
SAVE_FILE: { name: "Save File", keys: "ctrl+s" },
OPEN_FILE: { name: "Open File", keys: "mod+o" },
SAVE_FILE: { name: "Save File", keys: "mod+s" },
EXIT_APP: { name: "Exit En-Croissant", keys: "mod+q" },
NEW_BOARD_TAB: { name: "New board tab", keys: "mod+t" },
CLOSE_BOARD_TAB: { name: "Close board tab", keys: "mod+w" },
BOARD_TAB_ONE: { name: "Go to board tab one", keys: "mod+1" },
BOARD_TAB_TWO: { name: "Go to board tab two", keys: "mod+2" },
BOARD_TAB_THREE: { name: "Go to board tab three", keys: "mod+3" },
BOARD_TAB_FOUR: { name: "Go to board tab four", keys: "mod+4" },
BOARD_TAB_FIVE: { name: "Go to board tab five", keys: "mod+5" },
BOARD_TAB_SIX: { name: "Go to board tab six", keys: "mod+6" },
BOARD_TAB_SEVEN: { name: "Go to board tab seven", keys: "mod+7" },
BOARD_TAB_EIGHT: { name: "Go to board tab eight", keys: "mod+8" },
BOARD_TAB_LAST: { name: "Go to rightmost board tab", keys: "mod+9" },
CYCLE_BOARD_TABS: { name: "Cycle board tabs", keys: "ctrl+tab" },
REVERSE_CYCLE_BOARD_TABS: {
name: "Reverse cycle board tabs",
keys: "ctrl+shift+tab",
},
SWAP_ORIENTATION: { name: "Swap orientation", keys: "f" },
CLEAR_SHAPES: { name: "Clear shapes", keys: "ctrl+l" },
CLEAR_SHAPES: { name: "Clear shapes", keys: "mod+l" },
NEXT_MOVE: { name: "Next move", keys: "arrowright" },
PREVIOUS_MOVE: { name: "Previous move", keys: "arrowleft" },
GO_TO_BRANCH_START: { name: "Go to start of branch", keys: "arrowup" },
Expand All @@ -25,8 +40,6 @@ const keys = {
keys: "shift+arrowleft",
},
DELETE_MOVE: { name: "Delete move", keys: "delete" },
CYCLE_TABS: { name: "Cycle tabs", keys: "ctrl+tab" },
REVERSE_CYCLE_TABS: { name: "Reverse cycle tabs", keys: "ctrl+shift+tab" },
TOGGLE_EVAL_BAR: { name: "Toggle Eval Bar and Arrows", keys: "z" },
PRACTICE_TAB: { name: "Go to practice tab", keys: "p" },
ANALYSIS_TAB: { name: "Go to analysis tab", keys: "a" },
Expand All @@ -42,8 +55,8 @@ const keys = {
ANNOTATION_DUBIOUS: { name: "Toggle dubious move annotation", keys: "4" },
ANNOTATION_MISTAKE: { name: "Toggle mistake move annotation", keys: "5" },
ANNOTATION_BLUNDER: { name: "Toggle blunder move annotation", keys: "6" },
TOGGLE_ALL_ENGINES: { name: "Toggle all engines", keys: "ctrl+a" },
TOGGLE_BLUR: { name: "Toggle blur", keys: "ctrl+b" },
TOGGLE_ALL_ENGINES: { name: "Toggle all engines", keys: "mod+a" },
TOGGLE_BLUR: { name: "Toggle blur", keys: "mod+b" },
PREVIOUS_GAME: { name: "Previous game", keys: "pageup" },
NEXT_GAME: { name: "Next game", keys: "pagedown" },
};
Expand Down