Changeset 958


Ignore:
Timestamp:
May 18, 2006, 8:23:47 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Changed cucul_putchar's prototype so that it accepts a 32-bit unsigned int which shall be used as an UTF-32 character. We do not have any casting problems due to the signedness of chars because all characters were ASCII (ie. <= 0x7f) beforehands.
Location:
libcaca/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/box.c

    r870 r958  
    8585    if(y1 >= 0)
    8686        for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
    87             _cucul_putchar32(cv, x, y1, (uint32_t)'-');
     87            cucul_putchar(cv, x, y1, '-');
    8888
    8989    if(y2 <= ymax)
    9090        for(x = x1 < 0 ? 1 : x1 + 1; x < x2 && x < xmax; x++)
    91             _cucul_putchar32(cv, x, y2, (uint32_t)'-');
     91            cucul_putchar(cv, x, y2, '-');
    9292
    9393    if(x1 >= 0)
    9494        for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
    95             _cucul_putchar32(cv, x1, y, (uint32_t)'|');
     95            cucul_putchar(cv, x1, y, '|');
    9696
    9797    if(x2 <= xmax)
    9898        for(y = y1 < 0 ? 1 : y1 + 1; y < y2 && y < ymax; y++)
    99             _cucul_putchar32(cv, x2, y, (uint32_t)'|');
     99            cucul_putchar(cv, x2, y, '|');
    100100
    101101    /* Draw corners */
    102102    if(x1 >= 0 && y1 >= 0)
    103         _cucul_putchar32(cv, x1, y1, (uint32_t)',');
     103        cucul_putchar(cv, x1, y1, ',');
    104104
    105105    if(x1 >= 0 && y2 <= ymax)
    106         _cucul_putchar32(cv, x1, y2, (uint32_t)'`');
     106        cucul_putchar(cv, x1, y2, '`');
    107107
    108108    if(x2 <= xmax && y1 >= 0)
    109         _cucul_putchar32(cv, x2, y1, (uint32_t)'.');
     109        cucul_putchar(cv, x2, y1, '.');
    110110
    111111    if(x2 <= xmax && y2 <= ymax)
    112         _cucul_putchar32(cv, x2, y2, (uint32_t)'\'');
     112        cucul_putchar(cv, x2, y2, '\'');
    113113
    114114    return 0;
     
    160160    for(y = y1; y <= y2; y++)
    161161        for(x = x1; x <= x2; x++)
    162             _cucul_putchar32(cv, x, y, ch);
     162            cucul_putchar(cv, x, y, ch);
    163163
    164164    return 0;
  • libcaca/trunk/cucul/canvas.c

    r874 r958  
    4242#include "cucul_internals.h"
    4343
    44 /** \brief Print an ASCII character.
    45  *
    46  *  This function prints an ASCII character at the given coordinates, using
    47  *  the default foreground and background values. If the coordinates are
    48  *  outside the canvas boundaries, nothing is printed. If the character
    49  *  value is a non-printable character or is outside the ASCII range, it is
    50  *  replaced with a space. To print a sequence of bytes forming an UTF-8
    51  *  character, use cucul_putstr() instead.
     44/** \brief Print an ASCII or Unicode character.
     45 *
     46 *  This function prints an ASCII or Unicode character at the given
     47 *  coordinates, using the default foreground and background values.
     48 *
     49 *  If the coordinates are outside the canvas boundaries, nothing is printed.
     50 *  If the character value is a non-printable character or is outside the
     51 *  UTF-32 range, it is replaced with a space. To print a sequence of bytes
     52 *  forming an UTF-8 character instead of an UTF-32 character, use the
     53 *  cucul_putstr() function instead.
    5254 *
    5355 *  This function never fails.
     
    5961 *  \return This function always returns 0.
    6062 */
    61 int cucul_putchar(cucul_canvas_t *cv, int x, int y, char ch)
     63int cucul_putchar(cucul_canvas_t *cv, int x, int y, unsigned long int ch)
    6264{
    6365    if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
    6466        return 0;
    6567
    66     if((unsigned char)ch < 0x20 || (unsigned char)ch > 0x7f)
     68    if((unsigned char)ch < 0x20)
    6769        ch = 0x20;
    6870
     
    261263}
    262264
    263 /*
    264  * XXX: The following functions are not exported
    265  */
    266 
    267 void _cucul_putchar32(cucul_canvas_t *cv, int x, int y, uint32_t ch)
    268 {
    269     if(x < 0 || x >= (int)cv->width ||
    270        y < 0 || y >= (int)cv->height)
    271         return;
    272 
    273     cv->chars[x + y * cv->width] = ch;
    274     cv->attr[x + y * cv->width] = (cv->bgcolor << 16) | cv->fgcolor;
    275 }
    276 
  • libcaca/trunk/cucul/conic.c

    r870 r958  
    249249
    250250    if((b & (0x1|0x4)) == (0x1|0x4))
    251         _cucul_putchar32(cv, xo + x, yo + y, ch);
     251        cucul_putchar(cv, xo + x, yo + y, ch);
    252252
    253253    if((b & (0x2|0x4)) == (0x2|0x4))
    254         _cucul_putchar32(cv, xo - x, yo + y, ch);
     254        cucul_putchar(cv, xo - x, yo + y, ch);
    255255
    256256    if((b & (0x1|0x8)) == (0x1|0x8))
    257         _cucul_putchar32(cv, xo + x, yo - y, ch);
     257        cucul_putchar(cv, xo + x, yo - y, ch);
    258258
    259259    if((b & (0x2|0x8)) == (0x2|0x8))
    260         _cucul_putchar32(cv, xo - x, yo - y, ch);
    261 }
    262 
     260        cucul_putchar(cv, xo - x, yo - y, ch);
     261}
     262
  • libcaca/trunk/cucul/cucul.h

    r938 r958  
    101101int cucul_set_truecolor(cucul_canvas_t *, unsigned int, unsigned int);
    102102char const *cucul_get_color_name(unsigned int);
    103 int cucul_putchar(cucul_canvas_t *, int, int, char);
     103int cucul_putchar(cucul_canvas_t *, int, int, unsigned long int);
    104104int cucul_putstr(cucul_canvas_t *, int, int, char const *);
    105105int cucul_printf(cucul_canvas_t *, int, int, char const *, ...);
  • libcaca/trunk/cucul/cucul_internals.h

    r927 r958  
    5353/* Canvas functions */
    5454extern int _cucul_set_canvas_size(cucul_canvas_t *, unsigned int, unsigned int);
    55 extern void _cucul_putchar32(cucul_canvas_t *, int, int, uint32_t);
    5655
    5756/* Charset functions */
  • libcaca/trunk/cucul/dither.c

    r953 r958  
    8484static int const rgb_weight[] =
    8585{
    86     //2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2
     86    /* 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2 */
    8787    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    8888};
     
    115115    COLOR_MODE_FULLGRAY,
    116116    COLOR_MODE_FULL8,
    117     COLOR_MODE_FULL16,
     117    COLOR_MODE_FULL16
    118118};
    119119
     
    10621062        /* Now output the character */
    10631063        cucul_set_color(cv, outfg, outbg);
    1064         _cucul_putchar32(cv, x, y, outch);
     1064        cucul_putchar(cv, x, y, outch);
    10651065
    10661066       d->increment_dither();
  • libcaca/trunk/cucul/import.c

    r954 r958  
    383383                    cucul_set_canvas_size(cv, width = 80, height);
    384384                for(j = x; j < 80; j++)
    385                     _cucul_putchar32(cv, j, y, (uint32_t)' ');
     385                    cucul_putchar(cv, j, y, ' ');
    386386                x = 80;
    387387                break;
     
    406406
    407407        /* Now paste our character */
    408         _cucul_putchar32(cv, x, y, _cucul_cp437_to_utf32(buffer[i]));
     408        cucul_putchar(cv, x, y, _cucul_cp437_to_utf32(buffer[i]));
    409409        x++;
    410410    }
  • libcaca/trunk/cucul/line.c

    r870 r958  
    261261        for(; dx>=0; dx--)
    262262        {
    263             _cucul_putchar32(cv, x1, y1, s->ch);
     263            cucul_putchar(cv, x1, y1, s->ch);
    264264            if(delta > 0)
    265265            {
     
    283283        for(; dy >= 0; dy--)
    284284        {
    285             _cucul_putchar32(cv, x1, y1, s->ch);
     285            cucul_putchar(cv, x1, y1, s->ch);
    286286            if(delta > 0)
    287287            {
     
    310310    if(s->x2 >= s->x1)
    311311    {
    312         charmapx[0] = (s->y1 > s->y2) ? (uint32_t)',' : (uint32_t)'`';
    313         charmapx[1] = (s->y1 > s->y2) ? (uint32_t)'\'' : (uint32_t)'.';
     312        charmapx[0] = (s->y1 > s->y2) ? ',' : '`';
     313        charmapx[1] = (s->y1 > s->y2) ? '\'' : '.';
    314314        x1 = s->x1; y1 = s->y1; x2 = s->x2; y2 = s->y2;
    315315    }
    316316    else
    317317    {
    318         charmapx[0] = (s->y1 > s->y2) ? (uint32_t)'`' : (uint32_t)'.';
    319         charmapx[1] = (s->y1 > s->y2) ? (uint32_t)',' : (uint32_t)'\'';
     318        charmapx[0] = (s->y1 > s->y2) ? '`' : '.';
     319        charmapx[1] = (s->y1 > s->y2) ? ',' : '\'';
    320320        x2 = s->x1; y2 = s->y1; x1 = s->x2; y1 = s->y2;
    321321    }
     
    326326    if(y1 > y2)
    327327    {
    328         charmapy[0] = (uint32_t)',';
    329         charmapy[1] = (uint32_t)'\'';
     328        charmapy[0] = ',';
     329        charmapy[1] = '\'';
    330330        yinc = -1;
    331331    }
     
    333333    {
    334334        yinc = 1;
    335         charmapy[0] = (uint32_t)'`';
    336         charmapy[1] = (uint32_t)'.';
     335        charmapy[0] = '`';
     336        charmapy[1] = '.';
    337337    }
    338338
     
    348348            if(delta > 0)
    349349            {
    350                 _cucul_putchar32(cv, x1, y1, charmapy[1]);
     350                cucul_putchar(cv, x1, y1, charmapy[1]);
    351351                x1++;
    352352                y1 += yinc;
     
    357357            {
    358358                if(prev)
    359                     _cucul_putchar32(cv, x1, y1, charmapy[0]);
     359                    cucul_putchar(cv, x1, y1, charmapy[0]);
    360360                else
    361                     _cucul_putchar32(cv, x1, y1, (uint32_t)'-');
     361                    cucul_putchar(cv, x1, y1, '-');
    362362                x1++;
    363363                delta += dpr;
     
    376376            if(delta > 0)
    377377            {
    378                 _cucul_putchar32(cv, x1, y1, charmapx[0]);
    379                 _cucul_putchar32(cv, x1 + 1, y1, charmapx[1]);
     378                cucul_putchar(cv, x1, y1, charmapx[0]);
     379                cucul_putchar(cv, x1 + 1, y1, charmapx[1]);
    380380                x1++;
    381381                y1 += yinc;
     
    384384            else
    385385            {
    386                 _cucul_putchar32(cv, x1, y1, (uint32_t)'|');
     386                cucul_putchar(cv, x1, y1, '|');
    387387                y1 += yinc;
    388388                delta += dpr;
  • libcaca/trunk/cucul/triangle.c

    r870 r958  
    142142
    143143        for(x = xa; x <= xb; x++)
    144             _cucul_putchar32(cv, x, y, ch);
     144            cucul_putchar(cv, x, y, ch);
    145145    }
    146146
  • libcaca/trunk/test/font2tga.c

    r957 r958  
    6868        for(j = blocklist[i]; j < blocklist[i + 1]; j++)
    6969        {
    70             _cucul_putchar32(cv, x, y, j);
     70            cucul_putchar(cv, x, y, j);
    7171
    7272            if(++x == WIDTH)
Note: See TracChangeset for help on using the changeset viewer.