Add method for returning cursor position in textinput

Previously, Cursor was a member on the model that did absolutely
nothing.
This commit is contained in:
Christian Rocha 2021-04-26 11:02:25 -04:00
parent 74436326b9
commit f016c31d83

View File

@ -61,7 +61,6 @@ type Model struct {
// General settings.
Prompt string
Placeholder string
Cursor string
BlinkSpeed time.Duration
EchoMode EchoMode
EchoCharacter rune
@ -150,6 +149,11 @@ func (m Model) Value() string {
return string(m.value)
}
// Cursor returns the cursor position.
func (m Model) Cursor() int {
return m.pos
}
// SetCursor moves the cursor to the given position. If the position is
// out of bounds the cursor will be moved to the start or end accordingly.
func (m *Model) SetCursor(pos int) {