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

Make AnsiConsoleSettings accept a IAnsiInput #1352

Open
halgari opened this issue Nov 2, 2023 · 0 comments
Open

Make AnsiConsoleSettings accept a IAnsiInput #1352

halgari opened this issue Nov 2, 2023 · 0 comments

Comments

@halgari
Copy link

halgari commented Nov 2, 2023

Is your feature request related to a problem? Please describe.
Right now the only way to implement a custom input for a IAnsiConsole is to re-implement all of IAnsiConsole. Instead I would like to be able to pass in a IAnsiInput into AnsiConsole.Create and use the rest of the library as-is.

I whipped up a PR for this: halgari/spectre.console@main...halgari:spectre.console:configurable-input but the PR template said to make an issue first, so here it is.

Describe the solution you'd like
Instead of always using DefaultInput(profile), look for an existing IAnsiInput in the AnsiConsoleSettings and use that, this is the same behavior as is already done with IAnsiOutput

Describe alternatives you've considered
I went down the path of re-implementing IAnsiConsole but that's a lot of pain, as so much behavior already exists in the internal sealed classes in the library. I'd much rather just provide a custom I/O to the console.

We could also extend DefaultConsole but that doesn't seem to be the right place for this change.

Additional context
To be clear, if you use AnsiConsole.Create it always calls the AnsiConsoleFactory which creates a AnsiConsoleFacade that always uses a DefaultInput which always calls System.Console.*. There's no extension point in this whole chain.


Please upvote 👍 this issue if you are interested in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo 🕑
Development

No branches or pull requests

1 participant