fix(cmd): initialize clipboard in newApplication func (#625)
This commit is contained in:
parent
dfaaf10818
commit
f2819e86d3
2 changed files with 13 additions and 13 deletions
|
|
@ -1,9 +1,9 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/ayn2op/discordo/internal/config"
|
||||
"github.com/ayn2op/discordo/internal/keyring"
|
||||
|
|
@ -44,6 +44,10 @@ func newApplication(cfg *config.Config) *application {
|
|||
messageInput: newMessageInput(cfg),
|
||||
}
|
||||
|
||||
if err := clipboard.Init(); err != nil {
|
||||
app.onError("Failed to init clipboard", err)
|
||||
}
|
||||
|
||||
app.pages.SetInputCapture(app.onPagesInputCapture)
|
||||
app.
|
||||
EnableMouse(cfg.Mouse).
|
||||
|
|
@ -242,7 +246,7 @@ func (a *application) showConfirmModal(prompt string, buttons []string, onDone f
|
|||
}
|
||||
|
||||
func (a *application) showErrorModal(msg, err string, info ...any) {
|
||||
a.showModal("[ ERROR ]", msg + "\nReason: " + err, []string{"Copy", "OK"}, func(label string) {
|
||||
a.showModal("[ ERROR ]", msg+"\nReason: "+err, []string{"Copy", "OK"}, func(label string) {
|
||||
if label != "Copy" {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,17 +58,13 @@ func newMessageInput(cfg *config.Config) *messageInput {
|
|||
mentionsList: tview.NewList(),
|
||||
}
|
||||
|
||||
if err := clipboard.Init(); err != nil {
|
||||
app.onError("Failed to init clipboard", err)
|
||||
} else {
|
||||
mi.
|
||||
SetClipboard(func(s string) {
|
||||
clipboard.Write(clipboard.FmtText, []byte(s))
|
||||
}, func() string {
|
||||
data := clipboard.Read(clipboard.FmtText)
|
||||
return string(data)
|
||||
})
|
||||
}
|
||||
mi.
|
||||
SetClipboard(func(s string) {
|
||||
clipboard.Write(clipboard.FmtText, []byte(s))
|
||||
}, func() string {
|
||||
data := clipboard.Read(clipboard.FmtText)
|
||||
return string(data)
|
||||
})
|
||||
|
||||
mi.Box = ui.ConfigureBox(mi.Box, &cfg.Theme)
|
||||
mi.SetInputCapture(mi.onInputCapture)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue