Skip to content

Commit

Permalink
feat: alt navigation by default
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Jun 19, 2024
1 parent 49d1a32 commit 54c8f64
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
6 changes: 0 additions & 6 deletions resources/examples/keybindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@
# - label: Open User Directory
# accelerator: CmdOrCtrl+Shift+,
# command: open-user-directory

# - label: Go to Previous Word
# accelerator: Alt+Left
# command: xterm:input
# args:
# - "\eb"
12 changes: 12 additions & 0 deletions src/renderer/assets/keybindings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import type { KeyBinding } from '../../typings/menu'

export default [
{
label: 'Go to Previous Word',
accelerator: 'Alt+Left',
command: 'xterm:input',
args: ['\u001bb'],
},
{
label: 'Go to Next Word',
accelerator: 'Alt+Right',
command: 'xterm:input',
args: ['\u001bf'],
},
{
label: 'Delete the whole line',
accelerator: 'CmdOrCtrl+Backspace',
Expand Down
22 changes: 14 additions & 8 deletions src/renderer/compositions/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,20 @@ interface RendererKeyBinding extends KeyBindingCommand {

const keybindings = $(useKeyBindings())
const rendererKeybindings = $computed(() => {
return keybindings.map<RendererKeyBinding>(binding => ({
pattern: {
...toKeyEvent(binding.accelerator),
type: binding.when ?? 'keydown',
},
command: binding.command!,
args: binding.args,
}))
return keybindings.map<RendererKeyBinding>(binding => {
const pattern = toKeyEvent(binding.accelerator)
if (pattern.code) {
delete pattern.key
}
return {
pattern: {
...pattern,
type: binding.when ?? 'keydown',
},
command: binding.command!,
args: binding.args,
}
})
})

export interface CreateTerminalTabOptions {
Expand Down

0 comments on commit 54c8f64

Please sign in to comment.