textviews.go 625 B

12345678910111213141516171819202122232425262728
  1. package ui
  2. import (
  3. "github.com/gdamore/tcell/v2"
  4. "github.com/rigormorrtiss/discordo/util"
  5. "github.com/rivo/tview"
  6. )
  7. func NewMessagesTextView(app *tview.Application, theme *util.Theme) *tview.TextView {
  8. messagesTextView := tview.NewTextView()
  9. messagesTextView.
  10. SetDynamicColors(true).
  11. SetWordWrap(true).
  12. ScrollToEnd().
  13. SetChangedFunc(onMessagesTextViewChanged(app)).
  14. SetBackgroundColor(tcell.GetColor(theme.TextViewBackground)).
  15. SetBorder(true).
  16. SetBorderPadding(0, 0, 1, 1)
  17. return messagesTextView
  18. }
  19. func onMessagesTextViewChanged(app *tview.Application) func() {
  20. return func() {
  21. app.Draw()
  22. }
  23. }