+2014-03-09 Christopher Faylor <me.cygwin2014@cgf.cx>
+
+ * fhandler_console.cc (fhandler_console::save_restore): Save only until
+ last written row and, because of this, don't bother trying to restore
+ the screen buffer size. Set cursor position after refilling buffer.
+ (fhandler_console::write): Use absolute paths when saving/restoring
+ cursor position or suffer odd problems after a saved screen is
+ restored.
+
2014-03-09 Christopher Faylor <me.cygwin2014@cgf.cx>
* fhandler.h (fhandler_console::dwBufferSize): Delete.
if (c == 'h') /* save */
{
fillin (h);
- save_bufsize = b.dwSize; /* Assume starting from 0/0 */
+ save_bufsize.Y = dwEnd.Y + 1; /* Assume starting from 0/0 */
+ save_bufsize.X = b.dwSize.X;
if (save_buf)
cfree (save_buf);
save_cursor = b.dwCursorPosition; /* Remember where we were. */
SMALL_RECT now = {}; /* Read the whole buffer */
- now.Bottom = b.dwSize.Y - 1;
- now.Right = b.dwSize.X - 1;
+ now.Bottom = save_bufsize.Y - 1;
+ now.Right = save_bufsize.X - 1;
if (!ReadConsoleOutputWrapper (h, save_buf, save_bufsize, now))
debug_printf ("ReadConsoleOutputWrapper(h, ...) failed during save, %E");
}
else if (save_buf)
{
- /* Restore original buffer size, just in case. */
- if (!SetConsoleScreenBufferSize (h, save_bufsize))
- debug_printf ("SetConsoleScreenBufferSize(h, ...) failed during restore, %E", h);
-
- /* Position where we were previously */
- if (!SetConsoleCursorPosition (h, save_cursor))
- debug_printf ("SetConsoleCursorInfo(%p, ...) failed during restore, %E", h);
-
- /* Get back correct version of buffer information */
- dwEnd.X = dwEnd.Y = 0;
- fillin (h);
COORD cob = {};
SMALL_RECT now = {};
- now.Bottom = b.dwSize.Y - 1;
- now.Right = b.dwSize.X - 1;
+ now.Bottom = save_bufsize.Y - 1;
+ now.Right = save_bufsize.X - 1;
/* Restore whole buffer */
BOOL res = WriteConsoleOutputW (h, save_buf, save_bufsize, cob, &now);
if (!res)
cfree (save_buf);
save_buf = NULL;
+
+ /* Position where we were previously */
+ if (!SetConsoleCursorPosition (h, save_cursor))
+ debug_printf ("SetConsoleCursorInfo(%p, ...) failed during restore, %E", h);
+ /* Get back correct version of buffer information */
+ dwEnd.X = dwEnd.Y = 0;
+ fillin (h);
}
}
}
else if (*src == '8') /* DECRC Restore cursor position */
{
- cursor_set (true, con.savex, con.savey);
+ cursor_set (false, con.savex, con.savey);
con.state = normal;
}
else if (*src == '7') /* DECSC Save cursor position */
{
cursor_get (&con.savex, &con.savey);
- con.savey -= con.b.srWindow.Top;
con.state = normal;
}
else if (*src == 'R') /* ? */