cursor.go
This file
Path
cursor/cursor.go
26 lines · 786 bytes · Go
Last changed by
chore: prepare v2 (#1116)Drew Smirnoffbefore adoption02d6f06
History of this fileTake it
1// Package cursor provides cursor modes.2package cursor34import (5 "charm.land/bubbles/v2/textarea"6 "charm.land/bubbles/v2/textinput"7 "charm.land/gum/v2/style"8)910// TextInput applies the given cursor mode and style to the text input.11func TextInput(i *textinput.Model, mode string, s style.Styles) {12 styles := i.Styles()13 styles.Cursor.Color = s.ToLipgloss().GetForeground()14 styles.Cursor.Blink = mode == "blink"15 i.SetStyles(styles)16 i.SetVirtualCursor(mode != "hide")17}1819// TextArea applies the given cursor mode and style to the text area.20func TextArea(a *textarea.Model, mode string, s style.Styles) {21 styles := a.Styles()22 styles.Cursor.Color = s.ToLipgloss().GetForeground()23 styles.Cursor.Blink = mode == "blink"24 a.SetStyles(styles)25 a.SetVirtualCursor(mode != "hide")26}