Add ability to bind alt keys

This lets you bind keys like Alt-b or Alt-f.
This commit also adds some new default keybindings in emacs style, so
alt-a is beginning of line and alt-e is end etc...
This commit is contained in:
Zachary Yedidia
2016-05-22 15:33:40 -04:00
parent df684ec505
commit f9adcd525d
2 changed files with 171 additions and 148 deletions

View File

@@ -253,7 +253,7 @@ func (v *View) HandleEvent(event tcell.Event) {
// Window resized
v.Resize(e.Size())
case *tcell.EventKey:
if e.Key() == tcell.KeyRune {
if e.Key() == tcell.KeyRune && e.Modifiers() == 0 {
// Insert a character
if v.Cursor.HasSelection() {
v.Cursor.DeleteSelection()
@@ -264,6 +264,11 @@ func (v *View) HandleEvent(event tcell.Event) {
} else {
for key, action := range bindings {
if e.Key() == key.keyCode {
if e.Key() == tcell.KeyRune {
if e.Rune() != key.r {
continue
}
}
if e.Modifiers() == key.modifiers {
relocate = action(v)
for _, pl := range loadedPlugins {