This may be more of a question about terminals or stdin/stdout. Not sure if this is the best place to ask this, but here goes:
I'm writing a command line application that I need a mini pager for quickly displaying a long list of data (much like more
or less
, with simple keyboard navigation) without cluttering up the terminal window once the app is done. I used termion::screen::AlternateScreen
to accomplish this, along with a slightly modified version of redox-os/libpager.
It works great, except for when I need my application to read piped data from stdin. For the pager to capture keystrokes for page navigation, we need to call stdout.into_raw_mode()?
. When there is data in stdin (from a pipe) this function returns an error:
Error: Os { code: 25, kind: Other, message: "Inappropriate ioctl for device" }
I can capture the piped data just fine, it's just that I think stdin is blocking me from entering RawMode for capturing keystrokes. I've tried all combinations of flushing stdin/stdout, starting new instances of stdin/stdout as well as new AlternateScreen
s. I get this error on the redox pager implementation of less as well. Is there a better way to accomplish this, or am I just missing something?