Index: reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c =================================================================== --- reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c (revision 74386) +++ reactos/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c (working copy) @@ -147,7 +147,7 @@ WndClass.hIcon = ghDefaultIcon; WndClass.hIconSm = ghDefaultIconSm; WndClass.hCursor = ghDefaultCursor; - WndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); // The color of a terminal when it is switched off. + WndClass.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); /* for speed */ WndClass.lpszMenuName = NULL; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = GWLP_CONWND_ALLOC; Index: reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c =================================================================== --- reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c (revision 74386) +++ reactos/win32ss/user/winsrv/consrv/frontends/gui/text.c (working copy) @@ -7,6 +7,7 @@ * Johannes Anderwald * Jeffrey Morlan * Hermes Belusca-Maito (hermes.belusca@sfr.fr) + * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) */ /* INCLUDES *******************************************************************/ @@ -20,7 +21,7 @@ /* GLOBALS ********************************************************************/ -#define IS_WHITESPACE(c) ((c) == L'\0' || (c) == L' ' || (c) == L'\t') +#define IS_WHITESPACE(c) ((c) == L'\0' || (c) == L' ' || (c) == L'\t' || (c) == 0x3000) /* FUNCTIONS ******************************************************************/ @@ -346,128 +346,112 @@ PRECT rcFramebuffer) { PCONSRV_CONSOLE Console = Buffer->Header.Console; + ULONG Line, Column, TopLine, BottomLine, LeftColumn, RightColumn; + BOOL IsUnderline; + PCHAR_INFO pCharInfo; + RECT Rect; + WORD Attribute; + DWORD LastAttribute; + WCHAR wch; + COLORREF TextColor, BackColor; + HFONT Font, OldFont = NULL; // ASSERT(Console == GuiData->Console); - ULONG TopLine, BottomLine, LeftChar, RightChar; - ULONG Line, Char, Start; - PCHAR_INFO From; - PWCHAR To; - WORD LastAttribute, Attribute; - ULONG CursorX, CursorY, CursorHeight; - HBRUSH CursorBrush, OldBrush; - HFONT OldFont, NewFont; - BOOLEAN IsUnderline; + if (Buffer->Buffer == NULL) + return; - if (Buffer->Buffer == NULL) return; + if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) + return; - if (!ConDrvValidateConsoleUnsafe((PCONSOLE)Console, CONSOLE_RUNNING, TRUE)) return; + SetRect(rcFramebuffer, + Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left, + Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top, + Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right, + Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->bottom); - rcFramebuffer->left = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->left; - rcFramebuffer->top = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->top; - rcFramebuffer->right = Buffer->ViewOrigin.X * GuiData->CharWidth + rcView->right; - rcFramebuffer->bottom = Buffer->ViewOrigin.Y * GuiData->CharHeight + rcView->bottom; + LeftColumn = rcFramebuffer->left / GuiData->CharWidth; + RightColumn = rcFramebuffer->right / GuiData->CharWidth; + if (RightColumn >= (ULONG)Buffer->ScreenBufferSize.X) + RightColumn = Buffer->ScreenBufferSize.X - 1; - LeftChar = rcFramebuffer->left / GuiData->CharWidth; - TopLine = rcFramebuffer->top / GuiData->CharHeight; - RightChar = rcFramebuffer->right / GuiData->CharWidth; - BottomLine = rcFramebuffer->bottom / GuiData->CharHeight; + TopLine = rcFramebuffer->top / GuiData->CharHeight; + BottomLine = rcFramebuffer->bottom / GuiData->CharHeight; + if (BottomLine >= (ULONG)Buffer->ScreenBufferSize.Y) + BottomLine = Buffer->ScreenBufferSize.Y - 1; - if (RightChar >= (ULONG)Buffer->ScreenBufferSize.X) RightChar = Buffer->ScreenBufferSize.X - 1; - if (BottomLine >= (ULONG)Buffer->ScreenBufferSize.Y) BottomLine = Buffer->ScreenBufferSize.Y - 1; + /* draw the colored text */ + LastAttribute = 0xFFFFFFFF; + SetBkMode(GuiData->hMemDC, OPAQUE); + for (Line = TopLine; Line <= BottomLine; Line++) + { + SetRect(&Rect, LeftColumn * GuiData->CharWidth, + Line * GuiData->CharHeight, + RightColumn * GuiData->CharWidth, + (Line + 1) * GuiData->CharHeight); + if (!RectVisible(GuiData->hMemDC, &Rect)) + continue; - LastAttribute = ConioCoordToPointer(Buffer, LeftChar, TopLine)->Attributes; + for (Column = LeftColumn; Column <= RightColumn; Column++) + { + SetRect(&Rect, Column * GuiData->CharWidth, + Line * GuiData->CharHeight, + (Column + 1) * GuiData->CharWidth, + (Line + 1) * GuiData->CharHeight); + if (!RectVisible(GuiData->hMemDC, &Rect)) + continue; - SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute))); - SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute))); + pCharInfo = ConioCoordToPointer(Buffer, Column, Line); - /* We use the underscore flag as a underline flag */ - IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE); - /* Select the new font */ - NewFont = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL]; - OldFont = SelectObject(GuiData->hMemDC, NewFont); + Attribute = pCharInfo->Attributes; + if (Attribute == DEFAULT_SCREEN_ATTRIB) + Attribute = Buffer->ScreenDefaultAttrib; - for (Line = TopLine; Line <= BottomLine; Line++) - { - WCHAR LineBuffer[80]; // Buffer containing a part or all the line to be displayed - From = ConioCoordToPointer(Buffer, LeftChar, Line); // Get the first code of the line - Start = LeftChar; - To = LineBuffer; - - for (Char = LeftChar; Char <= RightChar; Char++) - { - /* - * We flush the buffer if the new attribute is different - * from the current one, or if the buffer is full. - */ - if (From->Attributes != LastAttribute || (Char - Start == sizeof(LineBuffer) / sizeof(WCHAR))) + if (Attribute != LastAttribute) { - TextOutW(GuiData->hMemDC, - Start * GuiData->CharWidth, - Line * GuiData->CharHeight, - LineBuffer, - Char - Start); - Start = Char; - To = LineBuffer; - Attribute = From->Attributes; - if (Attribute != LastAttribute) - { - LastAttribute = Attribute; - SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, TextAttribFromAttrib(LastAttribute))); - SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(LastAttribute))); + /* update attributes */ + LastAttribute = Attribute; - /* Change underline state if needed */ - if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderline) - { - IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE); - /* Select the new font */ - NewFont = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL]; - /* OldFont = */ SelectObject(GuiData->hMemDC, NewFont); - } - } + if (OldFont) + SelectObject(GuiData->hMemDC, OldFont); + + IsUnderline = !!(Attribute & COMMON_LVB_UNDERSCORE); + Font = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL]; + OldFont = SelectObject(GuiData->hMemDC, Font); + + TextColor = PaletteRGBFromAttrib(Console, TextAttribFromAttrib(Attribute)); + SetTextColor(GuiData->hMemDC, TextColor); + + BackColor = PaletteRGBFromAttrib(Console, BkgdAttribFromAttrib(Attribute)); + SetBkColor(GuiData->hMemDC, BackColor); } - *(To++) = (From++)->Char.UnicodeChar; + wch = pCharInfo->Char.UnicodeChar; + TextOutW(GuiData->hMemDC, Rect.left, Rect.top, &wch, 1); } + } - TextOutW(GuiData->hMemDC, - Start * GuiData->CharWidth, - Line * GuiData->CharHeight, - LineBuffer, - RightChar - Start + 1); + if (OldFont) + { + SelectObject(GuiData->hMemDC, OldFont); } - /* Restore the old font */ - SelectObject(GuiData->hMemDC, OldFont); - - /* - * Draw the caret - */ + /* draw the caret */ if (Buffer->CursorInfo.bVisible && - Buffer->CursorBlinkOn && - !Buffer->ForceCursorOff) + Buffer->CursorBlinkOn && !Buffer->ForceCursorOff) { - CursorX = Buffer->CursorPosition.X; - CursorY = Buffer->CursorPosition.Y; - if (LeftChar <= CursorX && CursorX <= RightChar && - TopLine <= CursorY && CursorY <= BottomLine) + Column = Buffer->CursorPosition.X; + Line = Buffer->CursorPosition.Y; + if (TopLine <= Line && Line <= BottomLine && + LeftColumn <= Column && Column <= RightColumn) { - CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight); + ULONG CursorHeight = ConioEffectiveCursorSize(Console, GuiData->CharHeight); - Attribute = ConioCoordToPointer(Buffer, Buffer->CursorPosition.X, Buffer->CursorPosition.Y)->Attributes; - if (Attribute == DEFAULT_SCREEN_ATTRIB) Attribute = Buffer->ScreenDefaultAttrib; - - CursorBrush = CreateSolidBrush(PaletteRGBFromAttrib(Console, TextAttribFromAttrib(Attribute))); - OldBrush = SelectObject(GuiData->hMemDC, CursorBrush); - PatBlt(GuiData->hMemDC, - CursorX * GuiData->CharWidth, - CursorY * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight), + Column * GuiData->CharWidth, + Line * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight), GuiData->CharWidth, CursorHeight, - PATCOPY); - - SelectObject(GuiData->hMemDC, OldBrush); - DeleteObject(CursorBrush); + DSTINVERT); } }