mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #1016] Allow completely disabling style tags in autocompleter #736
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#736
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 @gpanders on GitHub (Aug 9, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/1016
Hello, I'm the author of ijq, which uses tview.
jq filters often contain text of the form
[0]to select a value from a JSON array. Whenever a user writes a new jq filter, ijq saves their filter to a history file and later will populate an autocomplete popup using those history entries. This means that the values in the autocomplete popup contain these[0]strings (and others like it).I am calling
Escape()on all items before adding them to the list of autocomplete values, but this does not always work as expected: for instance,Escape()transforms[0]into[0[]. In the autocomplete popup this correctly appears to the user as[0]but when the user selects the item, the text[0[]is inserted into the text entry (open issue: https://todo.sr.ht/~gpanders/ijq/11).For my use case, I do not want style tags in this text input at all or in the autocomplete window. I would like the ability to completely disable style tags in the autocomplete popup and in the text input so that all strings containing
[]are interpreted literally (with no escaping or stripping needed).Is this possible to do now, and if not is this something you'd be willing to support?
Thanks very much!
@SamWhited commented on GitHub (Oct 25, 2024):
I came to file a similar issue where in a list I always get style tags back out when calling
list.GetItemTextto get the selected item, but I obviously don't want to display or send the style tags in other non-tview parts of the application. As far as I can tell there is no way to remove them or unescape the rest of the text. Having anUnescapeand possibly aStripmethod would be ideal.EDIT: if you'd be willing to reconsider the text transformer escaper in #339 I have expanded it to also include unescaping and stripping out style and region tags. If you'd like it I'm happy to send a PR; it could potentially be a sub-package to avoid cluttering the UI (with
tview.Escapere-written to just call it and possibly withUnescapeorStripfunctions added for simplicity)@rivo commented on GitHub (Nov 3, 2024):
The latest commit adds the
List.SetUseStyleTagsandInputField.SetAutocompleteUseTagsmethods as well as anUnescapefunction.