Thomas Wolff | 1 Dec 2004 08:16
Picon
Favicon

change log fix: [Patch] bug # 514 (cygwin console handling)

Sorry, I missed to insert the function name in the change log 
entry, so here it is again as an update; the patch is the same.

This is a small patch that fixes
 http://sourceware.org/bugzilla/show_bug.cgi?id=514

Please integrate it into the cygwin DLL.

2004-11-26  Thomas Wolff  <towo <at> computer.org>

* fhandler_console.cc (get_win32_attr): Avoid inappropriate intensity 
     interchanging that used to render reverse output unreadable 
     when (non-reversed) text is bright.
     See http://sourceware.org/bugzilla/show_bug.cgi?id=514
     There are two useful alternatives to handle this; both are in 
     the patch (#ifdef reverse_bright) and one is selected by #define:
     a) (selected) bright foreground will reverse to a bright background,
     b) bright foreground will reverse to a dim background but 
        the background will no longer reverse to a bright foreground 
        (which used to render reverse output unreadable).

--- cygwin-1.5.12-1/winsup/cygwin/fhandler_console.cc	2004-10-28 17:33:04.000000000 +0200
+++ cygwin-1.5.12-1/winsup/cygwin/fhandler_console.cc.fix514	2004-11-30 12:44:03.499523500 +0100
 <at>  <at>  -921,14 +921,32  <at>  <at>  fhandler_console::get_win32_attr ()
   if (dev_state->reverse)
     {
       WORD save_fg = win_fg;
+#define reverse_bright
+#ifdef reverse_bright
+      /* This way, a bright foreground will reverse to a bright background.
+       */
       win_fg = (win_bg & BACKGROUND_RED   ? FOREGROUND_RED   : 0) |
 	       (win_bg & BACKGROUND_GREEN ? FOREGROUND_GREEN : 0) |
 	       (win_bg & BACKGROUND_BLUE  ? FOREGROUND_BLUE  : 0) |
-	       (win_fg & FOREGROUND_INTENSITY);
+	       (win_bg & BACKGROUND_INTENSITY ? FOREGROUND_INTENSITY : 0);
       win_bg = (save_fg & FOREGROUND_RED   ? BACKGROUND_RED   : 0) |
 	       (save_fg & FOREGROUND_GREEN ? BACKGROUND_GREEN : 0) |
 	       (save_fg & FOREGROUND_BLUE  ? BACKGROUND_BLUE  : 0) |
-	       (win_bg & BACKGROUND_INTENSITY);
+	       (save_fg & FOREGROUND_INTENSITY ? BACKGROUND_INTENSITY : 0);
+#else
+      /* This way, a bright foreground will reverse to a dim background.
+         But the background will no longer reverse to a bright foreground 
+         (which used to render reverse output unreadable).
+       */
+      win_fg = (win_bg & BACKGROUND_RED   ? FOREGROUND_RED   : 0) |
+	       (win_bg & BACKGROUND_GREEN ? FOREGROUND_GREEN : 0) |
+	       (win_bg & BACKGROUND_BLUE  ? FOREGROUND_BLUE  : 0) |
+	       (win_bg & FOREGROUND_INTENSITY);
+      win_bg = (save_fg & FOREGROUND_RED   ? BACKGROUND_RED   : 0) |
+	       (save_fg & FOREGROUND_GREEN ? BACKGROUND_GREEN : 0) |
+	       (save_fg & FOREGROUND_BLUE  ? BACKGROUND_BLUE  : 0) |
+	       (save_fg & BACKGROUND_INTENSITY);
+#endif
     }
   if (dev_state->underline)
     win_fg = dev_state->underline_color;

Gmane