Added support for formatted text in the select message
#458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the problem that this PR addresses?
Currently, the
messageparameter ofquestionary.select()only accepts plain strings and does not support formatted text (e.g., ANSI or Rich styles).This makes it impossible to style the prompt title, even though option titles (
choices) already support formatting viaFormattedText.Closes #449
Related to #107
How did you solve it?
I extended the logic in
select()so that themessageparameter now acceptsFormattedText(including objects with__pt_formatted_text__or lists of style/text tuples).If a formatted message is provided, it is rendered with all styles and colors preserved, just like for option titles.
This was tested with both manual ANSI codes and Rich → PromptToolkit conversions to confirm correct rendering.
Checklist