v0.8.0
Textinput Cursor Options and Enhancements
This release introduces options for textinput cursor behavior and improves subtleties with cursor blinking when multiple textinputs are present.
To change the cursor behavior:
import "github.com/charmbracelet/bubbles/textinput"
m := textinput.NewModel()
m.SetCursorMode(textinput.CursorStatic) // no blinking
m.SetCursorMode(textinput.CursorHide) // actually, let's hide the cursor
m.SetCursorMode(textinput.CursorBlink) // jk let's make it blink
Changelog
New
- Cursors now have three modes:
CursorBlink
,CursorStatic
andCursorHide
(all of typeCursorMode
). You can set the cursor mode viatextinput
’sModel.SetCursor(CursorMode)
and get the cursor mode withModel.CursorMode() CursorMode
.
Changed
textinput
’sModel.Focus()
is nowModel.Focus() tea.Cmd
. This will initiate a properly timed cursor blink when focusing on a textinput if the cursor mode is set to blink.
Fixed
- After their initial cursor blink (initiated by
textinput.Blink() tea.Cmd
), textinputs can now only receive blink messages they sent. This prevents textinputs from receiving other textinputs blink messages when focus changes. - When cursor blink messages are sent, former blink messages in transit are invalidated, eliminating the change of rogue blinks.
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter and The Fediverse, or right here in GitHub Discussions.