diff --git a/cursor.go b/cursor.go index 17a580f327..9b37d183b4 100644 --- a/cursor.go +++ b/cursor.go @@ -8,3 +8,26 @@ type CursorPositionMsg struct { // Column is the column number. Column int } + +// CursorStyle is a style that represents the terminal cursor. +type CursorStyle int + +// Cursor styles. +const ( + CursorBlock CursorStyle = 1 + CursorUnderline CursorStyle = 3 + CursorBar CursorStyle = 5 +) + +// setCursorStyle is an internal message that sets the cursor style. +type setCursorStyle int + +// SetCursorStyle is a command that sets the terminal cursor style. +func SetCursorStyle(style CursorStyle, blink bool) Cmd { + if !blink { + style++ + } + return func() Msg { + return setCursorStyle(style) + } +} diff --git a/tea.go b/tea.go index dc167c778c..f518307702 100644 --- a/tea.go +++ b/tea.go @@ -426,6 +426,9 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) { p.suspend() } + case setCursorStyle: + p.execute(ansi.SetCursorStyle(int(msg))) + case modeReportMsg: switch msg.Mode { case graphemeClustering: