Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting terminal cursor position #918

Open
indiejames opened this issue Feb 6, 2024 · 3 comments
Open

Add support for setting terminal cursor position #918

indiejames opened this issue Feb 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@indiejames
Copy link

indiejames commented Feb 6, 2024

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.

@indiejames indiejames added the enhancement New feature or request label Feb 6, 2024
@muesli
Copy link
Member

muesli commented Mar 1, 2024

I don't think this is something we'll support, sorry. For the tea renderer to work, it needs to reset the cursor position before rendering.

@meowgorithm
Copy link
Member

Contextual note here that we should ultimately support this for IME (see #874) — however we'll need to reexamine the renderer to get there and I don't see that happening in the short term.

@indiejames
Copy link
Author

Thanks for the feedback. I have moved on to tview/tcell for my application, although I still love bubbletea and would use it if I could control the cursor. But I understand that this is not a priority for most users. Feel free to close this issue or leave it open as you see fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants