* 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.
This commit is contained in:
Corinna Vinschen 2001-03-30 11:10:13 +00:00
parent 0694d8d310
commit f42da31ad6
3 changed files with 65 additions and 0 deletions

View File

@ -1,3 +1,13 @@
Fri Mar 30 13:02:00 2001 Corinna Vinschen <corinna@vinschen.de>
* 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.
Wed Mar 28 19:28:50 2001 Christopher Faylor <cgf@cygnus.com>
* path.cc (chdir): Eat trailing whitespace on input path.

View File

@ -630,6 +630,10 @@ private:
/* saved cursor coordinates */
int savex, savey;
/* saved screen */
COORD savebufsiz;
PCHAR_INFO savebuf;
struct
{
short Top, Bottom;

View File

@ -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");