]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/resizeterm.c
ncurses 5.4
[ncurses.git] / ncurses / base / resizeterm.c
index 9cc8081b9115ef48de76a567706d89feb6491978..e5b852c70d3a6c2b634b5ffafbee406b9ca269dc 100644 (file)
 #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.15 2002/12/28 01:21:34 tom Exp $")
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
+static int current_lines;
+static int current_cols;
+
 NCURSES_EXPORT(bool)
 is_term_resized(int ToLines, int ToCols)
 {
@@ -99,7 +102,7 @@ static int
 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;
 
@@ -109,13 +112,13 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
        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;
     }
 
@@ -125,12 +128,12 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen)
     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);
@@ -216,15 +219,19 @@ resize_term(int ToLines, int ToCols)
        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;
 
        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 ||