[GH-ISSUE #1016] Allow completely disabling style tags in autocompleter #736

Closed
opened 2026-03-04 01:07:23 +03:00 by kerem · 2 comments
Owner

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!

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](https://github.com/gpanders/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!
kerem closed this issue 2026-03-04 01:07:23 +03:00
Author
Owner

@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.GetItemText to 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 an Unescape and possibly a Strip method 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.Escape re-written to just call it and possibly with Unescape or Strip functions added for simplicity)

<!-- gh-comment-id:2437856469 --> @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.GetItemText` to 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 an `Unescape` and possibly a `Strip` method 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.Escape` re-written to just call it and possibly with `Unescape` or `Strip` functions added for simplicity)
Author
Owner

@rivo commented on GitHub (Nov 3, 2024):

The latest commit adds the List.SetUseStyleTags and InputField.SetAutocompleteUseTags methods as well as an Unescape function.

<!-- gh-comment-id:2453394421 --> @rivo commented on GitHub (Nov 3, 2024): The latest commit adds the `List.SetUseStyleTags` and `InputField.SetAutocompleteUseTags` methods as well as an `Unescape` function.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#736
No description provided.