Cygwin: pty: Use redraw screen instead of clear screen.
- Previously, pty cleared screen at startup for synchronization between the real screen and console screen buffer for pseudo console. With this patch, instead of clearing screen, the screen is redrawn when the first native program is executed after pty is created. In other words, synchronization is deferred until the native app is executed. Moreover, this realizes excluding $TERM dependent code.
This commit is contained in:
parent
d3110717f0
commit
7ef4290a98
|
@ -2669,7 +2669,7 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
|
||||||
if (get_ttyp ()->num_pcon_attached_slaves == 0
|
if (get_ttyp ()->num_pcon_attached_slaves == 0
|
||||||
&& !ALWAYS_USE_PCON)
|
&& !ALWAYS_USE_PCON)
|
||||||
/* Assume this is the first process using this pty slave. */
|
/* Assume this is the first process using this pty slave. */
|
||||||
get_ttyp ()->need_clear_screen = true;
|
get_ttyp ()->need_redraw_screen = true;
|
||||||
|
|
||||||
get_ttyp ()->num_pcon_attached_slaves ++;
|
get_ttyp ()->num_pcon_attached_slaves ++;
|
||||||
}
|
}
|
||||||
|
@ -2700,6 +2700,21 @@ fhandler_pty_slave::fixup_after_attach (bool native_maybe, int fd_set)
|
||||||
kill (get_ttyp ()->pcon_pid, 0) != 0)
|
kill (get_ttyp ()->pcon_pid, 0) != 0)
|
||||||
get_ttyp ()->pcon_pid = myself->pid;
|
get_ttyp ()->pcon_pid = myself->pid;
|
||||||
get_ttyp ()->switch_to_pcon_out = true;
|
get_ttyp ()->switch_to_pcon_out = true;
|
||||||
|
|
||||||
|
if (get_ttyp ()->need_redraw_screen)
|
||||||
|
{
|
||||||
|
/* Forcibly redraw screen based on console screen buffer. */
|
||||||
|
/* The following code triggers redrawing the screen. */
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO sbi;
|
||||||
|
GetConsoleScreenBufferInfo (get_output_handle (), &sbi);
|
||||||
|
SMALL_RECT rect = {0, 0,
|
||||||
|
(SHORT) (sbi.dwSize.X -1), (SHORT) (sbi.dwSize.Y - 1)};
|
||||||
|
COORD dest = {0, 0};
|
||||||
|
CHAR_INFO fill = {' ', 0};
|
||||||
|
ScrollConsoleScreenBuffer (get_output_handle (),
|
||||||
|
&rect, NULL, dest, &fill);
|
||||||
|
get_ttyp ()->need_redraw_screen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
init_console_handler (false);
|
init_console_handler (false);
|
||||||
}
|
}
|
||||||
|
@ -2717,19 +2732,6 @@ fhandler_pty_slave::fixup_after_fork (HANDLE parent)
|
||||||
// fork_fixup (parent, inuse, "inuse");
|
// fork_fixup (parent, inuse, "inuse");
|
||||||
// fhandler_pty_common::fixup_after_fork (parent);
|
// fhandler_pty_common::fixup_after_fork (parent);
|
||||||
report_tty_counts (this, "inherited", "");
|
report_tty_counts (this, "inherited", "");
|
||||||
|
|
||||||
if (get_ttyp ()->need_clear_screen)
|
|
||||||
{
|
|
||||||
const char *term = getenv ("TERM");
|
|
||||||
if (term && strcmp (term, "dumb") && !strstr (term, "emacs"))
|
|
||||||
{
|
|
||||||
/* FIXME: Clearing sequence may not be "^[[H^[[J"
|
|
||||||
depending on the terminal type. */
|
|
||||||
DWORD n;
|
|
||||||
WriteFile (get_output_handle_cyg (), "\033[H\033[J", 6, &n, NULL);
|
|
||||||
}
|
|
||||||
get_ttyp ()->need_clear_screen = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -244,7 +244,7 @@ tty::init ()
|
||||||
pcon_pid = 0;
|
pcon_pid = 0;
|
||||||
num_pcon_attached_slaves = 0;
|
num_pcon_attached_slaves = 0;
|
||||||
term_code_page = 0;
|
term_code_page = 0;
|
||||||
need_clear_screen = false;
|
need_redraw_screen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE
|
HANDLE
|
||||||
|
|
|
@ -105,7 +105,7 @@ private:
|
||||||
pid_t pcon_pid;
|
pid_t pcon_pid;
|
||||||
int num_pcon_attached_slaves;
|
int num_pcon_attached_slaves;
|
||||||
UINT term_code_page;
|
UINT term_code_page;
|
||||||
bool need_clear_screen;
|
bool need_redraw_screen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HANDLE from_master () const { return _from_master; }
|
HANDLE from_master () const { return _from_master; }
|
||||||
|
|
Loading…
Reference in New Issue