X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Ftextclient%2Fscreen.c;h=c79d693fd8e1599fba5e534fd5b816a83a96640e;hb=fa5cd0e6595d211591cc8eebfa81874b03b6162d;hp=67cd2f506e56890c4637ff79552f6dff544464ff;hpb=f8d73af7c1bd70257c586761a88ea9729c99789b;p=citadel.git diff --git a/citadel/textclient/screen.c b/citadel/textclient/screen.c index 67cd2f506..c79d693fd 100644 --- a/citadel/textclient/screen.c +++ b/citadel/textclient/screen.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "sysdep.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" @@ -44,17 +45,39 @@ char status_line[1024] = " "; /* the default paginator prompt will be replaced by the server's prompt when we learn it */ char *moreprompt = " -- more -- "; -extern int screenheight; -extern int screenwidth; +int screenheight = 24; +int screenwidth = 80; int lines_printed = 0; int cols_printed = 0; extern int rc_ansi_color; extern int rc_prompt_control; -extern void check_screen_dims(void); - void do_keepalive(void); +/* + * Attempt to discover the screen dimensions. + * WARNING: This is sometimes called from a signal handler. + */ +void check_screen_dims(void) +{ +#ifdef TIOCGWINSZ + struct { + unsigned short height; /* rows */ + unsigned short width; /* columns */ + unsigned short xpixels; + unsigned short ypixels; /* pixels */ + } xwinsz; + + if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) { + if (xwinsz.height) + screenheight = (int) xwinsz.height; + if (xwinsz.width) + screenwidth = (int) xwinsz.width; + } +#endif +} + + /* * Initialize the screen */ @@ -222,7 +245,6 @@ RETSIGTYPE scr_winch(int signum) /* if we receive this signal, we must be running * in a terminal that supports resizing. */ - have_xterm = 1; caught_sigwinch = 1; check_screen_dims(); signal(SIGWINCH, scr_winch);