$Log$
+ Revision 590.153 2002/03/14 04:24:20 nbryant
+ support window resizing in curses mode
+
Revision 590.152 2002/03/13 04:11:11 nbryant
fix up minor gotcha introduced by fgets change
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
unsigned short ypixels; /* pixels */
} xwinsz;
- if (scr_set_windowsize())
- return;
-
if (have_xterm) { /* dynamically size screen if on an xterm */
if (ioctl(0, TIOCGWINSZ, &xwinsz) == 0) {
if (xwinsz.height)
- screenheight = (int) xwinsz.height;
+ screenheight = is_curses_enabled() ? (int)xwinsz.height - 1 : (int) xwinsz.height;
if (xwinsz.width)
screenwidth = (int) xwinsz.width;
}
sttybbs(SB_NO_INTR); /* Install the new ones */
signal(SIGHUP, dropcarr); /* Cleanup gracefully if carrier is dropped */
signal(SIGTERM, dropcarr); /* Cleanup gracefully if terminated */
- signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
+ signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
+#ifdef SIGWINCH
+ signal(SIGWINCH, scr_winch); /* Window resize signal */
+#endif
#ifdef HAVE_OPENSSL
arg_encrypt = RC_DEFAULT;
void formout(char *name);
void sighandler(int which_sig);
void do_system_configuration(void);
+extern int secure;
goto RCL;
}
if (FD_ISSET(0, &rfds)) {
- ch = scr_getc();
+ ch = scr_getc(SCR_BLOCK);
if ((ch == 10) || (ch == 13)) {
send_complete_line = 1;
} else if ((ch == 8) || (ch == 127)) {
* necessary and then waits again.
*/
do {
+ scr_set_windowsize();
do_keepalive();
+ scr_set_windowsize();
FD_ZERO(&rfds);
FD_SET(0, &rfds);
/* At this point, there's input, so fetch it.
* (There's a hole in the bucket...)
*/
- a = scr_getc();
+ a = scr_getc(SCR_NOBLOCK);
if (a == 127)
a = 8;
if (a > 126)
if (((a != 4) && (a != 10) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
&& ((a < 32) || (a > 126)))
a = 0;
+
+#if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H)
+ if (a == ERR)
+ a = 0;
+#endif
+
} while (a == 0);
return (a);
}
*/
#include "sysdep.h"
-#ifdef HAVE_NCURSES_H
-#include <ncurses.h>
-#elif defined(HAVE_CURSES_H)
-#include <curses.h>
-#endif
#include <stdio.h>
+#include <signal.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include "citadel.h"
#include "commands.h"
#include "screen.h"
+#include "citadel_decls.h"
#ifdef HAVE_CURSES_H
static SCREEN *myscreen = NULL;
}
-int scr_getc(void)
+int scr_getc(int delay)
{
char buf;
+
#ifdef HAVE_CURSES_H
- if (mainwindow)
+ if (mainwindow) {
+ wtimeout(mainwindow, delay);
return wgetch(mainwindow);
+ }
#endif
+
buf = '\0';
read (0, &buf, 1);
return buf;
}
+/* the following is unused and looks broken, but there may
+ be some input problems still lurking in curses mode, so
+ i'll leave it blocked out for now for informational
+ purposes. */
+#if 0
int scr_blockread(void)
{
int a = 0;
#endif
return a;
}
+#endif /* 0 */
/*
* scr_putc() outputs a single character
fflush(stdout);
}
+static volatile int caught_sigwinch = 0;
-int scr_set_windowsize(void)
+/*
+ * this is not supposed to be called from a signal handler.
+ */
+int scr_set_windowsize()
{
#ifdef HAVE_CURSES_H
- int y, x;
-
- if (mainwindow) {
- getmaxyx(mainwindow, y, x);
- screenheight = y;
- screenwidth = x;
+ if (mainwindow && caught_sigwinch) {
+ caught_sigwinch = 0;
+ resizeterm(screenheight + 1, screenwidth);
+ wresize(mainwindow, screenheight, screenwidth);
+ wresize(statuswindow, 1, screenwidth);
+ mvwin(statuswindow, screenheight, 0);
+ status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
+ room_name, secure, -1);
+ wnoutrefresh(mainwindow);
+ wnoutrefresh(statuswindow);
+ doupdate();
return 1;
}
#endif /* HAVE_CURSES_H */
return 0;
}
-
/*
* scr_winch() handles window size changes from SIGWINCH
* resizes all our windows for us
*/
-RETSIGTYPE scr_winch(void)
+RETSIGTYPE scr_winch(int signum)
{
-#ifdef HAVE_CURSES_H
- /* FIXME: not implemented */
-#endif
+ /* 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);
}
/* $Id$ */
+/* client code may need the ERR define: */
+
+#ifdef HAVE_NCURSES_H
+#include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
+#include <curses.h>
+#endif
+
void status_line(const char *humannode, const char *bbs_city,
const char *room_name, int secure, int newmailcount);
void screen_new(void);
int err_printf(char *fmt, ...);
int sln_printf(char *fmt, ...);
int sln_printf_if(char *fmt, ...);
-int scr_getc(void);
+
+#define SCR_NOBLOCK 0
+#define SCR_BLOCK -1
+int scr_getc(int delay);
+
int scr_putc(int c);
int sln_putc(int c);
int scr_color(int colornum);
void windows_delete(void);
int scr_blockread(void);
int is_curses_enabled(void);
+RETSIGTYPE scr_winch(int signum);