1 | /* |
---|
2 | * libcucul Canvas for ultrafast compositing of Unicode letters |
---|
3 | * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: transform.c 1782 2007-06-28 12:47:57Z sam $ |
---|
7 | * |
---|
8 | * This library is free software. It comes without any warranty, to |
---|
9 | * the extent permitted by applicable law. You can redistribute it |
---|
10 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | */ |
---|
14 | |
---|
15 | /* |
---|
16 | * This file contains horizontal and vertical flipping routines. |
---|
17 | */ |
---|
18 | |
---|
19 | #include "config.h" |
---|
20 | #include "common.h" |
---|
21 | |
---|
22 | #if !defined(__KERNEL__) |
---|
23 | #endif |
---|
24 | |
---|
25 | #include "cucul.h" |
---|
26 | #include "cucul_internals.h" |
---|
27 | |
---|
28 | static uint32_t flipchar(uint32_t ch); |
---|
29 | static uint32_t flopchar(uint32_t ch); |
---|
30 | static uint32_t rotatechar(uint32_t ch); |
---|
31 | |
---|
32 | /** \brief Invert a canvas' colours. |
---|
33 | * |
---|
34 | * Invert a canvas' colours (black becomes white, red becomes cyan, etc.) |
---|
35 | * without changing the characters in it. |
---|
36 | * |
---|
37 | * This function never fails. |
---|
38 | * |
---|
39 | * \param cv The canvas to invert. |
---|
40 | * \return This function always returns 0. |
---|
41 | */ |
---|
42 | int cucul_invert(cucul_canvas_t *cv) |
---|
43 | { |
---|
44 | uint32_t *attrs = cv->attrs; |
---|
45 | unsigned int i; |
---|
46 | |
---|
47 | for(i = cv->height * cv->width; i--; ) |
---|
48 | { |
---|
49 | *attrs = *attrs ^ 0x000f000f; |
---|
50 | attrs++; |
---|
51 | } |
---|
52 | |
---|
53 | return 0; |
---|
54 | } |
---|
55 | |
---|
56 | /** \brief Flip a canvas horizontally. |
---|
57 | * |
---|
58 | * Flip a canvas horizontally, choosing characters that look like the |
---|
59 | * mirrored version wherever possible. Some characters will stay |
---|
60 | * unchanged by the process, but the operation is guaranteed to be |
---|
61 | * involutive: performing it again gives back the original canvas. |
---|
62 | * |
---|
63 | * This function never fails. |
---|
64 | * |
---|
65 | * \param cv The canvas to flip. |
---|
66 | * \return This function always returns 0. |
---|
67 | */ |
---|
68 | int cucul_flip(cucul_canvas_t *cv) |
---|
69 | { |
---|
70 | unsigned int y; |
---|
71 | |
---|
72 | for(y = 0; y < cv->height; y++) |
---|
73 | { |
---|
74 | uint32_t *cleft = cv->chars + y * cv->width; |
---|
75 | uint32_t *cright = cleft + cv->width - 1; |
---|
76 | uint32_t *aleft = cv->attrs + y * cv->width; |
---|
77 | uint32_t *aright = aleft + cv->width - 1; |
---|
78 | |
---|
79 | while(cleft < cright) |
---|
80 | { |
---|
81 | uint32_t ch; |
---|
82 | uint32_t attr; |
---|
83 | |
---|
84 | /* Swap attributes */ |
---|
85 | attr = *aright; |
---|
86 | *aright-- = *aleft; |
---|
87 | *aleft++ = attr; |
---|
88 | |
---|
89 | /* Swap characters */ |
---|
90 | ch = *cright; |
---|
91 | *cright-- = flipchar(*cleft); |
---|
92 | *cleft++ = flipchar(ch); |
---|
93 | } |
---|
94 | |
---|
95 | if(cleft == cright) |
---|
96 | *cleft = flipchar(*cleft); |
---|
97 | |
---|
98 | /* Fix fullwidth characters. Could it be done in one loop? */ |
---|
99 | cleft = cv->chars + y * cv->width; |
---|
100 | cright = cleft + cv->width - 1; |
---|
101 | for( ; cleft < cright; cleft++) |
---|
102 | { |
---|
103 | if(cleft[0] == CUCUL_MAGIC_FULLWIDTH) |
---|
104 | { |
---|
105 | cleft[0] = cleft[1]; |
---|
106 | cleft[1] = CUCUL_MAGIC_FULLWIDTH; |
---|
107 | cleft++; |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | return 0; |
---|
113 | } |
---|
114 | |
---|
115 | /** \brief Flip a canvas vertically. |
---|
116 | * |
---|
117 | * Flip a canvas vertically, choosing characters that look like the |
---|
118 | * mirrored version wherever possible. Some characters will stay |
---|
119 | * unchanged by the process, but the operation is guaranteed to be |
---|
120 | * involutive: performing it again gives back the original canvas. |
---|
121 | * |
---|
122 | * This function never fails. |
---|
123 | * |
---|
124 | * \param cv The canvas to flop. |
---|
125 | * \return This function always returns 0. |
---|
126 | */ |
---|
127 | int cucul_flop(cucul_canvas_t *cv) |
---|
128 | { |
---|
129 | unsigned int x; |
---|
130 | |
---|
131 | for(x = 0; x < cv->width; x++) |
---|
132 | { |
---|
133 | uint32_t *ctop = cv->chars + x; |
---|
134 | uint32_t *cbottom = ctop + cv->width * (cv->height - 1); |
---|
135 | uint32_t *atop = cv->attrs + x; |
---|
136 | uint32_t *abottom = atop + cv->width * (cv->height - 1); |
---|
137 | |
---|
138 | while(ctop < cbottom) |
---|
139 | { |
---|
140 | uint32_t ch; |
---|
141 | uint32_t attr; |
---|
142 | |
---|
143 | /* Swap attributes */ |
---|
144 | attr = *abottom; *abottom = *atop; *atop = attr; |
---|
145 | |
---|
146 | /* Swap characters */ |
---|
147 | ch = *cbottom; *cbottom = flopchar(*ctop); *ctop = flopchar(ch); |
---|
148 | |
---|
149 | ctop += cv->width; cbottom -= cv->width; |
---|
150 | atop += cv->width; abottom -= cv->width; |
---|
151 | } |
---|
152 | |
---|
153 | if(ctop == cbottom) |
---|
154 | *ctop = flopchar(*ctop); |
---|
155 | } |
---|
156 | |
---|
157 | return 0; |
---|
158 | } |
---|
159 | |
---|
160 | /** \brief Rotate a canvas. |
---|
161 | * |
---|
162 | * Apply a 180-degree transformation to a canvas, choosing characters |
---|
163 | * that look like the upside-down version wherever possible. Some |
---|
164 | * characters will stay unchanged by the process, but the operation is |
---|
165 | * guaranteed to be involutive: performing it again gives back the |
---|
166 | * original canvas. |
---|
167 | * |
---|
168 | * This function never fails. |
---|
169 | * |
---|
170 | * \param cv The canvas to rotate. |
---|
171 | * \return This function always returns 0. |
---|
172 | */ |
---|
173 | int cucul_rotate(cucul_canvas_t *cv) |
---|
174 | { |
---|
175 | uint32_t *cbegin = cv->chars; |
---|
176 | uint32_t *cend = cbegin + cv->width * cv->height - 1; |
---|
177 | uint32_t *abegin = cv->attrs; |
---|
178 | uint32_t *aend = abegin + cv->width * cv->height - 1; |
---|
179 | unsigned int y; |
---|
180 | |
---|
181 | while(cbegin < cend) |
---|
182 | { |
---|
183 | uint32_t ch; |
---|
184 | uint32_t attr; |
---|
185 | |
---|
186 | /* Swap attributes */ |
---|
187 | attr = *aend; *aend = *abegin; *abegin = attr; |
---|
188 | |
---|
189 | /* Swap characters */ |
---|
190 | ch = *cend; *cend = rotatechar(*cbegin); *cbegin = rotatechar(ch); |
---|
191 | |
---|
192 | cbegin++; cend--; abegin++; aend--; |
---|
193 | } |
---|
194 | |
---|
195 | if(cbegin == cend) |
---|
196 | *cbegin = rotatechar(*cbegin); |
---|
197 | |
---|
198 | /* Fix fullwidth characters. Could it be done in one loop? */ |
---|
199 | for(y = 0; y < cv->height; y++) |
---|
200 | { |
---|
201 | cbegin = cv->chars + y * cv->width; |
---|
202 | cend = cbegin + cv->width - 1; |
---|
203 | for( ; cbegin < cend; cbegin++) |
---|
204 | { |
---|
205 | if(cbegin[0] == CUCUL_MAGIC_FULLWIDTH) |
---|
206 | { |
---|
207 | cbegin[0] = cbegin[1]; |
---|
208 | cbegin[1] = CUCUL_MAGIC_FULLWIDTH; |
---|
209 | cbegin++; |
---|
210 | } |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | return 0; |
---|
215 | } |
---|
216 | |
---|
217 | /* FIXME: as the lookup tables grow bigger, use a log(n) lookup instead |
---|
218 | * of linear lookup. */ |
---|
219 | static uint32_t flipchar(uint32_t ch) |
---|
220 | { |
---|
221 | int i; |
---|
222 | |
---|
223 | static uint32_t const noflip[] = |
---|
224 | { |
---|
225 | /* ASCII */ |
---|
226 | ' ', '"', '#', '\'', '-', '.', '*', '+', ':', '=', '0', '8', |
---|
227 | 'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y', '^', |
---|
228 | '_', 'i', 'o', 'v', 'w', 'x', '|', |
---|
229 | /* CP437 and box drawing */ |
---|
230 | 0x2591, 0x2592, 0x2593, 0x2588, 0x2584, 0x2580, /* ░ ▒ ▓ █ ▄ ▀ */ |
---|
231 | 0x2500, 0x2501, 0x2503, 0x2503, 0x253c, 0x254b, /* ─ ━ │ ┃ ┼ ╋ */ |
---|
232 | 0x252c, 0x2534, 0x2533, 0x253b, 0x2566, 0x2569, /* ┬ ┴ ┳ ┻ ╦ ╩ */ |
---|
233 | 0x2550, 0x2551, 0x256c, /* ═ ║ ╬ */ |
---|
234 | 0x2575, 0x2577, 0x2579, 0x257b, /* ╵ ╷ ╹ ╻ */ |
---|
235 | 0 |
---|
236 | }; |
---|
237 | |
---|
238 | static uint32_t const pairs[] = |
---|
239 | { |
---|
240 | /* ASCII */ |
---|
241 | '(', ')', |
---|
242 | '/', '\\', |
---|
243 | '<', '>', |
---|
244 | '[', ']', |
---|
245 | 'b', 'd', |
---|
246 | 'p', 'q', |
---|
247 | '{', '}', |
---|
248 | /* ASCII-Unicode */ |
---|
249 | ';', 0x204f, /* ; ⁏ */ |
---|
250 | '`', 0x00b4, /* ` ´ */ |
---|
251 | ',', 0x02ce, /* , ˎ */ |
---|
252 | 'C', 0x03fd, /* C Ͻ */ |
---|
253 | 'E', 0x018e, /* E Ǝ */ |
---|
254 | 'L', 0x2143, /* L ⅃ */ |
---|
255 | 'N', 0x0418, /* N И */ |
---|
256 | 'R', 0x042f, /* R Я */ |
---|
257 | 'S', 0x01a7, /* S Ƨ */ |
---|
258 | 'c', 0x0254, /* c ɔ */ |
---|
259 | 'e', 0x0258, /* e ɘ */ |
---|
260 | /* CP437 */ |
---|
261 | 0x258c, 0x2590, /* ▌ ▐ */ |
---|
262 | 0x2596, 0x2597, /* ▖ ▗ */ |
---|
263 | 0x2598, 0x259d, /* ▘ ▝ */ |
---|
264 | 0x2599, 0x259f, /* ▙ ▟ */ |
---|
265 | 0x259a, 0x259e, /* ▚ ▞ */ |
---|
266 | 0x259b, 0x259c, /* ▛ ▜ */ |
---|
267 | 0x25ba, 0x25c4, /* ► ◄ */ |
---|
268 | 0x2192, 0x2190, /* → ← */ |
---|
269 | 0x2310, 0xac, /* ⌐ ¬ */ |
---|
270 | /* Box drawing */ |
---|
271 | 0x250c, 0x2510, /* ┌ ┐ */ |
---|
272 | 0x2514, 0x2518, /* └ ┘ */ |
---|
273 | 0x251c, 0x2524, /* ├ ┤ */ |
---|
274 | 0x250f, 0x2513, /* ┏ ┓ */ |
---|
275 | 0x2517, 0x251b, /* ┗ ┛ */ |
---|
276 | 0x2523, 0x252b, /* ┣ ┫ */ |
---|
277 | 0x2552, 0x2555, /* ╒ ╕ */ |
---|
278 | 0x2558, 0x255b, /* ╘ ╛ */ |
---|
279 | 0x2553, 0x2556, /* ╓ ╖ */ |
---|
280 | 0x2559, 0x255c, /* ╙ ╜ */ |
---|
281 | 0x2554, 0x2557, /* ╔ ╗ */ |
---|
282 | 0x255a, 0x255d, /* ╚ ╝ */ |
---|
283 | 0x255e, 0x2561, /* ╞ ╡ */ |
---|
284 | 0x255f, 0x2562, /* ╟ ╢ */ |
---|
285 | 0x2560, 0x2563, /* ╠ ╣ */ |
---|
286 | 0x2574, 0x2576, /* ╴ ╶ */ |
---|
287 | 0x2578, 0x257a, /* ╸ ╺ */ |
---|
288 | 0 |
---|
289 | }; |
---|
290 | |
---|
291 | for(i = 0; noflip[i]; i++) |
---|
292 | if(ch == noflip[i]) |
---|
293 | return ch; |
---|
294 | |
---|
295 | for(i = 0; pairs[i]; i++) |
---|
296 | if(ch == pairs[i]) |
---|
297 | return pairs[i ^ 1]; |
---|
298 | |
---|
299 | return ch; |
---|
300 | } |
---|
301 | |
---|
302 | static uint32_t flopchar(uint32_t ch) |
---|
303 | { |
---|
304 | int i; |
---|
305 | |
---|
306 | static uint32_t const noflop[] = |
---|
307 | { |
---|
308 | /* ASCII */ |
---|
309 | ' ', '(', ')', '*', '+', '-', '0', '3', '8', ':', '<', '=', |
---|
310 | '>', 'B', 'C', 'D', 'E', 'H', 'I', 'K', 'O', 'X', '[', ']', |
---|
311 | 'c', 'o', '{', '|', '}', |
---|
312 | /* CP437 and box drawing */ |
---|
313 | 0x2591, 0x2592, 0x2593, 0x2588, 0x258c, 0x2590, /* ░ ▒ ▓ █ ▌ ▐ */ |
---|
314 | 0x2500, 0x2501, 0x2503, 0x2503, 0x253c, 0x254b, /* ─ ━ │ ┃ ┼ ╋ */ |
---|
315 | 0x251c, 0x2524, 0x2523, 0x252b, 0x2560, 0x2563, /* ├ ┤ ┣ ┫ ╠ ╣ */ |
---|
316 | 0x2550, 0x2551, 0x256c, /* ═ ║ ╬ */ |
---|
317 | 0x2574, 0x2576, 0x2578, 0x257a, /* ╴ ╶ ╸ ╺ */ |
---|
318 | 0 |
---|
319 | }; |
---|
320 | |
---|
321 | static uint32_t const pairs[] = |
---|
322 | { |
---|
323 | /* ASCII */ |
---|
324 | '/', '\\', |
---|
325 | 'M', 'W', |
---|
326 | ',', '`', |
---|
327 | 'b', 'p', |
---|
328 | 'd', 'q', |
---|
329 | 'p', 'q', |
---|
330 | 'f', 't', |
---|
331 | '.', '\'', |
---|
332 | /* ASCII-Unicode */ |
---|
333 | '_', 0x203e, /* _ ‾ */ |
---|
334 | '!', 0x00a1, /* ! ¡ */ |
---|
335 | 'L', 0x0413, /* L Г */ |
---|
336 | 'N', 0x0418, /* N И */ |
---|
337 | 'P', 0x042c, /* P Ь */ |
---|
338 | 'R', 0x0281, /* R ʁ */ |
---|
339 | 'S', 0x01a7, /* S Ƨ */ |
---|
340 | 'U', 0x0548, /* U Ո */ |
---|
341 | 'V', 0x039b, /* V Λ */ |
---|
342 | 'Y', 0x2144, /* Y ⅄ */ |
---|
343 | 'h', 0x03bc, /* h μ */ |
---|
344 | 'i', 0x1d09, /* i ᴉ */ |
---|
345 | 'v', 0x028c, /* v ʌ */ |
---|
346 | 'w', 0x028d, /* w ʍ */ |
---|
347 | 'y', 0x03bb, /* y λ */ |
---|
348 | /* Not perfect, but better than nothing */ |
---|
349 | '"', 0x201e, /* " „ */ |
---|
350 | 'm', 0x026f, /* m ɯ */ |
---|
351 | 'n', 'u', |
---|
352 | /* CP437 */ |
---|
353 | 0x2584, 0x2580, /* ▄ ▀ */ |
---|
354 | 0x2596, 0x2598, /* ▖ ▘ */ |
---|
355 | 0x2597, 0x259d, /* ▗ ▝ */ |
---|
356 | 0x2599, 0x259b, /* ▙ ▛ */ |
---|
357 | 0x259f, 0x259c, /* ▟ ▜ */ |
---|
358 | 0x259a, 0x259e, /* ▚ ▞ */ |
---|
359 | /* Box drawing */ |
---|
360 | 0x250c, 0x2514, /* ┌ └ */ |
---|
361 | 0x2510, 0x2518, /* ┐ ┘ */ |
---|
362 | 0x252c, 0x2534, /* ┬ ┴ */ |
---|
363 | 0x250f, 0x2517, /* ┏ ┗ */ |
---|
364 | 0x2513, 0x251b, /* ┓ ┛ */ |
---|
365 | 0x2533, 0x253b, /* ┳ ┻ */ |
---|
366 | 0x2554, 0x255a, /* ╔ ╚ */ |
---|
367 | 0x2557, 0x255d, /* ╗ ╝ */ |
---|
368 | 0x2566, 0x2569, /* ╦ ╩ */ |
---|
369 | 0x2552, 0x2558, /* ╒ ╘ */ |
---|
370 | 0x2555, 0x255b, /* ╕ ╛ */ |
---|
371 | 0x2564, 0x2567, /* ╤ ╧ */ |
---|
372 | 0x2553, 0x2559, /* ╓ ╙ */ |
---|
373 | 0x2556, 0x255c, /* ╖ ╜ */ |
---|
374 | 0x2565, 0x2568, /* ╥ ╨ */ |
---|
375 | 0x2575, 0x2577, /* ╵ ╷ */ |
---|
376 | 0x2579, 0x257b, /* ╹ ╻ */ |
---|
377 | 0 |
---|
378 | }; |
---|
379 | |
---|
380 | for(i = 0; noflop[i]; i++) |
---|
381 | if(ch == noflop[i]) |
---|
382 | return ch; |
---|
383 | |
---|
384 | for(i = 0; pairs[i]; i++) |
---|
385 | if(ch == pairs[i]) |
---|
386 | return pairs[i ^ 1]; |
---|
387 | |
---|
388 | return ch; |
---|
389 | } |
---|
390 | |
---|
391 | static uint32_t rotatechar(uint32_t ch) |
---|
392 | { |
---|
393 | int i; |
---|
394 | |
---|
395 | static uint32_t const norotate[] = |
---|
396 | { |
---|
397 | /* ASCII */ |
---|
398 | ' ', '*', '+', '-', '/', '0', '8', ':', '=', 'H', 'I', 'N', |
---|
399 | 'O', 'S', 'X', 'Z', '\\', 'l', 'o', 's', 'x', 'z', '|', |
---|
400 | /* Unicode */ |
---|
401 | 0x2591, 0x2592, 0x2593, 0x2588, 0x259a, 0x259e, /* ░ ▒ ▓ █ ▚ ▞ */ |
---|
402 | 0x2500, 0x2501, 0x2503, 0x2503, 0x253c, 0x254b, /* ─ ━ │ ┃ ┼ ╋ */ |
---|
403 | 0x2550, 0x2551, 0x256c, /* ═ ║ ╬ */ |
---|
404 | 0 |
---|
405 | }; |
---|
406 | |
---|
407 | static uint32_t const pairs[] = |
---|
408 | { |
---|
409 | /* ASCII */ |
---|
410 | '(', ')', |
---|
411 | '<', '>', |
---|
412 | '[', ']', |
---|
413 | '{', '}', |
---|
414 | '.', '\'', |
---|
415 | '6', '9', |
---|
416 | 'M', 'W', |
---|
417 | 'b', 'q', |
---|
418 | 'd', 'p', |
---|
419 | 'n', 'u', |
---|
420 | /* ASCII-Unicode */ |
---|
421 | '_', 0x203e, /* _ ‾ */ |
---|
422 | ',', 0x00b4, /* , ´ */ |
---|
423 | '`', 0x02ce, /* ` ˎ */ |
---|
424 | '&', 0x214b, /* & ⅋ */ |
---|
425 | '!', 0x00a1, /* ! ¡ */ |
---|
426 | '?', 0x00bf, /* ? ¿ */ |
---|
427 | 'C', 0x03fd, /* C Ͻ */ |
---|
428 | 'E', 0x018e, /* E Ǝ */ |
---|
429 | 'F', 0x2132, /* F Ⅎ */ |
---|
430 | 'L', 0x2142, /* L ⅂ */ |
---|
431 | 'U', 0x0548, /* U Ո */ |
---|
432 | 'V', 0x039b, /* V Λ */ |
---|
433 | 'Y', 0x2144, /* Y ⅄ */ |
---|
434 | 'a', 0x0250, /* a ɐ */ |
---|
435 | 'c', 0x0254, /* c ɔ */ |
---|
436 | 'e', 0x0259, /* e ə */ |
---|
437 | 'f', 0x025f, /* f ɟ */ |
---|
438 | 'g', 0x1d77, /* g ᵷ */ |
---|
439 | 'h', 0x0265, /* h ɥ */ |
---|
440 | 'i', 0x1d09, /* i ᴉ */ |
---|
441 | 'k', 0x029e, /* k ʞ */ |
---|
442 | 'm', 0x026f, /* m ɯ */ |
---|
443 | 'r', 0x0279, /* r ɹ */ |
---|
444 | 't', 0x0287, /* t ʇ */ |
---|
445 | 'v', 0x028c, /* v ʌ */ |
---|
446 | 'w', 0x028d, /* w ʍ */ |
---|
447 | 'y', 0x028e, /* y ʎ */ |
---|
448 | /* Not perfect, but better than nothing */ |
---|
449 | '"', 0x201e, /* " „ */ |
---|
450 | /* Misc Unicode */ |
---|
451 | 0x00e6, 0x1d02, /* æ ᴂ */ |
---|
452 | 0x0153, 0x1d14, /* œ ᴔ */ |
---|
453 | /* CP437 */ |
---|
454 | 0x258c, 0x2590, /* ▌ ▐ */ |
---|
455 | 0x2584, 0x2580, /* ▄ ▀ */ |
---|
456 | 0x2596, 0x259d, /* ▖ ▝ */ |
---|
457 | 0x2597, 0x2598, /* ▗ ▘ */ |
---|
458 | 0x2599, 0x259c, /* ▙ ▜ */ |
---|
459 | 0x259f, 0x259b, /* ▟ ▛ */ |
---|
460 | /* Box drawing */ |
---|
461 | 0x250c, 0x2518, /* ┌ ┘ */ |
---|
462 | 0x2510, 0x2514, /* ┐ └ */ |
---|
463 | 0x251c, 0x2524, /* ├ ┤ */ |
---|
464 | 0x252c, 0x2534, /* ┬ ┴ */ |
---|
465 | 0x250f, 0x251b, /* ┏ ┛ */ |
---|
466 | 0x2513, 0x2517, /* ┓ ┗ */ |
---|
467 | 0x2523, 0x252b, /* ┣ ┫ */ |
---|
468 | 0x2533, 0x253b, /* ┳ ┻ */ |
---|
469 | 0x2554, 0x255d, /* ╔ ╝ */ |
---|
470 | 0x2557, 0x255a, /* ╗ ╚ */ |
---|
471 | 0x2560, 0x2563, /* ╠ ╣ */ |
---|
472 | 0x2566, 0x2569, /* ╦ ╩ */ |
---|
473 | 0x2552, 0x255b, /* ╒ ╛ */ |
---|
474 | 0x2555, 0x2558, /* ╕ ╘ */ |
---|
475 | 0x255e, 0x2561, /* ╞ ╡ */ |
---|
476 | 0x2564, 0x2567, /* ╤ ╧ */ |
---|
477 | 0x2553, 0x255c, /* ╓ ╜ */ |
---|
478 | 0x2556, 0x2559, /* ╖ ╙ */ |
---|
479 | 0x255f, 0x2562, /* ╟ ╢ */ |
---|
480 | 0x2565, 0x2568, /* ╥ ╨ */ |
---|
481 | 0x2574, 0x2576, /* ╴ ╶ */ |
---|
482 | 0x2575, 0x2577, /* ╵ ╷ */ |
---|
483 | 0x2578, 0x257a, /* ╸ ╺ */ |
---|
484 | 0x2579, 0x257b, /* ╹ ╻ */ |
---|
485 | 0 |
---|
486 | }; |
---|
487 | |
---|
488 | for(i = 0; norotate[i]; i++) |
---|
489 | if(ch == norotate[i]) |
---|
490 | return ch; |
---|
491 | |
---|
492 | for(i = 0; pairs[i]; i++) |
---|
493 | if(ch == pairs[i]) |
---|
494 | return pairs[i ^ 1]; |
---|
495 | |
---|
496 | return ch; |
---|
497 | } |
---|
498 | |
---|