- /*
- * Finally, adjust the parameters showing screen size and cursor
- * position:
- */
- win->_maxx = ToCols;
- win->_maxy = ToLines;
-
- if (win->_regtop > win->_maxy)
- win->_regtop = win->_maxy;
- if (win->_regbottom > win->_maxy
- || win->_regbottom == size_y)
- win->_regbottom = win->_maxy;
-
- if (win->_curx > win->_maxx)
- win->_curx = win->_maxx;
- if (win->_cury > win->_maxy)
- win->_cury = win->_maxy;
+ if_USE_SCROLL_HINTS(new_lines[row].oldindex = row);
+ if (row <= size_y) {
+ new_lines[row].firstchar = win->_line[row].firstchar;
+ new_lines[row].lastchar = win->_line[row].lastchar;
+ }
+ if ((ToCols != size_x) || (row > size_y)) {
+ if (end >= begin) { /* growing */
+ if (new_lines[row].firstchar < begin)
+ new_lines[row].firstchar = (NCURSES_SIZE_T) begin;
+ } else { /* shrinking */
+ new_lines[row].firstchar = 0;
+ }
+ new_lines[row].lastchar = (NCURSES_SIZE_T) ToCols;
+ }
+ new_lines[row].text = s;
+ }
+
+ /*
+ * Dispose of unwanted memory.
+ */
+ if (!(win->_flags & _SUBWIN)) {
+ if (ToCols == size_x) {
+ for (row = ToLines + 1; row <= size_y; row++) {
+ free(win->_line[row].text);
+ }
+ } else {
+ for (row = 0; row <= size_y; row++) {
+ free(win->_line[row].text);
+ }
+ }
+ }
+
+ free(win->_line);
+ win->_line = new_lines;
+
+ /*
+ * Finally, adjust the parameters showing screen size and cursor
+ * position:
+ */
+ win->_maxx = (NCURSES_SIZE_T) ToCols;
+ win->_maxy = (NCURSES_SIZE_T) ToLines;
+
+ if (win->_regtop > win->_maxy)
+ win->_regtop = win->_maxy;
+ if (win->_regbottom > win->_maxy
+ || win->_regbottom == size_y)
+ win->_regbottom = win->_maxy;
+
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ if (win->_cury > win->_maxy)
+ win->_cury = win->_maxy;
+
+ /*
+ * Check for subwindows of this one, and readjust pointers to our text,
+ * if needed.
+ */
+ repair_subwindows(win);