Merge remote-tracking branch 'julianuu/master'
This commit is contained in:
commit
4e2cbf1e4f
1
go.mod
1
go.mod
@ -16,6 +16,7 @@ require (
|
|||||||
github.com/sasha-s/go-deadlock v0.2.0
|
github.com/sasha-s/go-deadlock v0.2.0
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||||
github.com/stretchr/testify v1.5.1
|
github.com/stretchr/testify v1.5.1
|
||||||
|
github.com/zyedidia/clipboard v0.0.0-20200421031010-7c45b8673834
|
||||||
go.etcd.io/bbolt v1.3.4
|
go.etcd.io/bbolt v1.3.4
|
||||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8
|
||||||
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
|
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
|
||||||
|
@ -119,6 +119,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
|||||||
"react": cmdReact,
|
"react": cmdReact,
|
||||||
"download": cmdDownload,
|
"download": cmdDownload,
|
||||||
"open": cmdOpen,
|
"open": cmdOpen,
|
||||||
|
"copy": cmdCopy,
|
||||||
"sendevent": cmdSendEvent,
|
"sendevent": cmdSendEvent,
|
||||||
"msendevent": cmdMSendEvent,
|
"msendevent": cmdMSendEvent,
|
||||||
"setstate": cmdSetState,
|
"setstate": cmdSetState,
|
||||||
|
@ -158,6 +158,7 @@ const (
|
|||||||
SelectRedact = "redact"
|
SelectRedact = "redact"
|
||||||
SelectDownload = "download"
|
SelectDownload = "download"
|
||||||
SelectOpen = "open"
|
SelectOpen = "open"
|
||||||
|
SelectCopy = "copy"
|
||||||
)
|
)
|
||||||
|
|
||||||
func cmdReply(cmd *Command) {
|
func cmdReply(cmd *Command) {
|
||||||
@ -176,6 +177,18 @@ func cmdOpen(cmd *Command) {
|
|||||||
cmd.Room.StartSelecting(SelectOpen, strings.Join(cmd.Args, " "))
|
cmd.Room.StartSelecting(SelectOpen, strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cmdCopy(cmd *Command) {
|
||||||
|
register := strings.Join(cmd.Args, " ")
|
||||||
|
if len(register) == 0 {
|
||||||
|
register = "clipboard"
|
||||||
|
}
|
||||||
|
if (register == "clipboard" || register == "primary") {
|
||||||
|
cmd.Room.StartSelecting(SelectCopy, register)
|
||||||
|
} else {
|
||||||
|
cmd.Reply("Usage: /copy [register], where register is either \"clipboard\" or \"primary\". Defaults to \"clipboard\".")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func cmdReact(cmd *Command) {
|
func cmdReact(cmd *Command) {
|
||||||
if len(cmd.Args) == 0 {
|
if len(cmd.Args) == 0 {
|
||||||
cmd.Reply("Usage: /react <reaction>")
|
cmd.Reply("Usage: /react <reaction>")
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
"github.com/kyokomi/emoji"
|
"github.com/kyokomi/emoji"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
|
"github.com/zyedidia/clipboard"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/crypto/attachment"
|
"maunium.net/go/mautrix/crypto/attachment"
|
||||||
"maunium.net/go/mauview"
|
"maunium.net/go/mauview"
|
||||||
@ -209,6 +210,11 @@ func (view *RoomView) OnSelect(message *messages.UIMessage) {
|
|||||||
}
|
}
|
||||||
go view.Download(msg.URL, msg.File, path, view.selectReason == SelectOpen)
|
go view.Download(msg.URL, msg.File, path, view.selectReason == SelectOpen)
|
||||||
}
|
}
|
||||||
|
case SelectCopy:
|
||||||
|
msg, ok := message.Renderer.(*messages.TextMessage)
|
||||||
|
if ok {
|
||||||
|
go view.CopyToClipboard(msg.PlainText(), view.selectContent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
view.selecting = false
|
view.selecting = false
|
||||||
view.selectContent = ""
|
view.selectContent = ""
|
||||||
@ -629,6 +635,19 @@ func (view *RoomView) InputSubmit(text string) {
|
|||||||
view.SetInputText("")
|
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()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
view.AddServiceMessage(fmt.Sprintf("Clipboard register %v unsupported", register))
|
||||||
|
view.parent.parent.Render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile, filename string, openFile bool) {
|
func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile, filename string, openFile bool) {
|
||||||
path, err := view.parent.matrix.DownloadToDisk(url, file, filename)
|
path, err := view.parent.matrix.DownloadToDisk(url, file, filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user