mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #554] Feature request: Configurable autocompleteselect in inputfield #403
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#403
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 @rmasp98 on GitHub (Jan 20, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/554
Hi,
Firstly, thank you for such a great library!
I was wondering if you would be open to a configurable autocompleteselect function in the inputfield primitive. This would allow for more sophisticated autocomplete functionality without much complexity, which would be helpful for my app because the search bar I am writing accepts quite complex queries, so I would prefer the autocomplete function to only alter parts of the query rather than the entire text.
This is fairly simple to create (with just a member, setter and getter, and a check in the InputHandler) and I have tested it in my app and it seems to run fine. I would be happy to create a pull request for this.
If you wanted to check out what I am trying to achieve, you can see my app here. It is currently written using go-cui but I am in the middle of rewriting it with tview.
@rivo commented on GitHub (Feb 17, 2021):
I suppose you could use
SetChangedFunc()to listen to changes to the input field (including the ones made via autocomplete) and then setting its text to the full string again. You'd just have to be careful not to create an infinite loop. What do you think about that?@rmasp98 commented on GitHub (Mar 4, 2021):
How would I do that?
The only way I can think of is to store the old field text and cursor position in global variables and then capture a reference to the input field in the
changedfunction (so that I can update the text) but like you said, whenever I set text, it will trigger an infinite loop. So would I have to unset the changed function, set the text and then re-set the changed function?This approach feels really messy, so would be open to a better approach.
Is the original suggestion out of the question?
@rivo commented on GitHub (Jun 24, 2021):
Can you make a suggestion for an actual configurable autocompleteselect function, i.e. what would such a function look like which would satisfy your requirements? I'm not quite sure what information you need to determine partial queries and how you would replace the selection in the input. (It sounded like you have an implementation already so it would be good to see how you solved this.)
@rivo commented on GitHub (Nov 9, 2021):
Any interest in this still?