Added support for formatted text in the select message#458
Open
kotazzz wants to merge 1 commit intotmbo:masterfrom
Open
Added support for formatted text in the select message#458kotazzz wants to merge 1 commit intotmbo:masterfrom
select message#458kotazzz wants to merge 1 commit intotmbo:masterfrom
Conversation
Author
|
That is really needed as I tried to add OSB 8 ANSI hyperlinks in the options and they fail to render, likely because the code is escaping the ANSI escapes I added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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