summaryrefslogtreecommitdiff
blob: 50470bd6b7ef983448fa14c9326c78e65be77d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
diff -Nru /tmp/wgHyQebD7F/fte-0.50.0/src/con_slang.cpp /tmp/PQJo4szkUb/fte-0.50.0/src/con_slang.cpp
--- a/fte-0.50.0/src/con_slang.cpp	2005-12-28 16:53:24.000000000 +0100
+++ b/fte-0.50.0/src/con_slang.cpp	2006-06-05 06:02:37.000000000 +0200
@@ -99,12 +99,14 @@
     '+'
 };
 
-static char raw_dchs[sizeof(slang_dchs)];
+static SLsmg_Char_Type raw_dchs[sizeof(slang_dchs)];
 
-static unsigned char ftesl_get_dch(char raw)
+static unsigned char ftesl_get_dch(SLsmg_Char_Type raw)
 {
     for (int i = 0; i < (int) sizeof(slang_dchs); i++)
-	if (raw_dchs[i] == raw)
+	if (raw_dchs[i].nchars == raw.nchars
+	    && !memcmp(raw_dchs[i].wchars, raw.wchars,
+		       raw.nchars * sizeof(*raw.wchars)))
 	    return DCH_SLANG_C1 + i;
     return DCH_SLANG_EOL;
 }
@@ -215,7 +217,6 @@
 int ConInit(int /*XSize */ , int /*YSize */ )
 {
     unsigned i;
-    unsigned short linebuf[sizeof(slang_dchs)];
 
     SLtt_get_terminfo();
 
@@ -246,9 +247,7 @@
     SLsmg_write_nchars(slang_dchs, sizeof(slang_dchs));
 
     SLsmg_gotorc(0, 0);
-    SLsmg_read_raw((SLsmg_Char_Type*)linebuf, sizeof(slang_dchs));
-    for (i = 0; i < sizeof(slang_dchs); i++)
-	raw_dchs[i] = (linebuf[i]) & 0xff;
+    SLsmg_read_raw(raw_dchs, sizeof(slang_dchs));
 
     SLsmg_set_char_set(0);
 
@@ -361,14 +360,14 @@
     return 0;
 }
 
-static int ConPutBoxRaw(int X, int Y, int W, int H, unsigned short *box)
+static int ConPutBoxRaw(int X, int Y, int W, int H, SLsmg_Char_Type *box)
 {
     int CurX, CurY;
 
     ConQueryCursorPos(&CurX, &CurY);
     while (H > 0) {
 	SLsmg_gotorc(Y++, X);
-	SLsmg_write_raw((SLsmg_Char_Type*)box, W);
+	SLsmg_write_raw(box, W);
 	box += W;
 	H--;
     }
@@ -381,35 +380,51 @@
 int ConGetBox(int X, int Y, int W, int H, PCell Cell)
 {
     int CurX, CurY, i;
-    char ch;
+    SLsmg_Char_Type *linebuf;
+
+    linebuf = new SLsmg_Char_Type [W];
 
     ConQueryCursorPos(&CurX, &CurY);
     while (H > 0) {
 	SLsmg_gotorc(Y++, X);
-	SLsmg_read_raw((SLsmg_Char_Type*)Cell, W);
-	for (i = 0; i < W; i++)
-	    if (Cell[i] & 0x8000) {
-		ch = Cell[i] & 0xff;
-		Cell[i] &= 0x7f00;
-		Cell[i] |= ftesl_get_dch(ch);
-	    }
+	SLsmg_read_raw(linebuf, W);
+	for (i = 0; i < W; i++) {
+	    if (linebuf[i].color & SLSMG_ACS_MASK)
+		Cell[i] = ftesl_get_dch(linebuf[i]);
+	    else
+		/*
+		 * FIXME: Handle UTF-8 -- way beyond a quick-and-dirty
+		 * fix.  --MV
+		 */
+		Cell[i] = SLSMG_EXTRACT_CHAR(linebuf[i]);
+	    /*
+	     * FIXME: This preserves only 7 out of 15 bits of color.
+	     * Fortunately, we're dealing with color handles rather than
+	     * colors themselves -- S-Lang jumps through an extra hoop to
+	     * map these to color data.  As long as we use less than 127
+	     * different colors, things should be OK.  I think.  --MV
+	     */
+	    Cell[i] |= (linebuf[i].color & 0x7f) << 8;
+	}
 	Cell += W;
 	H--;
     }
     ConSetCursorPos(CurX, CurY);
 
+    delete [] (linebuf);
+
     return 0;
 
 }
 
-static int ConGetBoxRaw(int X, int Y, int W, int H, unsigned short *box)
+static int ConGetBoxRaw(int X, int Y, int W, int H, SLsmg_Char_Type *box)
 {
     int CurX, CurY;
 
     ConQueryCursorPos(&CurX, &CurY);
     while (H > 0) {
 	SLsmg_gotorc(Y++, X);
-	SLsmg_read_raw((SLsmg_Char_Type*)box, W);
+	SLsmg_read_raw(box, W);
 	box += W;
 	H--;
     }
@@ -451,9 +466,9 @@
 
 int ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count)
 {
-    unsigned short *box;
+    SLsmg_Char_Type *box;
 
-    box = new unsigned short [W * H];
+    box = new SLsmg_Char_Type [W * H];
 
     TCell fill = (((unsigned) Fill) << 8) | ' ';