(cfg *config.Config, chat *Model)
| 62 | var _ help.KeyMap = (*composer)(nil) |
| 63 | |
| 64 | func 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. |
no test coverage detected