[GH-ISSUE #472] Improve support for using colors in autocomplete input fields? #342

Closed
opened 2026-03-04 01:04:09 +03:00 by kerem · 4 comments
Owner

Originally created by @khughitt on GitHub (Jul 18, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/472

One more quick idea --

Would it be possible to modify autocomplete to make it easier to include choices which are colored differently?

Currently, autocomplete display text in different colors just fine, however, to actually match one of the words, you have to type the color expression in the input field.

For example, for the string "[#ff0000] word" to match, you have to start with the "[".

It would be nice if there was an option to indicate that colors should still be displayed in the autocomplete options, but otherwise stripped from the strings that are being matched against.

Another possible approach would be to allow Maps to be used, with each entry corresponding to a (label, text) pair.

Originally created by @khughitt on GitHub (Jul 18, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/472 One more quick idea -- Would it be possible to modify autocomplete to make it easier to include choices which are colored differently? Currently, autocomplete display text in different colors just fine, however, to actually match one of the words, you have to type the color expression in the input field. For example, for the string "[#ff0000] word" to match, you have to start with the "[". It would be nice if there was an option to indicate that colors should still be _displayed_ in the autocomplete options, but otherwise stripped from the strings that are being matched against. Another possible approach would be to allow Maps to be used, with each entry corresponding to a `(label, text)` pair.
kerem closed this issue 2026-03-04 01:04:09 +03:00
Author
Owner

@khughitt commented on GitHub (Jul 18, 2020):

Nevermind!

Just realized this was my fault for using strings.HasPrefix() in the inputField.SetAutocompleteFunc() function.

Switching to a different approach to matching fixed the issue.

Please ignore :)

<!-- gh-comment-id:660416675 --> @khughitt commented on GitHub (Jul 18, 2020): Nevermind! Just realized this was my fault for using `strings.HasPrefix()` in the `inputField.SetAutocompleteFunc()` function. Switching to a different approach to matching fixed the issue. Please ignore :)
Author
Owner

@khughitt commented on GitHub (Jul 18, 2020):

Reopening for different but related issue (still having to do with color + autocomplete support):

when navigating through autocomplete choices, colors and formatting are rendered as expected, however, in the text that is shown in the inputField, the unformatted text (e.g. [#ff0000][::b]match...) is shown instead of the rendered text.

<!-- gh-comment-id:660480499 --> @khughitt commented on GitHub (Jul 18, 2020): Reopening for different but related issue (still having to do with color + autocomplete support): when navigating through autocomplete choices, colors and formatting are rendered as expected, however, in the text that is shown in the inputField, the unformatted text (e.g. `[#ff0000][::b]match...`) is shown instead of the rendered text.
Author
Owner

@rivo commented on GitHub (Sep 15, 2020):

That's actually a bug. Colour tags should not appear in the input field when you make an autocomplete selection. I fixed this in the latest commit.

<!-- gh-comment-id:692662386 --> @rivo commented on GitHub (Sep 15, 2020): That's actually a bug. Colour tags should not appear in the input field when you make an autocomplete selection. I fixed this in the latest commit.
Author
Owner

@khughitt commented on GitHub (Sep 15, 2020):

Thanks for the fix! It's much appreciated.

<!-- gh-comment-id:692884699 --> @khughitt commented on GitHub (Sep 15, 2020): Thanks for the fix! It's much appreciated.
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#342
No description provided.