chore(input,textarea): return nil for cursors when using virtual cursors

This commit is contained in:
Christian Rocha
2025-03-01 10:10:36 -05:00
parent 4491afa808
commit 739fec5f64
2 changed files with 16 additions and 14 deletions
+8 -7
View File
@@ -1418,7 +1418,10 @@ func Blink() tea.Msg {
}
// Cursor returns a [tea.Cursor] for rendering a real cursor in a Bubble Tea
// program.
// program. This requires that [Model.VirtualCursor] is set to false.
//
// Note that you will almost certainly also need to adjust the offset cursor
// position per the textarea's per the textarea's position in the terminal.
//
// Example:
//
@@ -1427,13 +1430,11 @@ func Blink() tea.Msg {
// f.Cursor = m.textarea.Cursor()
// f.Cursor.Position.X += offsetX
// f.Cursor.Position.Y += offsetY
//
// Note that you will almost certainly also need to adjust the offset
// position of the textarea to properly set the cursor position.
//
// If you're using a real cursor, you should also set [Model.VirtualCursor] to
// false.
func (m Model) Cursor() *tea.Cursor {
if m.VirtualCursor {
return nil
}
lineInfo := m.LineInfo()
w := lipgloss.Width
baseStyle := m.activeStyle().Base
+8 -7
View File
@@ -867,7 +867,10 @@ func (m Model) validate(v []rune) error {
}
// Cursor returns a [tea.Cursor] for rendering a real cursor in a Bubble Tea
// program.
// program. This requires that [Model.VirtualCursor] is set to false.
//
// Note that you will almost certainly also need to adjust the offset cursor
// position per the textarea's per the textarea's position in the terminal.
//
// Example:
//
@@ -876,13 +879,11 @@ func (m Model) validate(v []rune) error {
// f.Cursor = m.textarea.Cursor()
// f.Cursor.Position.X += offsetX
// f.Cursor.Position.Y += offsetY
//
// Note that you will almost certainly also need to adjust the offset
// position of the textarea to properly set the cursor position.
//
// If you're using a real cursor, you should also set [Model.VirtualCursor] to
// false.
func (m Model) Cursor() *tea.Cursor {
if m.VirtualCursor {
return nil
}
w := lipgloss.Width
xOffset := m.Position() +