[ros-diffs] [weiden] 29941: Fix console painting bugs

weiden at svn.reactos.org weiden at svn.reactos.org
Sun Oct 28 21:52:21 CET 2007


Author: weiden
Date: Sun Oct 28 23:52:21 2007
New Revision: 29941

URL: http://svn.reactos.org/svn/reactos?rev=29941&view=rev
Log:
Fix console painting bugs

Modified:
    trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c

Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c?rev=29941&r1=29940&r2=29941&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c Sun Oct 28 23:52:21 2007
@@ -61,7 +61,7 @@
 #define PM_DESTROY_CONSOLE (WM_APP + 2)
 
 #define CURSOR_BLINK_TIME 500
-#define DEFAULT_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY)
+#define DEFAULT_ATTRIB (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
 
 static BOOL ConsInitialized = FALSE;
 static HWND NotifyWnd;
@@ -115,6 +115,8 @@
     RGB(255, 255, 255)
 };
 
+#define GuiConsoleRGBFromAttribute(GuiData, Attribute) ((GuiData)->Colors[(Attribute) & 0xF])
+
 /* FUNCTIONS *****************************************************************/
 
 static VOID FASTCALL
@@ -777,31 +779,6 @@
   return (BOOL) DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM) Create);
 }
 
-static COLORREF FASTCALL
-GuiConsoleRGBFromAttribute(BYTE Attribute)
-{
-  int Red = (Attribute & 0x04 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
-  int Green = (Attribute & 0x02 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
-  int Blue = (Attribute & 0x01 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
-
-  return RGB(Red, Green, Blue);
-}
-
-static VOID FASTCALL
-GuiConsoleSetTextColors(HDC Dc, BYTE Attribute, PCSRSS_SCREEN_BUFFER Buff, COLORREF TextColor, COLORREF BkColor)
-{
-  if (Attribute != Buff->DefaultAttrib)
-    {
-      SetTextColor(Dc, GuiConsoleRGBFromAttribute(Attribute & 0x0f));
-      SetBkColor(Dc, GuiConsoleRGBFromAttribute((Attribute & 0xf0) >> 4));
-    }
-  else
-    {
-      SetTextColor(Dc, TextColor);
-      SetBkColor(Dc, BkColor);
-    }
-}
-
 static VOID FASTCALL
 GuiConsoleGetLogicalCursorPos(PCSRSS_SCREEN_BUFFER Buff, ULONG *CursorX, ULONG *CursorY)
 {
@@ -905,11 +882,8 @@
     RightChar = (rc->right + (GuiData->CharWidth - 1)) / GuiData->CharWidth - 1;
     LastAttribute = Buff->Buffer[(TopLine * Buff->MaxX + LeftChar) * 2 + 1];
 
-    GuiConsoleSetTextColors(hDC,
-                            LastAttribute,
-                            Buff,
-                            GuiData->ScreenText,
-                            GuiData->ScreenBackground);
+    SetTextColor(hDC, GuiConsoleRGBFromAttribute(GuiData, LastAttribute));
+    SetBkColor(hDC, GuiConsoleRGBFromAttribute(GuiData, LastAttribute >> 4));
 
     EnterCriticalSection(&Buff->Header.Lock);
 
@@ -948,11 +922,8 @@
                 Attribute = *(From + 1);
                 if (Attribute != LastAttribute)
                 {
-                    GuiConsoleSetTextColors(hDC,
-                                            Attribute,
-                                            Buff,
-                                            GuiData->ScreenText,
-                                            GuiData->ScreenBackground);
+                    SetTextColor(hDC, GuiConsoleRGBFromAttribute(GuiData, Attribute));
+                    SetBkColor(hDC, GuiConsoleRGBFromAttribute(GuiData, Attribute >> 4));
                     LastAttribute = Attribute;
                 }
             }
@@ -992,7 +963,7 @@
 
             if (*From != DEFAULT_ATTRIB)
             {
-                CursorBrush = CreateSolidBrush(GuiConsoleRGBFromAttribute(*From));
+                CursorBrush = CreateSolidBrush(GuiConsoleRGBFromAttribute(GuiData, *From));
             }
             else
             {
@@ -1253,8 +1224,8 @@
 
     if (Console->ActiveBuffer == Buff)
     {
-        GuiData->ScreenText = GuiConsoleRGBFromAttribute(Buff->DefaultAttrib & 0x0f);
-        GuiData->ScreenBackground = GuiConsoleRGBFromAttribute((Buff->DefaultAttrib & 0xf0) >> 4);
+        GuiData->ScreenText = GuiConsoleRGBFromAttribute(GuiData, Buff->DefaultAttrib);
+        GuiData->ScreenBackground = GuiConsoleRGBFromAttribute(GuiData, Buff->DefaultAttrib >> 4);
     }
 
     return TRUE;




More information about the Ros-diffs mailing list