diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5217a8510..383c252fd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2014-04-26 Christopher Faylor + + * DevNotes: Add entry cgf-000026. + * fhandler.h (fhandler_console::save_top): Save top of screen + coordinates. + * fhandler_console.cc (dev::save_restore): Record top of screen + coordinates. Clear entire buffer when restoring saved buffer and try + to position the cursor on the save relative place on the screen. + 2014-04-25 Corinna Vinschen * syscalls.cc (NT_TRANSACTIONAL_ERROR): Cover all status codes up to diff --git a/winsup/cygwin/DevNotes b/winsup/cygwin/DevNotes index 0f480954a..5d31ed72e 100644 --- a/winsup/cygwin/DevNotes +++ b/winsup/cygwin/DevNotes @@ -1,3 +1,12 @@ +2014-04-26 cgf-000026 + +Forgot to clear to the end of screen when restoring a screen buffer. +That worked, for some reason, with Take Command but not with normal +consoles. I don't remember why I didn't resize the screen like a Linux +X terminal emulator but that might have made things work a little +better. Right now, there is a scroll bar for apps like less or vi and +that doesn't feel right. + 2014-03-29 cgf-000025 Reorganized _cygtls::signal_debugger to avoid sending anything to the diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index c738071de..19f629124 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1302,6 +1302,7 @@ class dev_console COORD save_bufsize; PCHAR_INFO save_buf; COORD save_cursor; + SHORT save_top; COORD dwLastCursorPosition; COORD dwMousePosition; /* scroll-adjusted coord of mouse event */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 7a97fc461..27471581a 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1466,6 +1466,7 @@ dev_console::save_restore (HANDLE h, char c) save_buf = (PCHAR_INFO) cmalloc_abort (HEAP_1_BUF, screen_size); save_cursor = b.dwCursorPosition; /* Remember where we were. */ + save_top = b.srWindow.Top; SMALL_RECT now = {}; /* Read the whole buffer */ now.Bottom = save_bufsize.Y - 1; @@ -1489,6 +1490,7 @@ dev_console::save_restore (HANDLE h, char c) now.Bottom = save_bufsize.Y - 1; now.Right = save_bufsize.X - 1; /* Restore whole buffer */ + clear_screen (h, 0, 0, b.dwSize.X - 1, b.dwSize.Y - 1); BOOL res = WriteConsoleOutputW (h, save_buf, save_bufsize, cob, &now); if (!res) debug_printf ("WriteConsoleOutputW failed, %E"); @@ -1496,9 +1498,14 @@ dev_console::save_restore (HANDLE h, char c) cfree (save_buf); save_buf = NULL; + cob.X = 0; + cob.Y = save_top; + /* Temporarily position at top of screen */ + if (!SetConsoleCursorPosition (h, cob)) + debug_printf ("SetConsoleCursorInfo(%p, cob) failed during restore, %E", h); /* Position where we were previously */ if (!SetConsoleCursorPosition (h, save_cursor)) - debug_printf ("SetConsoleCursorInfo(%p, ...) failed during restore, %E", h); + debug_printf ("SetConsoleCursorInfo(%p, save_cursor) failed during restore, %E", h); /* Get back correct version of buffer information */ dwEnd.X = dwEnd.Y = 0; fillin (h);