textviews.go 509 B

1234567891011121314151617181920212223242526
  1. package ui
  2. import (
  3. "github.com/rivo/tview"
  4. )
  5. func NewMessagesTextView(app *tview.Application) (messagesTextView *tview.TextView) {
  6. messagesTextView = tview.NewTextView().
  7. SetDynamicColors(true).
  8. SetWrap(true).
  9. SetWordWrap(true).
  10. SetScrollable(true).
  11. ScrollToEnd().
  12. SetChangedFunc(onMessagesTextViewChanged(app))
  13. messagesTextView.
  14. SetBorder(true).
  15. SetBorderPadding(0, 0, 1, 1)
  16. return
  17. }
  18. func onMessagesTextViewChanged(app *tview.Application) func() {
  19. return func() {
  20. app.Draw()
  21. }
  22. }