Browse Source

* Slightly nicer code in driver_x11.c.

tags/v0.99.beta14
Sam Hocevar sam 17 years ago
parent
commit
9369bb3cb8
1 changed files with 26 additions and 30 deletions
  1. +26
    -30
      caca/driver_x11.c

+ 26
- 30
caca/driver_x11.c View File

@@ -549,6 +549,31 @@ static int x11_error_handler(Display *dpy, XErrorEvent *xevent)
static void x11_put_glyph(caca_display_t *dp, int x, int y, int yoff, static void x11_put_glyph(caca_display_t *dp, int x, int y, int yoff,
int w, int h, uint32_t attr, uint32_t ch) int w, int h, uint32_t attr, uint32_t ch)
{ {
static uint8_t const udlr[] =
{
/* 0x2500 - 0x250f: ─ . │ . . . . . . . . . ┌ . . . */
0x05, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
/* 0x2510 - 0x251f: ┐ . . . └ . . . ┘ . . . ├ . . . */
0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
0x44, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
/* 0x2520 - 0x252f: . . . . ┤ . . . . . . . ┬ . . . */
0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
/* 0x2530 - 0x253f: . . . . ┴ . . . . . . . ┼ . . . */
0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
/* 0x2540 - 0x254f: . . . . . . . . . . . . . . . . */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 0x2550 - 0x255f: ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ */
0x0a, 0xa0, 0x12, 0x21, 0x22, 0x18, 0x24, 0x28,
0x42, 0x81, 0x82, 0x48, 0x84, 0x88, 0x52, 0xa1,
/* 0x2560 - 0x256c: ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ */
0xa2, 0x58, 0xa4, 0xa8, 0x1a, 0x25, 0x2a, 0x4a,
0x85, 0x8a, 0x5a, 0xa5, 0xaa,
};

Display *dpy = dp->drv.p->dpy; Display *dpy = dp->drv.p->dpy;
Pixmap px = dp->drv.p->pixmap; Pixmap px = dp->drv.p->pixmap;
GC gc = dp->drv.p->gc; GC gc = dp->drv.p->gc;
@@ -574,38 +599,10 @@ static void x11_put_glyph(caca_display_t *dp, int x, int y, int yoff,
* such as the CP437 gradients and half blocks. For unknown * such as the CP437 gradients and half blocks. For unknown
* characters, print what cucul_utf32_to_ascii() returns. */ * characters, print what cucul_utf32_to_ascii() returns. */


if(ch >= 0x2500 && ch <= 0x256c)
if(ch >= 0x2500 && ch <= 0x256c && udlr[ch - 0x2500])
{ {
static uint8_t const udlr[] =
{
/* 0x2500 - 0x250f: ─ . │ . . . . . . . . . ┌ . . . */
0x05, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
/* 0x2510 - 0x251f: ┐ . . . └ . . . ┘ . . . ├ . . . */
0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
0x44, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
/* 0x2520 - 0x252f: . . . . ┤ . . . . . . . ┬ . . . */
0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
/* 0x2530 - 0x253f: . . . . ┴ . . . . . . . ┼ . . . */
0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
/* 0x2540 - 0x254f: . . . . . . . . . . . . . . . . */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 0x2550 - 0x255f: ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ */
0x0a, 0xa0, 0x12, 0x21, 0x22, 0x18, 0x24, 0x28,
0x42, 0x81, 0x82, 0x48, 0x84, 0x88, 0x52, 0xa1,
/* 0x2560 - 0x256c: ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ */
0xa2, 0x58, 0xa4, 0xa8, 0x1a, 0x25, 0x2a, 0x4a,
0x85, 0x8a, 0x5a, 0xa5, 0xaa,
};

uint16_t D = udlr[ch - 0x2500]; uint16_t D = udlr[ch - 0x2500];


if(!D)
goto next_try;

if(D & 0x04) if(D & 0x04)
XFillRectangle(dpy, px, gc, x, y + h / 2, fw / 2 + 1, 1); XFillRectangle(dpy, px, gc, x, y + h / 2, fw / 2 + 1, 1);


@@ -657,7 +654,6 @@ static void x11_put_glyph(caca_display_t *dp, int x, int y, int yoff,


return; return;
} }
next_try:


switch(ch) switch(ch)
{ {


Loading…
Cancel
Save