Merge branch 'master' of https://github.com/to-miz/micro into to-miz-master

This commit is contained in:
Zachary Yedidia 2016-09-07 16:57:42 -04:00
commit cc73efc0bd

View file

@ -342,7 +342,33 @@ 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
funcName := FuncName(action)
if funcName != "main.(*View).ToggleMacro" && funcName != "main.(*View).PlayMacro" {
if recordingMacro {
curMacro = append(curMacro, action)
}
}
}
}
}
}
}
if !isBinding && e.Key() == tcell.KeyRune {
// Insert a character
if v.Cursor.HasSelection() {
v.Cursor.DeleteSelection()
@ -361,28 +387,6 @@ func (v *View) HandleEvent(event tcell.Event) {
if recordingMacro {
curMacro = append(curMacro, e.Rune())
}
} 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
funcName := FuncName(action)
if funcName != "main.(*View).ToggleMacro" && funcName != "main.(*View).PlayMacro" {
if recordingMacro {
curMacro = append(curMacro, action)
}
}
}
}
}
}
}
case *tcell.EventPaste:
if !PreActionCall("Paste", v) {