fixed inserting runes that require ctrl+alt

we check wheter an input is a binding first, only if it is not a binding
do we insert the rune regardless of modifiers
This commit is contained in:
to-miz
2016-09-05 16:03:05 +02:00
parent 5d00522d4e
commit 725533d991

View File

@@ -311,7 +311,27 @@ func (v *View) HandleEvent(event tcell.Event) {
// Window resized
tabs[v.TabNum].Resize()
case *tcell.EventKey:
if e.Key() == tcell.KeyRune && (e.Modifiers() == 0 || e.Modifiers() == tcell.ModShift) {
// Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune
isBinding := false
if e.Key() != tcell.KeyRune || e.Modifiers() != 0 {
for key, actions := range bindings {
if e.Key() == key.keyCode {
if e.Key() == tcell.KeyRune {
if e.Rune() != key.r {
continue
}
}
if e.Modifiers() == key.modifiers {
relocate = false
isBinding = true
for _, action := range actions {
relocate = action(v, true) || relocate
}
}
}
}
}
if !isBinding && e.Key() == tcell.KeyRune {
// Insert a character
if v.Cursor.HasSelection() {
v.Cursor.DeleteSelection()
@@ -326,22 +346,6 @@ func (v *View) HandleEvent(event tcell.Event) {
TermMessage(err)
}
}
} else {
for key, actions := range bindings {
if e.Key() == key.keyCode {
if e.Key() == tcell.KeyRune {
if e.Rune() != key.r {
continue
}
}
if e.Modifiers() == key.modifiers {
relocate = false
for _, action := range actions {
relocate = action(v, true) || relocate
}
}
}
}
}
case *tcell.EventPaste:
if !PreActionCall("Paste", v) {