From f016c31d8344b118e9b0f1664c65e6d5df0d49ec Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 26 Apr 2021 11:02:25 -0400 Subject: [PATCH] Add method for returning cursor position in textinput Previously, Cursor was a member on the model that did absolutely nothing. --- textinput/textinput.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/textinput/textinput.go b/textinput/textinput.go index 9645fa7..85c5ecf 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -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) {