mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #1122] [Feature Request]: Methods to move the cursor to start/end in TextArea #812
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#812
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dbohdan on GitHub (Sep 21, 2025).
Original GitHub issue: https://github.com/rivo/tview/issues/1122
I am looking to migrate my application from Bubble Tea to tview for its better text area performance with larger buffers (noticeable at hundreds of lines). Most functionality has a clear replacement, but moving the cursor to the start or end of the buffer doesn't seem to.
It would be useful to have methods like
textArea.MoveCursorToStart()andtextArea.MoveCursorToEnd()to do this directly. I have only found a way to emulate it withtextArea.SetText(textArea.GetText(), false)andtextArea.SetText(textArea.GetText(), true).If you make a breaking change in the future, consider also binding these operations to the semi-standard shortcuts Ctrl+Home (start) and Ctrl+End (end).
@rivo commented on GitHub (Sep 27, 2025):
Maybe somewhat unintuitively, this is already possible with the
Select()function.To move to the beginning of the text:
To move to the end of the text:
I think the reason I did not introduce Ctrl-Home / Ctrl-End to
tviewwas that on my Mac, this is not handed to the terminal application but instead repositions and resizes the terminal window (Ctrl-Home being Ctrl-Fn-LeftArrow). It should be quite simple to add this to your application, however.@dbohdan commented on GitHub (Sep 27, 2025):
Oh, I see. Thanks for explaining. I have implemented the shortcuts in my app.
Implementation.
I didn't notice this line in the documentation for
Select:I think I searched for "cursor" and missed it when going through the matches because there were too many, then focused on looking for "move", "beginning", "start", and "end".
TextAreaprobably doesn't need additional methods, but I think it's a good idea to document cursor manipulation some more. One way to do it would be by implementing Ctrl+Home and Ctrl+End indemos/textarea/.P.S.: The migration from Bubble Tea to tview has been successfully completed.