inputfields.go 595 B

1234567891011121314151617181920212223
  1. package ui
  2. import (
  3. "github.com/gdamore/tcell/v2"
  4. "github.com/rivo/tview"
  5. )
  6. // NewMessageInputField creates and returns a new message inputfield.
  7. func NewMessageInputField(
  8. onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey,
  9. ) *tview.InputField {
  10. i := tview.NewInputField()
  11. i.
  12. SetPlaceholder("Message...").
  13. SetPlaceholderTextColor(tcell.ColorWhite).
  14. SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
  15. SetInputCapture(onMessageInputFieldInputCapture).
  16. SetBorder(true).
  17. SetBorderPadding(0, 0, 1, 0).
  18. SetTitleAlign(tview.AlignLeft)
  19. return i
  20. }