/*
* Screen output handling
*
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2012 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <ctype.h>
#include <sys/types.h>
+#include <sys/ioctl.h>
#include "sysdep.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
#include "commands.h"
#include "screen.h"
-int enable_status_line = 0; /* FIXME the status line works, but not on Mac. Make this configurable. */
+int enable_status_line = 0;
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
*/
/* 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);