Reapply "fix(cmd): initialize clipboard in newApplication func (#625)"
This reverts commit 97b2249608.
This commit is contained in:
parent
db9e64fc50
commit
ea7f2cf7b2
2 changed files with 12 additions and 11 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/ayn2op/discordo/internal/ui"
|
||||
"github.com/ayn2op/tview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"golang.design/x/clipboard"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -41,6 +42,10 @@ func newApplication(cfg *config.Config) *application {
|
|||
messageInput: newMessageInput(cfg),
|
||||
}
|
||||
|
||||
if err := clipboard.Init(); err != nil {
|
||||
slog.Error("failed to init clipboard", "err", err)
|
||||
}
|
||||
|
||||
app.pages.SetInputCapture(app.onPagesInputCapture)
|
||||
app.
|
||||
EnableMouse(cfg.Mouse).
|
||||
|
|
|
|||
|
|
@ -59,17 +59,13 @@ func newMessageInput(cfg *config.Config) *messageInput {
|
|||
mentionsList: tview.NewList(),
|
||||
}
|
||||
|
||||
if err := clipboard.Init(); err != nil {
|
||||
slog.Warn("failed to init clipboard", "err", 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