charmbracelet / charmbracelet/bubbletea
Add support for setting terminal cursor position
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
I am unable to set the terminal cursor position reliably (the real one, not the one rendered by the TextArea bubble). I have tried using direct ANSI escape codes as well as instantiating a separate `termenv` `Output` structure. In both cases the cursor can be moved, but as soon as I render anything with my View method the cursor pops back down to the bottom left corner of the terminal.
Note that I am able to make the cursor visible by returning a `tea.ShowCursor` message from my `Update` method.
**Describe the solution you'd like**
I would like to see a new command generator function added to the API, similar to the `SetWindowTitle` function. Perhaps
```
func SetCursorPosition(row int, column int) Cmd
```
Using this function should set the position of the cursor and it should stay in that position until the method is called again.
**Describe alternatives you've considered**
I know that the `TextArea` bubble uses a rendered cursor by setting a background color on the character at the cursor position. This works for a block cursor, and an underscore cursor could work similarly, but I'm not aware of a way to render a bar cursor (vertical line to the left of the character under the cursor) with this approach.
**Additional context**
Add any other context or screenshots about the feature request here.
Contributor guide
Research direction
Start by reading the existing SetWindowTitle command generator and tracing how View output affects the terminal cursor. Compare that behavior with tea.ShowCursor and the TextArea bubble's rendered cursor, then determine how the requested row and column should persist across renders. Done means a public command sets the real terminal cursor position without it returning to the bottom-left after View renders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100