aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/commands.go11
-rw-r--r--ui/room-view.go19
2 files changed, 24 insertions, 6 deletions
diff --git a/ui/commands.go b/ui/commands.go
index 27c9caf..ed853a2 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -34,7 +34,6 @@ import (
"github.com/lucasb-eyer/go-colorful"
"github.com/russross/blackfriday/v2"
- "github.com/atotto/clipboard"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/event"
@@ -179,10 +178,14 @@ func cmdOpen(cmd *Command) {
}
func cmdCopy(cmd *Command) {
- if clipboard.Unsupported {
- cmd.Reply("Clipboard unsupported.")
+ register := strings.Join(cmd.Args, " ")
+ if len(register) == 0 {
+ register = "clipboard"
+ }
+ if (register == "clipboard" || register == "primary") {
+ cmd.Room.StartSelecting(SelectCopy, register)
} else {
- cmd.Room.StartSelecting(SelectCopy, strings.Join(cmd.Args, " "))
+ cmd.Reply("Usage: /copy [register], where register is either \"clipboard\" or \"primary\". Defaults to \"clipboard\".")
}
}
diff --git a/ui/room-view.go b/ui/room-view.go
index 641e9d1..e9523d9 100644
--- a/ui/room-view.go
+++ b/ui/room-view.go
@@ -25,7 +25,7 @@ import (
"github.com/kyokomi/emoji"
"github.com/mattn/go-runewidth"
- "github.com/atotto/clipboard"
+ "github.com/zyedidia/clipboard"
"maunium.net/go/mauview"
"maunium.net/go/tcell"
@@ -208,7 +208,7 @@ func (view *RoomView) OnSelect(message *messages.UIMessage) {
case SelectCopy:
msg, ok := message.Renderer.(*messages.TextMessage)
if ok {
- go clipboard.WriteAll(msg.PlainText())
+ go view.CopyToClipboard(msg.PlainText(),view.selectContent)
}
}
view.selecting = false
@@ -630,6 +630,21 @@ func (view *RoomView) InputSubmit(text string) {
view.SetInputText("")
}
+func (view *RoomView) CopyToClipboard(text string, register string) {
+ if (register == "clipboard" || register == "primary") {
+ err := clipboard.WriteAll(text,register)
+ if err != nil {
+ view.AddServiceMessage(fmt.Sprintf("Clipboard unsupported: %v", err))
+ view.parent.parent.Render()
+ return
+ }
+ } else {
+ view.AddServiceMessage(fmt.Sprintf("Clipboard register %v unsupported", register))
+ view.parent.parent.Render()
+ return
+ }
+}
+
func (view *RoomView) Download(url id.ContentURI, filename string, openFile bool) {
path, err := view.parent.matrix.DownloadToDisk(url, filename)
if err != nil {