mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
feat(tracker/gioui): user-defined keybindings.yml override defaults
The behaviour of the user-defined keybindings.yml was changed. It now documents just the changes from the default keybindings. An empty line with no action means "unbind the key".
This commit is contained in:
parent
eb9413b9a0
commit
daf7fb1519
@ -1,3 +1,11 @@
|
|||||||
|
# You can place your custom keybindings.yml in the Sointu config directory e.g.
|
||||||
|
# AppData\Roaming\sointu\keybindings.yml on Windows. There, you can override the
|
||||||
|
# default keybindings with your own. The format is the same as below. A
|
||||||
|
# keybinding without any action means unbinding the key. For example, the line
|
||||||
|
#
|
||||||
|
# - {key: "A"}
|
||||||
|
#
|
||||||
|
# will stop the A key from sending NoteOff events.
|
||||||
- {key: "C", shortcut: true, action: "Copy"}
|
- {key: "C", shortcut: true, action: "Copy"}
|
||||||
- {key: "V", shortcut: true, action: "Paste"}
|
- {key: "V", shortcut: true, action: "Paste"}
|
||||||
- {key: "A", shortcut: true, action: "SelectAll"}
|
- {key: "A", shortcut: true, action: "SelectAll"}
|
||||||
|
@ -60,10 +60,9 @@ func loadDefaultKeyBindings() []KeyBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
keyBindings := loadCustomKeyBindings()
|
keyBindings := loadDefaultKeyBindings()
|
||||||
if keyBindings == nil {
|
keyBindings = append(keyBindings, loadCustomKeyBindings()...)
|
||||||
keyBindings = loadDefaultKeyBindings()
|
|
||||||
}
|
|
||||||
for _, kb := range keyBindings {
|
for _, kb := range keyBindings {
|
||||||
var mods key.Modifiers
|
var mods key.Modifiers
|
||||||
if kb.Shortcut {
|
if kb.Shortcut {
|
||||||
@ -84,8 +83,17 @@ func init() {
|
|||||||
if kb.Super {
|
if kb.Super {
|
||||||
mods |= key.ModSuper
|
mods |= key.ModSuper
|
||||||
}
|
}
|
||||||
keyBindingMap[key.Event{Name: key.Name(kb.Key), Modifiers: mods, State: key.Press}] = kb.Action
|
|
||||||
if _, ok := keyActionMap[KeyAction(kb.Action)]; !ok {
|
keyEvent := key.Event{Name: key.Name(kb.Key), Modifiers: mods, State: key.Press}
|
||||||
|
action, ok := keyBindingMap[keyEvent] // if this key has been previously bound, remove it from the hint map
|
||||||
|
if ok {
|
||||||
|
delete(keyActionMap, KeyAction(action))
|
||||||
|
}
|
||||||
|
if kb.Action == "" { // unbind
|
||||||
|
delete(keyBindingMap, keyEvent)
|
||||||
|
} else { // bind
|
||||||
|
keyBindingMap[keyEvent] = kb.Action
|
||||||
|
// last binding of the some action wins for displaying the hint
|
||||||
modString := strings.Replace(mods.String(), "-", "+", -1)
|
modString := strings.Replace(mods.String(), "-", "+", -1)
|
||||||
text := kb.Key
|
text := kb.Key
|
||||||
if modString != "" {
|
if modString != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user