paste
This commit is contained in:
parent
7662127aff
commit
19de9a1ba2
2 changed files with 20 additions and 2 deletions
|
|
@ -24,7 +24,9 @@ type (
|
|||
}
|
||||
|
||||
MessageInputKeysConfig struct {
|
||||
Send string `yaml:"send"`
|
||||
Send string `yaml:"send"`
|
||||
Paste string `yaml:"paste"`
|
||||
|
||||
LaunchEditor string `yaml:"launch_editor"`
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +106,9 @@ func newConfig() (*Config, error) {
|
|||
SelectLast: "End",
|
||||
},
|
||||
MessageInput: MessageInputKeysConfig{
|
||||
Send: "Enter",
|
||||
Send: "Enter",
|
||||
|
||||
Paste: "Ctrl+V",
|
||||
LaunchEditor: "Ctrl+E",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/atotto/clipboard"
|
||||
"github.com/diamondburned/arikawa/v3/api"
|
||||
"github.com/diamondburned/arikawa/v3/discord"
|
||||
"github.com/diamondburned/arikawa/v3/utils/json/option"
|
||||
|
|
@ -46,6 +47,9 @@ func (mi *MessageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
|
|||
case config.Keys.MessageInput.Send:
|
||||
mi.sendAction()
|
||||
return nil
|
||||
case config.Keys.MessageInput.Paste:
|
||||
mi.pasteAction()
|
||||
return nil
|
||||
case config.Keys.MessageInput.LaunchEditor:
|
||||
messageInput.launchEditorAction()
|
||||
return nil
|
||||
|
|
@ -100,6 +104,16 @@ func (mi *MessageInput) sendAction() {
|
|||
mi.reset()
|
||||
}
|
||||
|
||||
func (mi *MessageInput) pasteAction() {
|
||||
text, err := clipboard.ReadAll()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Append the text to the message input.
|
||||
mi.SetText(mi.GetText() + text)
|
||||
}
|
||||
|
||||
func (mi *MessageInput) launchEditorAction() {
|
||||
e := config.Editor
|
||||
if e == "default" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue