[PATCH 0/1] Workaround for bug of hrizontal tab on console.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/1] Workaround for bug of hrizontal tab on console.

Takashi Yano
In cygwin test release 3.1.0-0.1, the horizontal tab setting is broken
after resizing console window. This seems to be a bug of xterm
compatible mode of windows console. This patch fixes this problem.

Takashi Yano (1):
  Cygwin: console: Add workaround for windows xterm compatible mode bug.

 winsup/cygwin/fhandler_console.cc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--
2.21.0

Reply | Threaded
Open this post in threaded view
|

[PATCH 1/1] Cygwin: console: Add workaround for windows xterm compatible mode bug.

Takashi Yano
- The horizontal tab positions are broken after resizing console window.
  This seems to be a bug of xterm compatible mode of windows console.
  This workaround fixes this problem.
---
 winsup/cygwin/fhandler_console.cc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 075593523..3d26a0b90 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -326,6 +326,25 @@ fhandler_console::send_winch_maybe ()
     {
       con.scroll_region.Top = 0;
       con.scroll_region.Bottom = -1;
+      if (wincap.has_con_24bit_colors ())
+ {
+  /* Workaround for a bug of windows xterm compatible mode. */
+  /* The horizontal tab positions are broken after resize. */
+  DWORD dwLen;
+  CONSOLE_SCREEN_BUFFER_INFO sbi;
+  GetConsoleScreenBufferInfo (get_output_handle (), &sbi);
+  /* Clear all horizontal tabs */
+  WriteConsole (get_output_handle (), "\033[3g", 4, &dwLen, 0);
+  /* Set horizontal tabs */
+  for (int col=8; col<con.dwWinSize.X; col+=8)
+    {
+      char buf[32];
+      __small_sprintf (buf, "\033[%d;%dH\033H", 1, col+1);
+      WriteConsole (get_output_handle (), buf, strlen (buf), &dwLen, 0);
+    }
+  /* Restore cursor position */
+  SetConsoleCursorPosition (get_output_handle (), sbi.dwCursorPosition);
+ }
       get_ttyp ()->kill_pgrp (SIGWINCH);
       return true;
     }
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/1] Cygwin: console: Add workaround for windows xterm compatible mode bug.

Corinna Vinschen-2
On Aug 12 22:47, Takashi Yano wrote:

> - The horizontal tab positions are broken after resizing console window.
>   This seems to be a bug of xterm compatible mode of windows console.
>   This workaround fixes this problem.
> ---
>  winsup/cygwin/fhandler_console.cc | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
> index 075593523..3d26a0b90 100644
> --- a/winsup/cygwin/fhandler_console.cc
> +++ b/winsup/cygwin/fhandler_console.cc
> @@ -326,6 +326,25 @@ fhandler_console::send_winch_maybe ()
>      {
>        con.scroll_region.Top = 0;
>        con.scroll_region.Bottom = -1;
> +      if (wincap.has_con_24bit_colors ())
> + {
> +  /* Workaround for a bug of windows xterm compatible mode. */
> +  /* The horizontal tab positions are broken after resize. */
> +  DWORD dwLen;
> +  CONSOLE_SCREEN_BUFFER_INFO sbi;
> +  GetConsoleScreenBufferInfo (get_output_handle (), &sbi);
> +  /* Clear all horizontal tabs */
> +  WriteConsole (get_output_handle (), "\033[3g", 4, &dwLen, 0);
> +  /* Set horizontal tabs */
> +  for (int col=8; col<con.dwWinSize.X; col+=8)
> +    {
> +      char buf[32];
> +      __small_sprintf (buf, "\033[%d;%dH\033H", 1, col+1);
> +      WriteConsole (get_output_handle (), buf, strlen (buf), &dwLen, 0);
> +    }
> +  /* Restore cursor position */
> +  SetConsoleCursorPosition (get_output_handle (), sbi.dwCursorPosition);
> + }
>        get_ttyp ()->kill_pgrp (SIGWINCH);
>        return true;
>      }
> --
> 2.21.0
Pushed.


Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer

signature.asc (849 bytes) Download Attachment