MCPcopy
hub / github.com/ayn2op/discordo / newComposer

Function newComposer

internal/ui/chat/composer.go:64–89  ·  view source on GitHub ↗
(cfg *config.Config, chat *Model)

Source from the content-addressed store, hash-verified

62var _ help.KeyMap = (*composer)(nil)
63
64func newComposer(cfg *config.Config, chat *Model) *composer {
65 c := &composer{
66 TextArea: tview.NewTextArea(),
67 cfg: cfg,
68 chat: chat,
69 sendMessageData: &api.SendMessageData{},
70 cache: cache.NewCache(),
71 mentionsList: newMentionsList(cfg),
72 }
73 c.Box = ui.ConfigureBox(c.Box, &cfg.Theme)
74 c.
75 SetPlaceholder(tview.NewLine(tview.NewSegment("Select a channel to start chatting", tcell.StyleDefault.Dim(true)))).
76 SetClipboard(
77 func(s string) {
78 if err := clipboard.Write(clipboard.FmtText, []byte(s)); err != nil {
79 slog.Error("failed to write clipboard text", "err", err)
80 }
81 },
82 func() string {
83 return string(clipboard.Read(clipboard.FmtText))
84 },
85 ).
86 SetDisabled(true)
87
88 return c
89}
90
91// forwardToTextArea passes a key event to the embedded TextArea then resizes for the new content.
92// SetChangedFunc isn't used: it fires inside replace's defer, before truncateLines/findCursor, so it would observe stale state.

Callers 1

NewModelFunction · 0.85

Calls 3

NewCacheFunction · 0.92
ConfigureBoxFunction · 0.92
newMentionsListFunction · 0.85

Tested by

no test coverage detected