The overall question is simple:
How to gracefully resize a window in a multi-thread ncurses program?
refreshin user's own
Leverage ncurses builtin
KEY_RESIZEand handle it.
I have tested on my ncurses implementation to make sure I can receive
KEY_RESIZE. But I still don't understand how signal handler works with multi-thread ncurses program:
If I'm using the builtin
SIGWINCHhandler, which thread will be running the signal handler? Does this matter? Do I have control over this?
SIGWINCHhandler generates a
KEY_RESIZE. But what if there are other keys pressed that haven't been delivered? Is
KEY_RESIZEguaranteed to be the key returned by the next call of
KEY_RESIZElooks less painful than writing my own
SIGWINCHhandler. But how can I read this key as soon as it is delivered to make the UI responsive? Can I select or poll stdin to detect its delivery? Is it put on an internal queue that only has something to do with
getchbut nothing to do with stdin?
If I'm writing my own
SIGWINCHhandler, do I have any guarantee about ncurses context so that my signal handler code won't break ncurses (by calling functions that cannot be called at the time the signal is delivered, etc.)?
Is ncurses itself single-threaded or multi-threaded? If I block the
SIGWINCHsignal on all my threads other than the main thread, am I guaranteed to receive the
SIGWINCHsignal on the main thread (but not an internal thread created by the ncurses library)?