Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable color for Input autocomplete #560

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

issadarkthing
Copy link
Contributor

It would be convenient if we can configure the color of the autocomplete for InputField instead of using global Styles.

@gpanders
Copy link

gpanders commented Jun 3, 2021

I'd like to add my support for this feature. The inability to style the autocomplete list separately from the rest of the primitives is fairly limiting, particularly when trying to support both light and dark terminal backgrounds.

@gpanders
Copy link

@issadarkthing I actually don't think this will work. In the Autocomplete function, the list is destroyed and re-created repeatedly:

tview/inputfield.go

Lines 232 to 248 in d4fb034

entries := i.autocomplete(i.text)
if len(entries) == 0 {
// No entries, no list.
i.autocompleteList = nil
return i
}
// Make a list if we have none.
if i.autocompleteList == nil {
i.autocompleteList = NewList()
i.autocompleteList.ShowSecondaryText(false).
SetMainTextColor(Styles.PrimitiveBackgroundColor).
SetSelectedTextColor(Styles.PrimitiveBackgroundColor).
SetSelectedBackgroundColor(Styles.PrimaryTextColor).
SetHighlightFullLine(true).
SetBackgroundColor(Styles.MoreContrastBackgroundColor)
}

Instead, you either need to 1) add a new hook that can be called for the autocomplete list to be configured after it's created or 2) add new properties to InputField (autocompleteTextColor, autocompleteBackgroundColor, etc.) and use those to set the autocomplete list styles in lines 243-247.

I have a PR ready to go that does the latter: gpanders@c5d98ee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants