/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2004 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 *
#include <curses.priv.h>
#include <term.h>
-MODULE_ID("$Id: resizeterm.c,v 1.14 2002/07/13 21:32:57 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.17 2004/07/31 20:24:38 tom Exp $")
#define stolen_lines (screen_lines - SP->_lines_avail)
+static int current_lines;
+static int current_cols;
+
+#ifdef TRACE
+static void
+show_window_sizes(const char *name)
+{
+ WINDOWLIST *wp;
+
+ _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
+ screen_lines, screen_columns);
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ _tracef(" window %p is %2d x %2d at %2d,%2d",
+ &(wp->win),
+ wp->win._maxy + 1,
+ wp->win._maxx + 1,
+ wp->win._begy,
+ wp->win._begx);
+ }
+}
+#endif
+
NCURSES_EXPORT(bool)
is_term_resized(int ToLines, int ToCols)
{
- return (ToLines != screen_lines
- || ToCols != screen_columns);
+ T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
+ returnCode(ToLines > 0
+ && ToCols > 0
+ && (ToLines != screen_lines
+ || ToCols != screen_columns));
}
/*
adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
{
int result;
- int bottom = screen_lines + SP->_topstolen - stolen;
+ int bottom = current_lines + SP->_topstolen - stolen;
int myLines = win->_maxy + 1;
int myCols = win->_maxx + 1;
getbegy(win), getbegx(win)));
if (win->_begy >= bottom) {
- win->_begy += (ToLines - screen_lines);
+ win->_begy += (ToLines - current_lines);
} else {
- if (myLines == screen_lines - stolen
- && ToLines != screen_lines)
+ if (myLines == current_lines - stolen
+ && ToLines != current_lines)
myLines = ToLines - stolen;
- else if (myLines == screen_lines
- && ToLines != screen_lines)
+ else if (myLines == current_lines
+ && ToLines != current_lines)
myLines = ToLines;
}
if (myCols > ToCols)
myCols = ToCols;
- if (myLines == screen_lines
- && ToLines != screen_lines)
- myCols = ToLines;
+ if (myLines == current_lines
+ && ToLines != current_lines)
+ myLines = ToLines;
- if (myCols == screen_columns
- && ToCols != screen_columns)
+ if (myCols == current_cols
+ && ToCols != current_cols)
myCols = ToCols;
result = wresize(win, myLines, myCols);
if (!(win->_flags & _ISPAD)) {
if (child_depth(win) == depth) {
+ found = TRUE;
if (adjust_window(win, ToLines, ToCols, stolen) != OK)
returnCode(ERR);
}
if (!(win->_flags & _ISPAD)) {
if (parent_depth(win) == depth) {
+ found = TRUE;
if (adjust_window(win, ToLines, ToCols, stolen) != OK)
returnCode(ERR);
}
screen_lines, screen_columns));
if (is_term_resized(ToLines, ToCols)) {
- int myLines = screen_lines;
- int myCols = screen_columns;
+ int myLines = current_lines = screen_lines;
+ int myCols = current_cols = screen_columns;
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ show_window_sizes("before");
+#endif
if (ToLines > screen_lines) {
increase_size(myLines = ToLines, myCols, was_stolen);
+ current_lines = myLines;
+ current_cols = myCols;
}
if (ToCols > screen_columns) {
increase_size(myLines, myCols = ToCols, was_stolen);
+ current_lines = myLines;
+ current_cols = myCols;
}
if (ToLines < myLines ||
if (SP->newhash) {
FreeAndNull(SP->newhash);
}
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE) {
+ LINES = ToLines - was_stolen;
+ COLS = ToCols;
+ show_window_sizes("after");
+ }
+#endif
}
/*