diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-01 15:30:36 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-01 15:30:36 -0500 |
| commit | e740e5478a43358fbbd79636483d000e01f88b7e (patch) | |
| tree | 49041418731a0369b94f8dd6a57a9b2d47133651 | |
| parent | b919f8c0329dcce6802195df1ef0c21780a3a615 (diff) | |
clear selection when setting input contents
| -rw-r--r-- | tui/text_input.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tui/text_input.go b/tui/text_input.go index ba99f48..63335aa 100644 --- a/tui/text_input.go +++ b/tui/text_input.go @@ -22,6 +22,7 @@ func (t *TextInput) Text() string { func (t *TextInput) SetText(text string) { t.beforeCursor = "" t.afterCursor = text + t.selection = "" } func toGraphemes(s string) []string { @@ -167,6 +168,10 @@ func (t *TextInput) Write(text string) { t.beforeCursor += text } +func (t *TextInput) IsEmpty() bool { + return t.beforeCursor == "" && t.selection == "" && t.afterCursor == "" +} + func (t *TextInput) Update(ev Event) (usedKeybind bool) { if Selected != t.id { t.Deselect() |
