AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 350 forks source link

Highlight items in Multiselect #424

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi, It can be hard to match a long string with the associated checkbox in the multi-select function, especially when just the end of the string differs. And it's more difficult when there is more than 7 items (default). It could be a nice feature to highlight or apply a different color on the current line, but I didn't find a way to do this in the README.

Current behavior with default (7 items):

Sélection_001

This could be nice :

Sélection_002

Thanks !

mislav commented 2 years ago

Hi, you can accomplish this by overriding this template string in Survey with your own: https://github.com/AlecAivazis/survey/blob/c2be27f4a7faa58a920ea402d0984647a5b8deb2/multiselect.go#L62-L79

So in your app, you can do something like:

import github.com/AlecAivazis/survey/v2

func init() {
  survey.MultiSelectQuestionTemplate = `...`
}