IRenderable prompts, prompts with border styling and layout options - #2112
IRenderable prompts, prompts with border styling and layout options#2112MapelSiroup wants to merge 6 commits into
Conversation
|
Wow, this is impressive! Fair warning though: a PR this size is going to take me some time to review thoroughly. I'll get to it as soon as I can, but please bear with me. Side note: There are some conflicts that need to be resolved. |
|
Yes, i am slightly aware of the conflict, not fully sure whats conflicting but i think its just a function signature out of order (Extension.Input -> readline -> swap cancelation token with InitialInput or something like that, unsure about the TextPrompt.cs but maybe some recent changes i forgot to port over), juggling between like 2-3 branches make me loose track of what's what sometimes. I'll be around to fix it soon ish. This is also very experiemental, i tried my best but im sure people will find it clunky or suggest changes so no need to rush the implementation of it in the main branch just yet, but yeah i would invite you to look at it whenever you have time :] |
This Pull Request introduces IRenderable prompts, despite some prompts already having rendering features, TextPrompt now extends Live Renderable, and all Prompt types can now be inside panels, layouts, etc. All the while maintaining retro-compatibility with the old system.
New system works by setting up an initial prompt and then rendering it with
await promptname.ShowAsRenderableAsync()when it is needed, you can also pass a custom IRenderable wrapper when rendering it.Fixes #1281
AI Agents used:
Changes
The pullrequest does not change the old behavior of textprompt but introduces a way to render it using a render hook, LiveRenderable had to be updated in order to clear any overdraws or weird shapes with other renderables near it and so only 1 test expectation result had to be fixed due to an additional cursor input. All tests ran fine as of May 3rd.
Multiselection and SelectionPrompt had some existing features which made their implementation not too difficult.
The whole system works and is open to suggestions or code changes, but is, as described, a way to insert prompts as renderables. This is a cleaned up branch of the feature branch at MapelSiroup/spectre.console/irenderable-prompts
You can test functionality with the provided interactive tests located in my own fork: interactive tests examples
Usage Example:
This produces a prompt inside the layout, with the right styling as provided in the wrapper. then returns the list of strings when user confirms their selection.
Minimal example:
This produces a prompt with a minimal border using a panel, then returns the result when user confirms their selection.
Please upvote 👍 this pull request if you are interested in it.