diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-03-30 11:10:13 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-03-30 11:10:13 +0000 |
commit | f42da31ad6985867c9098eea4c6eab7576c10bf0 (patch) | |
tree | c15b594213700e92a0d3f5e00f6e94232ef27d31 /winsup/cygwin/fhandler_console.cc | |
parent | 0694d8d3109d10be3c016d5f144811c618602111 (diff) | |
download | newlib-f42da31ad6985867c9098eea4c6eab7576c10bf0.zip newlib-f42da31ad6985867c9098eea4c6eab7576c10bf0.tar.gz newlib-f42da31ad6985867c9098eea4c6eab7576c10bf0.tar.bz2 |
* fhandler.h (class fhandler_console): Add members `savebufsiz' and
`savebuf' to allow save/restore of screen.
* fhandler_console.cc (fhandler_console::dup): Duplicate savebuf.
(fhandler_console::fhandler_console): Initialize `savebufsiz' and
`savebuf'.
(fhandler_console::char_command): Add terminal capabilities
"save screen content" = \E[?47h and "restore screen content" = \E[?47l.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index d780f8c..ba72dfa 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -565,6 +565,15 @@ fhandler_console::dup (fhandler_base *child) fhc->savex = savex; fhc->savey = savey; + fhc->savebufsiz = savebufsiz; + if (savebuf) + { + fhc->savebuf = (PCHAR_INFO) malloc (sizeof (CHAR_INFO) * + savebufsiz.X * savebufsiz.Y); + memcpy (fhc->savebuf, savebuf, sizeof (CHAR_INFO) * + savebufsiz.X * savebufsiz.Y); + } + fhc->scroll_region = scroll_region; fhc->dwLastCursorPosition = dwLastCursorPosition; fhc->dwLastButtonState = dwLastButtonState; @@ -784,6 +793,8 @@ fhandler_console::fhandler_console (const char *name) : nargs_ = 0; for (int i = 0; i < MAXARGS; i++) args_ [i] = 0; savex = savey = 0; + savebufsiz.X = savebufsiz.Y = 0; + savebuf = NULL; scroll_region.Top = 0; scroll_region.Bottom = -1; dwLastCursorPosition.X = -1; @@ -1088,6 +1099,46 @@ fhandler_console::char_command (char c) break; switch (args_[0]) { + case 47: /* Save/Restore screen */ + if (c == 'h') /* save */ + { + CONSOLE_SCREEN_BUFFER_INFO now; + COORD cob = { 0, 0 }; + + if (!GetConsoleScreenBufferInfo (get_output_handle (), &now)) + break; + + savebufsiz.X = now.srWindow.Right - now.srWindow.Left; + savebufsiz.Y = now.srWindow.Bottom - now.srWindow.Top; + + if (savebuf) + free (savebuf); + savebuf = (PCHAR_INFO) malloc (sizeof (CHAR_INFO) * + savebufsiz.X * savebufsiz.Y); + + ReadConsoleOutputA (get_output_handle (), savebuf, + savebufsiz, cob, &now.srWindow); + } + else /* restore */ + { + CONSOLE_SCREEN_BUFFER_INFO now; + COORD cob = { 0, 0 }; + + if (!GetConsoleScreenBufferInfo (get_output_handle (), &now)) + break; + + if (!savebuf) + break; + + WriteConsoleOutputA (get_output_handle (), savebuf, + savebufsiz, cob, &now.srWindow); + + free (savebuf); + savebuf = NULL; + savebufsiz.X = savebufsiz.Y = 0; + } + break; + case 1000: /* Mouse support */ use_mouse = (c == 'h') ? TRUE : FALSE; syscall_printf("mouse support %sabled", use_mouse ? "en" : "dis"); |