aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/base/resizeterm.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
committerPeter Wemm <peter@FreeBSD.org>2002-05-21 05:30:25 +0000
commit39f2269fcb4873fd97d70af944ec49f4230fadea (patch)
treebd986d58f5a6e348466b5362637ba93e6cd5bf8c /contrib/ncurses/ncurses/base/resizeterm.c
parent7e6a63408cfb0b48f0e41f77ed82f5d0ca60bda5 (diff)
downloadsrc-39f2269fcb4873fd97d70af944ec49f4230fadea.tar.gz
src-39f2269fcb4873fd97d70af944ec49f4230fadea.zip
Import ncurses-5.2-20020518 onto the vendor branch.
Obtained from: ftp://dickey.his.com/ncurses/
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=97049
Diffstat (limited to 'contrib/ncurses/ncurses/base/resizeterm.c')
-rw-r--r--contrib/ncurses/ncurses/base/resizeterm.c67
1 files changed, 47 insertions, 20 deletions
diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c
index 303aa5e5be49..f454b20c8437 100644
--- a/contrib/ncurses/ncurses/base/resizeterm.c
+++ b/contrib/ncurses/ncurses/base/resizeterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -41,39 +41,34 @@
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.9 2000/12/10 02:43:28 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.13 2002/02/02 19:26:27 tom Exp $")
+
+NCURSES_EXPORT(bool)
+is_term_resized(int ToLines, int ToCols)
+{
+ return (ToLines != screen_lines
+ || ToCols != screen_columns);
+}
/*
- * This function reallocates NCURSES window structures. It is invoked in
- * response to a SIGWINCH interrupt. Other user-defined windows may also need
- * to be reallocated.
- *
- * Because this performs memory allocation, it should not (in general) be
- * invoked directly from the signal handler.
+ * This function reallocates NCURSES window structures, with no side-effects
+ * such as ungetch().
*/
NCURSES_EXPORT(int)
-resizeterm(int ToLines, int ToCols)
+resize_term(int ToLines, int ToCols)
{
int stolen = screen_lines - SP->_lines_avail;
int bottom = screen_lines + SP->_topstolen - stolen;
- T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
+ T((T_CALLED("resize_term(%d,%d) old(%d,%d)"),
ToLines, ToCols,
screen_lines, screen_columns));
- SP->_sig_winch = FALSE;
-
- if (ToLines != screen_lines
- || ToCols != screen_columns) {
+ if (is_term_resized(ToLines, ToCols)) {
WINDOWLIST *wp;
-#if USE_SIGWINCH
- ungetch(KEY_RESIZE); /* so application can know this */
- clearok(curscr, TRUE); /* screen contents are unknown */
-#endif
-
for (wp = _nc_windows; wp != 0; wp = wp->next) {
- WINDOW *win = wp->win;
+ WINDOW *win = &(wp->win);
int myLines = win->_maxy + 1;
int myCols = win->_maxx + 1;
@@ -122,3 +117,35 @@ resizeterm(int ToLines, int ToCols)
returnCode(OK);
}
+
+/*
+ * This function reallocates NCURSES window structures. It is invoked in
+ * response to a SIGWINCH interrupt. Other user-defined windows may also need
+ * to be reallocated.
+ *
+ * Because this performs memory allocation, it should not (in general) be
+ * invoked directly from the signal handler.
+ */
+NCURSES_EXPORT(int)
+resizeterm(int ToLines, int ToCols)
+{
+ int result = OK;
+
+ SP->_sig_winch = FALSE;
+
+ T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
+ ToLines, ToCols,
+ screen_lines, screen_columns));
+
+ if (is_term_resized(ToLines, ToCols)) {
+
+#if USE_SIGWINCH
+ ungetch(KEY_RESIZE); /* so application can know this */
+ clearok(curscr, TRUE); /* screen contents are unknown */
+#endif
+
+ result = resize_term(ToLines, ToCols);
+ }
+
+ returnCode(result);
+}