Use tcell's EventPaste to capture paste from the OS

This commit uses the recent commit to zyedidia/tcell to capture paste
events from the OS.

Fixes #60
Fixes #61
This commit is contained in:
Zachary Yedidia 2016-05-02 11:16:03 -04:00
parent 4ca6e65197
commit 07d8a08422

View file

@ -268,6 +268,15 @@ func (v *View) HandleEvent(event tcell.Event) {
}
}
}
case *tcell.EventPaste:
if v.cursor.HasSelection() {
v.cursor.DeleteSelection()
v.cursor.ResetSelection()
}
clip := e.Text()
v.eh.Insert(v.cursor.Loc(), clip)
v.cursor.SetLoc(v.cursor.Loc() + Count(clip))
v.freshClip = false
case *tcell.EventMouse:
x, y := e.Position()
x -= v.lineNumOffset - v.leftCol