diff --git a/cptr/frontend/src/lib/components/DropdownMenu.svelte b/cptr/frontend/src/lib/components/DropdownMenu.svelte index 5f23f9b..4e351f0 100644 --- a/cptr/frontend/src/lib/components/DropdownMenu.svelte +++ b/cptr/frontend/src/lib/components/DropdownMenu.svelte @@ -12,6 +12,8 @@ image?: string; /** Optional check mark on the right when active. */ check?: boolean; + /** Optional keyboard shortcut hint displayed as a single pill on the right. */ + shortcut?: string; } interface Props { @@ -139,6 +141,9 @@ {/if} {item.label} + {#if item.shortcut} + {item.shortcut} + {/if} {#if item.check && item.active} diff --git a/cptr/frontend/src/lib/components/GroupTabBar.svelte b/cptr/frontend/src/lib/components/GroupTabBar.svelte index 51a696c..68da673 100644 --- a/cptr/frontend/src/lib/components/GroupTabBar.svelte +++ b/cptr/frontend/src/lib/components/GroupTabBar.svelte @@ -22,6 +22,7 @@ } from '$lib/stores'; import { openChatTab } from '$lib/stores'; import { chatEnabled, streamingChatTabs } from '$lib/stores/chat'; + import { keybindings, formatChord } from '$lib/stores/keybindings'; import Icon from './Icon.svelte'; import DropdownMenu from './DropdownMenu.svelte'; import { tooltip } from '$lib/tooltip'; @@ -129,16 +130,19 @@ { label: $t('bar.newFile'), icon: 'page', + shortcut: formatChord($keybindings.newFile), onclick: () => { openUntitledFileTab(group.id); }, }, ...($chatEnabled ? [{ label: $t('bar.newChat'), icon: 'chat-bubble', + shortcut: formatChord($keybindings.newChat), onclick: () => { openChatTab(undefined, group.id); }, }] : []), { label: $t('bar.newTerminal'), icon: 'terminal', + shortcut: formatChord($keybindings.newTerminal), onclick: () => { openTerminalTab(group.id); }, }, ]); diff --git a/cptr/frontend/src/lib/components/Modal.svelte b/cptr/frontend/src/lib/components/Modal.svelte index 464a012..525b963 100644 --- a/cptr/frontend/src/lib/components/Modal.svelte +++ b/cptr/frontend/src/lib/components/Modal.svelte @@ -24,7 +24,7 @@ >
e.stopPropagation()} onkeydown={() => {}} > diff --git a/cptr/frontend/src/lib/components/QuickOpen.svelte b/cptr/frontend/src/lib/components/QuickOpen.svelte index cdf4eba..ffbbed4 100644 --- a/cptr/frontend/src/lib/components/QuickOpen.svelte +++ b/cptr/frontend/src/lib/components/QuickOpen.svelte @@ -1,6 +1,7 @@ + + + +
+
+

Keyboard Shortcuts

+ +
+ + +
+ Command + Keybinding +
+ +
+ {#each ACTION_IDS as actionId} + {@const chord = $keybindings[actionId]} + {@const isRecording = recordingAction === actionId} + {@const conflict = getConflict(actionId, chord)} + +
+
+
{ACTION_LABELS[actionId]}
+
{ACTION_DESCRIPTIONS[actionId]}
+
+ +
+ {#if isRecording} + Press keys… + {:else if chord} + + {:else} + + {/if} + + {#if conflict} + ! + {/if} +
+
+ {/each} +
+ +

+ Click a binding to rebind. Press Esc to cancel. +

+
+ + + diff --git a/cptr/frontend/src/lib/components/SettingsModal.svelte b/cptr/frontend/src/lib/components/SettingsModal.svelte index 612d7cb..a496403 100644 --- a/cptr/frontend/src/lib/components/SettingsModal.svelte +++ b/cptr/frontend/src/lib/components/SettingsModal.svelte @@ -3,17 +3,18 @@ import Modal from "./Modal.svelte"; import General from "./Settings/General.svelte"; import Account from "./Settings/Account.svelte"; + import Keyboard from "./Settings/Keyboard.svelte"; import About from "./Settings/About.svelte"; import { t } from '$lib/i18n'; interface Props { onclose: () => void; - initialTab?: 'general' | 'account' | 'about'; + initialTab?: 'general' | 'keyboard' | 'account' | 'about'; } let { onclose, initialTab = 'general' }: Props = $props(); - let activeTab = $state<"general" | "account" | "about">(initialTab); + let activeTab = $state<"general" | "keyboard" | "account" | "about">(initialTab); {$t('settings.back')} - {#each [{ id: "general", label: $t('settings.general'), icon: "settings" }, { id: "account", label: $t('settings.account'), icon: "user" }, { id: "about", label: $t('settings.about'), icon: "info" }] as tab} + {#each [{ id: "general", label: $t('settings.general'), icon: "settings" }, { id: "keyboard", label: "Keyboard", icon: "terminal" }, { id: "account", label: $t('settings.account'), icon: "user" }, { id: "about", label: $t('settings.about'), icon: "info" }] as tab}