github charmbracelet/bubbles v0.8.0

latest releases: v2.0.0-alpha.1, v0.20.0, v0.19.0...
3 years ago

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 and CursorHide (all of type CursorMode). You can set the cursor mode via textinput’s Model.SetCursor(CursorMode) and get the cursor mode with Model.CursorMode() CursorMode.

Changed

  • textinput’s Model.Focus() is now Model.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.

The Charm logo

Don't miss a new bubbles release

NewReleases is sending notifications on new releases.