aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/command-processor.go1
-rw-r--r--ui/commands.go10
-rw-r--r--ui/room-view.go6
3 files changed, 17 insertions, 0 deletions
diff --git a/ui/command-processor.go b/ui/command-processor.go
index 10478cc..e9485c4 100644
--- a/ui/command-processor.go
+++ b/ui/command-processor.go
@@ -119,6 +119,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"react": cmdReact,
"download": cmdDownload,
"open": cmdOpen,
+ "copy": cmdCopy,
"sendevent": cmdSendEvent,
"msendevent": cmdMSendEvent,
"setstate": cmdSetState,
diff --git a/ui/commands.go b/ui/commands.go
index 4dd1482..27c9caf 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -34,6 +34,7 @@ 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"
@@ -158,6 +159,7 @@ const (
SelectRedact = "redact"
SelectDownload = "download"
SelectOpen = "open"
+ SelectCopy = "copy"
)
func cmdReply(cmd *Command) {
@@ -176,6 +178,14 @@ func cmdOpen(cmd *Command) {
cmd.Room.StartSelecting(SelectOpen, strings.Join(cmd.Args, " "))
}
+func cmdCopy(cmd *Command) {
+ if clipboard.Unsupported {
+ cmd.Reply("Clipboard unsupported.")
+ } else {
+ cmd.Room.StartSelecting(SelectCopy, strings.Join(cmd.Args, " "))
+ }
+}
+
func cmdReact(cmd *Command) {
if len(cmd.Args) == 0 {
cmd.Reply("Usage: /react <reaction>")
diff --git a/ui/room-view.go b/ui/room-view.go
index 5792626..641e9d1 100644
--- a/ui/room-view.go
+++ b/ui/room-view.go
@@ -25,6 +25,7 @@ import (
"github.com/kyokomi/emoji"
"github.com/mattn/go-runewidth"
+ "github.com/atotto/clipboard"
"maunium.net/go/mauview"
"maunium.net/go/tcell"
@@ -204,6 +205,11 @@ func (view *RoomView) OnSelect(message *messages.UIMessage) {
}
go view.Download(msg.URL, path, view.selectReason == SelectOpen)
}
+ case SelectCopy:
+ msg, ok := message.Renderer.(*messages.TextMessage)
+ if ok {
+ go clipboard.WriteAll(msg.PlainText())
+ }
}
view.selecting = false
view.selectContent = ""