Skip to content

Add support for setting terminal cursor position #918

Open
@indiejames

Description

@indiejames

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions