programs/wineconsole: Correctly display chars 00..1F and 7F [try 2]

Kirill K. Smirnov lich at math.spbu.ru
Mon Jul 30 03:55:36 CDT 2007


-------------- next part --------------
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
index 689d128..57c6193 100644
--- a/programs/wineconsole/user.c
+++ b/programs/wineconsole/user.c
@@ -39,9 +39,38 @@ const COLORREF WCUSER_ColorMap[16] =
     RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
 };
 
+/*
+ * Mapping console control chars to unicode glyphs.
+ * It is almost the same mapping as for MB_USEGLYPHCHARS flag of
+ * MultiByteToWideChar function, but also translates 0x0 to 0x20.
+ */
+WCHAR WCUSER_GlyphMap[128];
+
 static BOOL WCUSER_SetFont(struct inner_data* data, const LOGFONT* font);
 
 /******************************************************************
+ *		WCUSER_BuildGlyphMap
+ *
+ * Initializes WCUSER_GlyphMap table using MultiByteToWideChar
+ * with MB_USEGLYPHCHARS flag.
+ *
+ * It does not really matter, what codepage is taken as a source.
+ * The only demands are:
+ * 1) support glyphs;
+ * 2) [32..126] chars must be left in place.
+ * Codepage 437 is suitable.
+ */
+static void WCUSER_BuildGlyphMap(void)
+{
+    char from[128];
+    int i;
+
+    for (i = 0; i < 128; i++) from[i] = i;
+    MultiByteToWideChar(437, MB_USEGLYPHCHARS, from, 128, WCUSER_GlyphMap, 128);
+    WCUSER_GlyphMap[0] = ' ';
+}
+
+/******************************************************************
  *		WCUSER_FillMemDC
  *
  * Fills the Mem DC with current cells values
@@ -53,6 +82,7 @@ static void WCUSER_FillMemDC(const struc
     HFONT		hOldFont;
     WORD		attr;
     WCHAR*		line;
+    WCHAR		c;
     RECT                r;
     HBRUSH              hbr;
 
@@ -78,7 +108,8 @@ static void WCUSER_FillMemDC(const struc
 	    SetTextColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[attr&0x0F]);
 	    for (k = i; k < data->curcfg.sb_width && cell[k].Attributes == attr; k++)
 	    {
-		line[k - i] = cell[k].Char.UnicodeChar;
+		c = cell[k].Char.UnicodeChar;
+		line[k - i] = (c < 0x80) ? WCUSER_GlyphMap[c] : c;
 	    }
 	    TextOut(PRIVATE(data)->hMemDC, i * data->curcfg.cell_width, j * data->curcfg.cell_height,
 		    line, k - i);
@@ -1439,5 +1470,6 @@ enum init_return WCUSER_InitBackend(stru
 		 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, wndclass.hInstance, data);
     if (!PRIVATE(data)->hWnd) return init_failed;
 
+    WCUSER_BuildGlyphMap();
     return init_success;
 }


More information about the wine-patches mailing list