]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler_console.cc (fhandler_console::save_restore): Save only until last
authorChristopher Faylor <me@cgf.cx>
Mon, 10 Mar 2014 03:15:39 +0000 (03:15 +0000)
committerChristopher Faylor <me@cgf.cx>
Mon, 10 Mar 2014 03:15:39 +0000 (03:15 +0000)
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.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_console.cc

index 173caf081c9dd7b11d540d8c3cab7a3dc77f52f4..f96e0e1a68c70bc11773c3e2220e3eac2130d00a 100644 (file)
@@ -1,3 +1,12 @@
+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.
index 10cbd9763bfa02d38e2fb173d02fee593d198f58..53418edf12e4e317a2e1cef8ae19c69b30ca8a43 100644 (file)
@@ -1457,7 +1457,8 @@ dev_console::save_restore (HANDLE h, char c)
   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);
@@ -1467,8 +1468,8 @@ dev_console::save_restore (HANDLE h, char c)
       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");
 
@@ -1483,21 +1484,10 @@ dev_console::save_restore (HANDLE h, char c)
     }
   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)
@@ -1505,6 +1495,13 @@ dev_console::save_restore (HANDLE h, char c)
 
       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);
     }
 }
 
@@ -2218,13 +2215,12 @@ fhandler_console::write (const void *vsrc, size_t len)
            }
          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')         /* ? */
This page took 0.039011 seconds and 5 git commands to generate.