Skip to content

Commit

Permalink
Add method for returning cursor position in textinput
Browse files Browse the repository at this point in the history
Previously, Cursor was a member on the model that did absolutely
nothing.
  • Loading branch information
meowgorithm committed Apr 26, 2021
1 parent 7443632 commit f016c31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type Model struct {
// General settings.
Prompt string
Placeholder string
Cursor string
BlinkSpeed time.Duration
EchoMode EchoMode
EchoCharacter rune
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f016c31

Please sign in to comment.