Copy to primary clipboard on mouse selection

This commit is contained in:
Zachary Yedidia
2016-09-02 10:44:32 -04:00
parent d9b8a04841
commit 89c34ed8b3

View File

@@ -1,11 +1,13 @@
package main
import (
"runtime"
"strconv"
"strings"
"time"
"github.com/mattn/go-runewidth"
"github.com/zyedidia/clipboard"
"github.com/zyedidia/tcell"
)
@@ -446,6 +448,10 @@ func (v *View) HandleEvent(event tcell.Event) {
if !v.doubleClick && !v.tripleClick {
v.MoveToMouseClick(x, y)
v.Cursor.CurSelection[1] = v.Cursor.Loc
if runtime.GOOS != "windows" && runtime.GOOS != "darwin" {
clipboard.WriteAll(v.Cursor.GetSelection(), "primary")
}
}
v.mouseReleased = true
}