Ignore:
Timestamp:
Apr 18, 2006, 5:11:25 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Renamed caca_t into caca_display_t.
  • Renamed canvas handle variables from "c" to "cv". Eh ouais mon gros.
File:
1 edited

Legend:

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

    r810 r811  
    4747 *  character, use cucul_putstr() instead.
    4848 *
    49  *  \param c A handle to the libcucul canvas.
     49 *  \param cv A handle to the libcucul canvas.
    5050 *  \param x X coordinate.
    5151 *  \param y Y coordinate.
    5252 *  \param ch The character to print.
    5353 */
    54 void cucul_putchar(cucul_canvas_t *c, int x, int y, char ch)
    55 {
    56     if(x < 0 || x >= (int)c->width ||
    57        y < 0 || y >= (int)c->height)
     54void cucul_putchar(cucul_canvas_t *cv, int x, int y, char ch)
     55{
     56    if(x < 0 || x >= (int)cv->width ||
     57       y < 0 || y >= (int)cv->height)
    5858        return;
    5959
     
    6161        ch = 0x20;
    6262
    63     c->chars[x + y * c->width] = ch;
    64     c->attr[x + y * c->width] = (c->bgcolor << 16) | c->fgcolor;
     63    cv->chars[x + y * cv->width] = ch;
     64    cv->attr[x + y * cv->width] = (cv->bgcolor << 16) | cv->fgcolor;
    6565}
    6666
     
    7272 *  be cropped accordingly if it is too long.
    7373 *
    74  *  \param c A handle to the libcucul canvas.
     74 *  \param cv A handle to the libcucul canvas.
    7575 *  \param x X coordinate.
    7676 *  \param y Y coordinate.
    7777 *  \param s The string to print.
    7878 */
    79 void cucul_putstr(cucul_canvas_t *c, int x, int y, char const *s)
     79void cucul_putstr(cucul_canvas_t *cv, int x, int y, char const *s)
    8080{
    8181    uint32_t *chars, *attr;
    8282    unsigned int len;
    8383
    84     if(y < 0 || y >= (int)c->height || x >= (int)c->width)
     84    if(y < 0 || y >= (int)cv->height || x >= (int)cv->width)
    8585        return;
    8686
     
    9696    }
    9797
    98     chars = c->chars + x + y * c->width;
    99     attr = c->attr + x + y * c->width;
    100 
    101     if(x + len >= c->width)
    102         len = c->width - x;
     98    chars = cv->chars + x + y * cv->width;
     99    attr = cv->attr + x + y * cv->width;
     100
     101    if(x + len >= cv->width)
     102        len = cv->width - x;
    103103
    104104    while(len)
    105105    {
    106106        *chars++ = _cucul_utf8_to_utf32(s);
    107         *attr++ = (c->bgcolor << 16) | c->fgcolor;
     107        *attr++ = (cv->bgcolor << 16) | cv->fgcolor;
    108108
    109109        s = _cucul_skip_utf8(s, 1);
     
    120120 *  string is the same as for the C printf() function.
    121121 *
    122  *  \param c A handle to the libcucul canvas.
     122 *  \param cv A handle to the libcucul canvas.
    123123 *  \param x X coordinate.
    124124 *  \param y Y coordinate.
     
    126126 *  \param ... Arguments to the format string.
    127127 */
    128 void cucul_printf(cucul_canvas_t *c, int x, int y, char const *format, ...)
     128void cucul_printf(cucul_canvas_t *cv, int x, int y, char const *format, ...)
    129129{
    130130    char tmp[BUFSIZ];
     
    132132    va_list args;
    133133
    134     if(y < 0 || y >= (int)c->height || x >= (int)c->width)
    135         return;
    136 
    137     if(c->width - x + 1 > BUFSIZ)
    138         buf = malloc(c->width - x + 1);
     134    if(y < 0 || y >= (int)cv->height || x >= (int)cv->width)
     135        return;
     136
     137    if(cv->width - x + 1 > BUFSIZ)
     138        buf = malloc(cv->width - x + 1);
    139139
    140140    va_start(args, format);
    141141#if defined(HAVE_VSNPRINTF)
    142     vsnprintf(buf, c->width - x + 1, format, args);
     142    vsnprintf(buf, cv->width - x + 1, format, args);
    143143#else
    144144    vsprintf(buf, format, args);
    145145#endif
    146     buf[c->width - x] = '\0';
     146    buf[cv->width - x] = '\0';
    147147    va_end(args);
    148148
    149     cucul_putstr(c, x, y, buf);
     149    cucul_putstr(cv, x, y, buf);
    150150
    151151    if(buf != tmp)
     
    157157 *  This function clears the canvas using a black background.
    158158 */
    159 void cucul_clear(cucul_canvas_t *c)
    160 {
    161     uint16_t oldfg = c->fgcolor;
    162     uint16_t oldbg = c->bgcolor;
    163     int y = c->height;
    164 
    165     cucul_set_color(c, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
     159void cucul_clear(cucul_canvas_t *cv)
     160{
     161    uint16_t oldfg = cv->fgcolor;
     162    uint16_t oldbg = cv->bgcolor;
     163    int y = cv->height;
     164
     165    cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
    166166
    167167    /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */
    168168    while(y--)
    169         cucul_putstr(c, 0, y, c->empty_line);
    170 
    171     c->fgcolor = oldfg;
    172     c->bgcolor = oldbg;
     169        cucul_putstr(cv, 0, y, cv->empty_line);
     170
     171    cv->fgcolor = oldfg;
     172    cv->bgcolor = oldbg;
    173173}
    174174
     
    231231 */
    232232
    233 void _cucul_putchar32(cucul_canvas_t *c, int x, int y, uint32_t ch)
    234 {
    235     if(x < 0 || x >= (int)c->width ||
    236        y < 0 || y >= (int)c->height)
    237         return;
    238 
    239     c->chars[x + y * c->width] = ch;
    240     c->attr[x + y * c->width] = (c->bgcolor << 16) | c->fgcolor;
    241 }
    242 
     233void _cucul_putchar32(cucul_canvas_t *cv, int x, int y, uint32_t ch)
     234{
     235    if(x < 0 || x >= (int)cv->width ||
     236       y < 0 || y >= (int)cv->height)
     237        return;
     238
     239    cv->chars[x + y * cv->width] = ch;
     240    cv->attr[x + y * cv->width] = (cv->bgcolor << 16) | cv->fgcolor;
     241}
     242
Note: See TracChangeset for help on using the changeset viewer.