From af3715d55da4bbf5aede498c7dbe245149b10051 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sat, 23 Apr 2016 20:54:52 -0400 Subject: [PATCH] If system clipboard is unsupported, use internal clipboard instead Fixes #65 --- cmd/micro/bindings.go | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 8ed71995..a6631092 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -434,11 +434,7 @@ func Redo(v *View) bool { // Copy the selection to the system clipboard func Copy(v *View) bool { if v.cursor.HasSelection() { - if !clipboard.Unsupported { - clipboard.WriteAll(v.cursor.GetSelection()) - } else { - messenger.Error("Clipboard is not supported on your system") - } + clipboard.WriteAll(v.cursor.GetSelection()) } return true } @@ -446,13 +442,9 @@ func Copy(v *View) bool { // Cut the selection to the system clipboard func Cut(v *View) bool { if v.cursor.HasSelection() { - if !clipboard.Unsupported { - clipboard.WriteAll(v.cursor.GetSelection()) - v.cursor.DeleteSelection() - v.cursor.ResetSelection() - } else { - messenger.Error("Clipboard is not supported on your system") - } + clipboard.WriteAll(v.cursor.GetSelection()) + v.cursor.DeleteSelection() + v.cursor.ResetSelection() } return true } @@ -460,17 +452,13 @@ func Cut(v *View) bool { // Paste whatever is in the system clipboard into the buffer // Delete and paste if the user has a selection func Paste(v *View) bool { - if !clipboard.Unsupported { - if v.cursor.HasSelection() { - v.cursor.DeleteSelection() - v.cursor.ResetSelection() - } - clip, _ := clipboard.ReadAll() - v.eh.Insert(v.cursor.Loc(), clip) - v.cursor.SetLoc(v.cursor.Loc() + Count(clip)) - } else { - messenger.Error("Clipboard is not supported on your system") + if v.cursor.HasSelection() { + v.cursor.DeleteSelection() + v.cursor.ResetSelection() } + clip, _ := clipboard.ReadAll() + v.eh.Insert(v.cursor.Loc(), clip) + v.cursor.SetLoc(v.cursor.Loc() + Count(clip)) return true }