From 9db4e640a09636a8cca26db521ea295eefaa3a05 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sat, 20 Aug 2016 10:35:57 -0700 Subject: [PATCH] Add pasting in command mode --- cmd/micro/messenger.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/micro/messenger.go b/cmd/micro/messenger.go index 2391bca8..5d1d8cbf 100644 --- a/cmd/micro/messenger.go +++ b/cmd/micro/messenger.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/zyedidia/clipboard" "github.com/zyedidia/tcell" ) @@ -252,11 +253,20 @@ func (m *Messenger) HandleEvent(event tcell.Event, history []string) { m.response = string([]rune(m.response)[:m.cursorx-1]) + string([]rune(m.response)[m.cursorx:]) m.cursorx-- } + case tcell.KeyCtrlV: + clip, _ := clipboard.ReadAll() + m.response = Insert(m.response, m.cursorx, clip) + m.cursorx += Count(clip) case tcell.KeyRune: m.response = Insert(m.response, m.cursorx, string(e.Rune())) m.cursorx++ } history[m.historyNum] = m.response + + case *tcell.EventPaste: + clip := e.Text() + m.response = Insert(m.response, m.cursorx, clip) + m.cursorx += Count(clip) } }