Pārlūkot izejas kodu

* Get rid of _cucul_attr_to_ansi4[fb]g() and replace all calls with

the now official cucul_attr_to_ansi_[fb]g().
tags/v0.99.beta14
Sam Hocevar sam pirms 18 gadiem
vecāks
revīzija
25d0366fe6
4 mainītis faili ar 27 papildinājumiem un 38 dzēšanām
  1. +8
    -2
      caca/driver_slang.c
  2. +4
    -3
      caca/driver_win32.c
  3. +0
    -20
      cucul/attr.c
  4. +15
    -13
      cucul/export.c

+ 8
- 2
caca/driver_slang.c Parādīt failu

@@ -217,8 +217,14 @@ static void slang_display(caca_display_t *dp)
* here for, and in cases where SLang does not render
* bright backgrounds, it's just fucked up. */
#if 0
uint8_t fgcolor = _cucul_attr_to_ansi4fg(*attrs);
uint8_t bgcolor = _cucul_attr_to_ansi4bg(*attrs);
uint8_t fgcolor = cucul_attr_to_ansi_fg(*attrs);
uint8_t bgcolor = cucul_attr_to_ansi_bg(*attrs);

if(fgcolor >= 0x10)
fgcolor = CUCUL_LIGHTGRAY;

if(bgcolor >= 0x10)
bgcolor = CUCUL_BLACK; /* FIXME: handle transparency */

if(fgcolor == bgcolor)
{


+ 4
- 3
caca/driver_win32.c Parādīt failu

@@ -198,6 +198,8 @@ static void win32_display(caca_display_t *dp)
for(n = dp->cv->height * dp->cv->width; n--; )
{
uint32_t ch = *chars++;
uint8_t fg = cucul_attr_to_ansi_fg(*attrs);
uint8_t bg = cucul_attr_to_ansi_bg(*attrs);

#if 0
if(ch > 0x00000020 && ch < 0x00000080)
@@ -213,9 +215,8 @@ static void win32_display(caca_display_t *dp)
buffer->Char.UnicodeChar = (uint16_t)' ';
#endif

buffer->Attributes =
win32_fg_palette[_cucul_attr_to_ansi4fg(*attrs)]
| win32_bg_palette[_cucul_attr_to_ansi4bg(*attrs)];
buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CUCUL_LIGHTGRAY]
| win32_bg_palette[bg < 0x10 ? bg : CUCUL_BLACK];
attrs++;
buffer++;
}


+ 0
- 20
cucul/attr.c Parādīt failu

@@ -350,26 +350,6 @@ uint8_t _cucul_attr_to_ansi8(uint32_t attr)
return fg | (bg << 4);
}

uint8_t _cucul_attr_to_ansi4fg(uint32_t attr)
{
uint8_t c = nearest_ansi((attr >> 4) & 0x3fff);

if(c == CUCUL_DEFAULT || c == CUCUL_TRANSPARENT)
return CUCUL_LIGHTGRAY;

return c;
}

uint8_t _cucul_attr_to_ansi4bg(uint32_t attr)
{
uint8_t c = nearest_ansi(attr >> 18);

if(c == CUCUL_DEFAULT || c == CUCUL_TRANSPARENT)
return CUCUL_BLACK;

return c;
}

uint16_t _cucul_attr_to_rgb12fg(uint32_t attr)
{
uint16_t fg = (attr >> 4) & 0x3fff;


+ 15
- 13
cucul/export.c Parādīt failu

@@ -288,15 +288,16 @@ static void *export_utf8(cucul_canvas_t *cv, unsigned long int *bytes, int cr)
{
uint32_t attr = lineattr[x];
uint32_t ch = linechar[x];
uint8_t fg, bg;
uint8_t ansifg, ansibg, fg, bg;

if(ch == CUCUL_MAGIC_FULLWIDTH)
continue;

fg = (((attr >> 4) & 0x3fff) == (CUCUL_DEFAULT | 0x40)) ?
0x10 : palette[_cucul_attr_to_ansi4fg(attr)];
bg = (((attr >> 18) & 0x3fff) == (CUCUL_TRANSPARENT | 0x40)) ?
0x10 : palette[_cucul_attr_to_ansi4bg(attr)];
ansifg = cucul_attr_to_ansi_fg(attr);
ansibg = cucul_attr_to_ansi_bg(attr);

fg = ansifg < 0x10 ? palette[ansifg] : 0x10;
bg = ansibg < 0x10 ? palette[ansibg] : 0x10;

/* TODO: the [0 could be omitted in some cases */
if(fg != prevfg || bg != prevbg)
@@ -363,8 +364,10 @@ static void *export_ansi(cucul_canvas_t *cv, unsigned long int *bytes)

for(x = 0; x < cv->width; x++)
{
uint8_t fg = palette[_cucul_attr_to_ansi4fg(lineattr[x])];
uint8_t bg = palette[_cucul_attr_to_ansi4bg(lineattr[x])];
uint8_t ansifg = cucul_attr_to_ansi_fg(lineattr[x]);
uint8_t ansibg = cucul_attr_to_ansi_bg(lineattr[x]);
uint8_t fg = ansifg < 0x10 ? palette[ansifg] : CUCUL_LIGHTGRAY;
uint8_t bg = ansibg < 0x10 ? palette[ansibg] : CUCUL_BLACK;
uint32_t ch = linechar[x];

if(ch == CUCUL_MAGIC_FULLWIDTH)
@@ -614,18 +617,17 @@ static void *export_irc(cucul_canvas_t *cv, unsigned long int *bytes)
for(x = 0; x < cv->width; x++)
{
uint32_t attr = lineattr[x];
uint8_t fg = palette[_cucul_attr_to_ansi4fg(attr)];
uint8_t bg = palette[_cucul_attr_to_ansi4bg(attr)];
uint32_t ch = linechar[x];
uint8_t ansifg, ansibg, fg, bg;

if(ch == CUCUL_MAGIC_FULLWIDTH)
continue;

if(((attr >> 4) & 0x3fff) == (CUCUL_DEFAULT | 0x40))
fg = 0x10;
ansifg = cucul_attr_to_ansi_fg(attr);
ansibg = cucul_attr_to_ansi_bg(attr);

if(((attr >> 18) & 0x3fff) == (CUCUL_TRANSPARENT | 0x40))
bg = 0x10;
fg = ansifg < 0x10 ? palette[ansifg] : 0x10;
bg = ansibg < 0x10 ? palette[ansibg] : 0x10;

/* TODO: optimise series of same fg / same bg
* don't change fg value if ch == ' '


Notiek ielāde…
Atcelt
Saglabāt