Corinna Vinschen wrote:
Since you were looking into the Cygwin console code lately, maybe you
could find out why `stty sane' doesn't reset the character set?
The tool to use would be 'reset'. So I'll try to find out why
'reset' doesn't reset the character set :-\ .
There are two methods to switch to the alternate character set. One
is by just sending a Control-N. Most terminals "guard" this method
by requiring an enable sequence before this works. I guess this
would considerably reduce the risk that this happens, that's
probably why they do it.
I didn't implement the guarding mechanism in fhandler_console
(although I prepared it somewhat) so I think I should fully
implement that.
The attached patch should make 'reset' work, and it should make the
'VT100 graphics garbage effect' less likely. Miraculously, even 'pstree
-G' works now...
2010-03-30 Thomas Wolff <[email protected]>
* fhandler.h, fhandler_console.cc: Tune VT100 graphics mode
switching to follow ISO 2022 strictly.
diff -rup orig/fhandler.h ./fhandler.h
--- orig/fhandler.h 2010-03-23 10:34:05.001000000 +0100
+++ ./fhandler.h 2010-03-30 17:22:15.427713900 +0200
@@ -906,7 +906,9 @@ class dev_console
unsigned rarg;
bool saw_question_mark;
bool saw_greater_than_sign;
- bool vt100_graphics_mode_active;
+ bool vt100_graphics_mode_G0;
+ bool vt100_graphics_mode_G1;
+ bool iso_2022_G1;
bool alternate_charset_active;
bool metabit;
diff -rup orig/fhandler_console.cc ./fhandler_console.cc
--- orig/fhandler_console.cc 2010-03-18 15:57:09.001000000 +0100
+++ ./fhandler_console.cc 2010-03-30 17:26:59.418904900 +0200
@@ -1161,7 +1161,9 @@ static wchar_t __vt100_conv [31] = {
inline
bool fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done)
{
- if (dev_state->vt100_graphics_mode_active)
+ if (dev_state->iso_2022_G1
+ ? dev_state->vt100_graphics_mode_G1
+ : dev_state->vt100_graphics_mode_G0)
for (DWORD i = 0; i < len; i ++)
if (buf[i] >= (unsigned char) '`' && buf[i] <= (unsigned char) '~')
buf[i] = __vt100_conv[buf[i] - (unsigned char) '`'];
@@ -1734,11 +1736,11 @@ fhandler_console::write_normal (const un
int x, y;
switch (base_chars[*found])
{
- case SO:
- dev_state->vt100_graphics_mode_active = true;
+ case SO: /* Shift Out: Invoke G1 character set (ISO 2022) */
+ dev_state->iso_2022_G1 = true;
break;
- case SI:
- dev_state->vt100_graphics_mode_active = false;
+ case SI: /* Shift In: Invoke G0 character set (ISO 2022) */
+ dev_state->iso_2022_G1 = false;
break;
case BEL:
beep ();
@@ -1862,6 +1864,9 @@ fhandler_console::write (const void *vsr
else if (*src == 'c') /* RIS Full Reset */
{
dev_state->set_default_attr ();
+ dev_state->vt100_graphics_mode_G0 = false;
+ dev_state->vt100_graphics_mode_G1 = false;
+ dev_state->iso_2022_G1 = false;
clear_screen (0, 0, -1, -1);
cursor_set (true, 0, 0);
dev_state->state_ = normal;
@@ -1959,20 +1964,19 @@ fhandler_console::write (const void *vsr
else
dev_state->state_ = gotarg1;
break;
- case gotparen:
+ case gotparen: /* Designate G0 Character Set (ISO 2022) */
if (*src == '0')
- dev_state->vt100_graphics_mode_active = true;
+ dev_state->vt100_graphics_mode_G0 = true;
else
- dev_state->vt100_graphics_mode_active = false;
+ dev_state->vt100_graphics_mode_G0 = false;
dev_state->state_ = normal;
src++;
break;
- case gotrparen:
- /* This is not strictly needed, ^N/^O can just always be enabled */
+ case gotrparen: /* Designate G1 Character Set (ISO 2022) */
if (*src == '0')
- /*dev_state->vt100_graphics_mode_SOSI_enabled = true*/;
+ dev_state->vt100_graphics_mode_G1 = true;
else
- /*dev_state->vt100_graphics_mode_SOSI_enabled = false*/;
+ dev_state->vt100_graphics_mode_G1 = false;
dev_state->state_ = normal;
src++;
break;