I'm writing a little app with ncurses, and I have a really strange problem. When I resize the terminal window, I don't get KEY_RESIZE but ERR. Also, when pretending the ERR is actually a KEY_RESIZE, I can't make the screen redraw.
Anyone have an idea what's up?
By the way it's called "faith" because I'm writing a replacement for the "qed" editor 
If for some crazy reason you want to reuse or redistribute (parts of) this program, please use a GPL license, version 2 or newer.
__________________
CAN I HAS FIXD CAPSLOK KEE PLZ?













If someone using something else than archlinux wants to build and test this for me:
gcc -c faith.c
gcc -o faith -lncurses faith.o
./faith
When you hit some random keys, it should display their (octal) keycodes. Escape will make it quit. But what happens when you resize the xterm? And what if you replace
if (inp == KEY_RESIZE || inp == ERR) faith_resize_screen();
by
if (inp == KEY_RESIZE) faith_resize_screen();
and then recompile?
CAN I HAS FIXD CAPSLOK KEE PLZ?
Login or register to post comments 0 points
#include <ncurses.h> int main(void) { WINDOW * stdscr = initscr(); int width, height; while (1) { getmaxyx(stdscr, height, width); mvprintw(0,0,"%d %d %o\n", height, width, getch()); refresh(); } return 0; }Even that simple program gets ERR (37777777777) when resizing, and the height and width don't change. Is there a problem with my ncurses, or am I doing something wrong?
CAN I HAS FIXD CAPSLOK KEE PLZ?
Login or register to post comments 0 points
I found out the ncurses in archlinux is compiled without --enable-sigwinch , but that's not the problem (I rebuilt ncurses with that configure option, and the problem is still there).
Writing my own SIGWINCH handler could be a solution, though.
CAN I HAS FIXD CAPSLOK KEE PLZ?
Login or register to post comments 0 points
I've just compiled the program on Gentoo. The output of gcc -v is:
As for your questions:
with "if (inp == KEY_RESIZE || inp == ERR) faith_resize_screen();" I get the octal codes for the keys, but when I resize the xterm the ncurses window doesn't resize.
with "if (inp == KEY_RESIZE) faith_resize_screen();" I get the octal codes for the keys, and ERR when I resize the xterm, the ncurses window doesn't seem to resize.
dylunio
Yn falch o ddefnyddio Linux a FLOSS!
Login or register to post comments 0 points
Then obviously I'm doing something (or forgetting to do it?) that makes the screen not resizable. I need to find an example somewhere...
CAN I HAS FIXD CAPSLOK KEE PLZ?
Login or register to post comments 0 points
from the manual page of resizeterm (which appears to be the default SIGWINCH handler in ncurses:
If the environment variables LINES or COLUMNS are set, this overrides the library's use of the window size obtained from the operating system. Thus, even if a SIGWINCH is received, no screen size change may be recorded. In that case, no KEY_RESIZE is queued for the next call to getch; an ERR will be returned instead.
And guess what?
So the solution is to do almost the same for ERR as for KEY_RESIZE: fetch the screen size, and redraw the screen. The only difference is that it should be fetched from these environment variables instead of getmaxyx(). I guess I'll write a function faith_getmaxyx() to replace all the calls to getmaxyx().
By the way, I removed the original program from the attachment, because I don't want search engines to pick up my poor code
.
CAN I HAS FIXD CAPSLOK KEE PLZ?
Login or register to post comments 0 points