Sync up with trunk r61578.
[reactos.git] / win32ss / user / winsrv / consrv / frontends / gui / text.c
index 313e50c..1867a09 100644 (file)
 
 /* FUNCTIONS ******************************************************************/
 
+COLORREF RGBFromAttrib2(PCONSOLE Console, WORD Attribute)
+{
+    HPALETTE hPalette = Console->ActiveBuffer->PaletteHandle;
+    PALETTEENTRY pe;
+
+    if (hPalette == NULL) return RGBFromAttrib(Console, Attribute);
+
+    GetPaletteEntries(hPalette, Attribute, 1, &pe);
+    return PALETTERGB(pe.peRed, pe.peGreen, pe.peBlue);
+}
+
 VOID
 GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer)
 {
@@ -217,8 +228,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
 
     LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes;
 
-    SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute)));
-    SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute)));
+    SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console, TextAttribFromAttrib(LastAttribute)));
+    SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console, BkgdAttribFromAttrib(LastAttribute)));
 
     OldFont = SelectObject(GuiData->hMemDC, GuiData->Font);
 
@@ -247,8 +258,8 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
                 Attribute = From->Attributes;
                 if (Attribute != LastAttribute)
                 {
-                    SetTextColor(GuiData->hMemDC, RGBFromAttrib(Console, TextAttribFromAttrib(Attribute)));
-                    SetBkColor(GuiData->hMemDC, RGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)));
+                    SetTextColor(GuiData->hMemDC, RGBFromAttrib2(Console, TextAttribFromAttrib(Attribute)));
+                    SetBkColor(GuiData->hMemDC, RGBFromAttrib2(Console, BkgdAttribFromAttrib(Attribute)));
                     LastAttribute = Attribute;
                 }
             }
@@ -280,7 +291,7 @@ GuiPaintTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
             Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X, Buffer->CursorPosition.Y)->Attributes;
             if (Attribute == DEFAULT_SCREEN_ATTRIB) Attribute = Buffer->ScreenDefaultAttrib;
 
-            CursorBrush = CreateSolidBrush(RGBFromAttrib(Console, Attribute));
+            CursorBrush = CreateSolidBrush(RGBFromAttrib2(Console, TextAttribFromAttrib(Attribute)));
             OldBrush    = SelectObject(GuiData->hMemDC, CursorBrush);
 
             PatBlt(GuiData->hMemDC,