crossterm icon indicating copy to clipboard operation
crossterm copied to clipboard

A way to change the input stream for event::read and event::poll

Open dmaahs2017 opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. I have an issue where my program uses a piped stdin, I want to manually open tty as a file and give that to crossterm for event handling though it does not seem possible at the moment. I also tried overriding stdin with the stdio_override crate which also did not work.

To clarify my use case - this was so that I could perform automated integration testing of my event handling implementation

Describe the solution you'd like To be able to specify an input source for event::read and event::poll. Or a global override for the source of events.

Not sure if this is possible. Haven't had the chance to dive deep into the crossterm code yet.

dmaahs2017 avatar Nov 11 '22 21:11 dmaahs2017

Piped stdin is not supported currently https://github.com/crossterm-rs/crossterm/issues/396 Pr that can fix this https://github.com/crossterm-rs/crossterm/pull/711

sigmaSd avatar Nov 12 '22 05:11 sigmaSd

Actually it works except on mac because it does seem to work on helix with linux (which uses crossterm)

sigmaSd avatar Nov 12 '22 06:11 sigmaSd

Hey @dmaahs2017, were you able to setup the testing framework using custom input source for stdin? I'm working on the same and any insights would be appreciated. Thanks.

Narayanbhat166 avatar Feb 27 '24 18:02 Narayanbhat166

Hey @dmaahs2017, were you able to setup the testing framework using custom input source for stdin? I'm working on the same and any insights would be appreciated. Thanks.

IIRC I ended up giving up on this idea

dmaahs2017 avatar Feb 27 '24 19:02 dmaahs2017