From 07d8a0842260ec1833017008224a0fb856419816 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Mon, 2 May 2016 11:16:03 -0400 Subject: [PATCH] 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 --- cmd/micro/view.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/micro/view.go b/cmd/micro/view.go index f56ff921..184803bc 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -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