From 17533b1286030f11baa6fc1629323d56c3d3bd7a Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 23 Oct 2024 15:57:38 -0400 Subject: [PATCH] chore(textinput): use getter and setter for width --- textinput/textinput.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/textinput/textinput.go b/textinput/textinput.go index 949dbd3..4429f29 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -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