Hi
I am author of pspg
https://github.com/okbob/pspg, and I found strange behaviour of ncurses input processing when there is a specific situation. a) pspg is a pager, so I need to process an reading from two streams stdin and tty. For this purpose I use timeout(0) and my own poll. Almost every time I have an active keypad, but not always - for readline is necessary raw stream. So I have an active keypad on stdscr and disabled keypad on my window that is used for editing.
Please, see file test-ncurses-bug
When I press key down as first event, I get result
pressed "^[" (27)
pressed "[" (91)
pressed "B" (66)
instead
pressed "KEY_DOWN" (258)
First event is not processed correctly.
Workaround is simple (but looks messy, and it was crazy to find this workaround) - just run again "workpad" function on stdscr
It is interesting, so without a mentioned workaround, the behaviour is fixed by self for next key's events.
Regards
Pavel