chore(textinput): use getter and setter for width

This commit is contained in:
Christian Rocha
2024-10-23 16:43:23 -04:00
parent aa1fe05f2e
commit 17533b1286
+16 -5
View File
@@ -107,17 +107,17 @@ type Model struct {
// accept. If 0 or less, there's no limit.
CharLimit int
// Width is the maximum number of characters that can be displayed at once.
// It essentially treats the text field like a horizontally scrolling
// viewport. If 0 or less this setting is ignored.
Width int
// KeyMap encodes the keybindings recognized by the widget.
KeyMap KeyMap
// Underlying text value.
value []rune
// width is the maximum number of characters that can be displayed at once. It
// essentially treats the text field like a horizontally scrolling
// viewport. If 0 or less this setting is ignored.
width int
// focus indicates whether user input focus should be on this input
// component. When false, ignore keyboard input and hide the cursor.
focus bool
@@ -198,6 +198,17 @@ func (m Model) Value() string {
return string(m.value)
}
func (m *Model) SetWidth(w int) {
m.width = w
}
// Width is the maximum number of characters that can be displayed at
// once. It essentially treats the text field like a horizontally scrolling
// viewport. If 0 or less this setting is ignored.
func (m Model) Width() int {
return m.width
}
// Position returns the cursor position.
func (m Model) Position() int {
return m.pos