If system clipboard is unsupported, use internal clipboard instead

Fixes #65
This commit is contained in:
Zachary Yedidia
2016-04-23 20:54:52 -04:00
parent 77853ec6b6
commit af3715d55d

View File

@@ -434,11 +434,7 @@ func Redo(v *View) bool {
// Copy the selection to the system clipboard // Copy the selection to the system clipboard
func Copy(v *View) bool { func Copy(v *View) bool {
if v.cursor.HasSelection() { if v.cursor.HasSelection() {
if !clipboard.Unsupported { clipboard.WriteAll(v.cursor.GetSelection())
clipboard.WriteAll(v.cursor.GetSelection())
} else {
messenger.Error("Clipboard is not supported on your system")
}
} }
return true return true
} }
@@ -446,13 +442,9 @@ func Copy(v *View) bool {
// Cut the selection to the system clipboard // Cut the selection to the system clipboard
func Cut(v *View) bool { func Cut(v *View) bool {
if v.cursor.HasSelection() { if v.cursor.HasSelection() {
if !clipboard.Unsupported { clipboard.WriteAll(v.cursor.GetSelection())
clipboard.WriteAll(v.cursor.GetSelection()) v.cursor.DeleteSelection()
v.cursor.DeleteSelection() v.cursor.ResetSelection()
v.cursor.ResetSelection()
} else {
messenger.Error("Clipboard is not supported on your system")
}
} }
return true return true
} }
@@ -460,17 +452,13 @@ func Cut(v *View) bool {
// Paste whatever is in the system clipboard into the buffer // Paste whatever is in the system clipboard into the buffer
// Delete and paste if the user has a selection // Delete and paste if the user has a selection
func Paste(v *View) bool { func Paste(v *View) bool {
if !clipboard.Unsupported { if v.cursor.HasSelection() {
if v.cursor.HasSelection() { v.cursor.DeleteSelection()
v.cursor.DeleteSelection() v.cursor.ResetSelection()
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")
} }
clip, _ := clipboard.ReadAll()
v.eh.Insert(v.cursor.Loc(), clip)
v.cursor.SetLoc(v.cursor.Loc() + Count(clip))
return true return true
} }