Hi,
As a project that I've set myself, I'm working on a simple pager, such as "less". Of course it would be best practice to build this pager on top of ncurses. It's my first time working with ncurses, though I find the API quite easy to understand and I've familiarised myself with it. I'm facing one specific problem for which I'm not able to find a solution:
A pager should be able to take input both from filename arguments:
$ pager foo.txt bar.txt ...
and from standard input:
$ <command> | pager
But a pager's key commands, such as Space for one screenful forward and the b key for one screenful backward, also have to be intercepted, and if the pager's input comes from stdin then it can't intercept these keys by reading stdin.
My reference is an old Unix implementation of a pager, and the idea used there to intercept these keys is to read from the terminal device directly (and not stdin).
As I understand, getch() is the standard way of getting character input in ncurses. Is there any way to make getch() read from the terminal device and not stdin?
I would be grateful for any help!
Thanks,
Saniya