From 826420a00e6d013301d7f3dd897d60ce12d1345d Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 20 May 2020 13:55:09 -0400 Subject: [PATCH] Add method to text input model to reset the state --- textinput/textinput.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/textinput/textinput.go b/textinput/textinput.go index 61320a9..8319bfd 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -72,6 +72,13 @@ func (m *Model) Blur() { m.blink = true } +// Reset sets the input to its default state with no input. +func (m *Model) Reset() { + m.Value = "" + m.offset = 0 + m.pos = 0 +} + // colorText colorizes a given string according to the TextColor value of the // model func (m *Model) colorText(s string) string {