mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #168] Feature request: Expose input field cursor position #133
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#133
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 @asacainbbc on GitHub (Sep 25, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/168
When using inputfields you may need to know where within the input that the user's cursor is positioned.
An example use-case would be for tab completion of arbitrary words within the input field. Without exposing this from within inputfield the most reasonable course of action would be to wrap it and catch all printable keys (increase cursor position) and then track left/right arrow movements and clamp it to the string's length.
While that is certainly a viable method of tracking the user's cursor I believe that this is standard functionality that should be exposed from within Inputfield itself.
@rivo commented on GitHub (Sep 26, 2018):
At the moment, there is no way to move the cursor within an input field without deleting trailing characters. So the solution right now is simple:
len(inputField.GetText())will give you the current cursor position.But one of my next tasks is to work on #103. I will keep in mind to add a
GetCursorPosition()once #103 is implemented.@trestletech commented on GitHub (Dec 24, 2019):
Hi. Thanks tons for your work on this package; I'm really enjoying using it.
I came across this request while looking for
GetCursorPositionandSetCursorPositionmethods onInputField. It looks like the cursor movement functionality that would be needed is already implemented (here) so this might just be a matter of exporting a couple of methods that surface thecursorPos? I'm happy to open a new issue to track this work, but it felt like the original request here actually aligns with what I had in mind. If the straightforward approach is the right one, I'm happy to open a PR.Perhaps tangential, but I'd love to be able to disable the default set of movement keys that you've defined. If that's something you'd be willing to consider, how would you want that surfaced to the user?
P.S. do you have a "sponsor" page anywhere for this package? I'd love to buy you a beer.