programs/wineconsole: Correctly display chars 00..1F and 7F

Kirill K. Smirnov lich at math.spbu.ru
Fri Jul 20 07:42:29 CDT 2007


-------------- next part --------------
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
index 689d128..9a4f6cb 100644
--- a/programs/wineconsole/user.c
+++ b/programs/wineconsole/user.c
@@ -39,6 +39,31 @@ 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
+ * MultuByteToWideChar function, but also translates 0x0 to 0x20.
+ */
+const WCHAR WCUSER_GlyphMap[128] =
+{
+    0x0020, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
+    0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
+    0x25ba, 0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25ac, 0x21a8,
+    0x2191, 0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc,
+    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
+    0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+    0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
+    0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+    0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
+    0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
+    0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
+    0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+    0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
+    0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+    0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
+    0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x2302,
+};
+
 static BOOL WCUSER_SetFont(struct inner_data* data, const LOGFONT* font);
 
 /******************************************************************
@@ -53,6 +78,7 @@ static void WCUSER_FillMemDC(const struc
     HFONT		hOldFont;
     WORD		attr;
     WCHAR*		line;
+    WCHAR		c;
     RECT                r;
     HBRUSH              hbr;
 
@@ -78,7 +104,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);


More information about the wine-patches mailing list