Ignore:
Timestamp:
Nov 25, 2007, 3:12:01 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Introduce cucul_get_canvas_chars() and cucul_get_canvas_attrs() to avoid direct cv->chars and cv->attrs access by display drivers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/driver_ncurses.c

    r2055 r2056  
    5252#endif
    5353
     54#include "cucul.h"
    5455#include "caca.h"
    5556#include "caca_internals.h"
    56 #include "cucul.h"
    57 #include "cucul_internals.h"
    5857
    5958/*
     
    332331{
    333332    /* Fallback to a 6x10 font */
    334     return dp->cv->width * 6;
     333    return cucul_get_canvas_width(dp->cv) * 6;
    335334}
    336335
     
    338337{
    339338    /* Fallback to a 6x10 font */
    340     return dp->cv->height * 10;
     339    return cucul_get_canvas_height(dp->cv) * 10;
    341340}
    342341
    343342static void ncurses_display(caca_display_t *dp)
    344343{
     344    uint32_t const *cvchars = (uint32_t const *)cucul_get_canvas_chars(dp->cv);
     345    uint32_t const *cvattrs = (uint32_t const *)cucul_get_canvas_attrs(dp->cv);
     346    unsigned int width = cucul_get_canvas_width(dp->cv);
     347    unsigned int height = cucul_get_canvas_height(dp->cv);
    345348    int x, y;
    346     uint32_t *attrs = dp->cv->attrs;
    347     uint32_t *chars = dp->cv->chars;
    348     for(y = 0; y < (int)dp->cv->height; y++)
     349
     350    for(y = 0; y < (int)height; y++)
    349351    {
    350352        move(y, 0);
    351         for(x = dp->cv->width; x--; )
     353        for(x = width; x--; )
    352354        {
    353             attrset(dp->drv.p->attr[cucul_attr_to_ansi(*attrs++)]);
    354             ncurses_write_utf32(*chars++);
     355            attrset(dp->drv.p->attr[cucul_attr_to_ansi(*cvattrs++)]);
     356            ncurses_write_utf32(*cvchars++);
    355357        }
    356358    }
     
    383385
    384386    /* Fallback */
    385     dp->resize.w = dp->cv->width;
    386     dp->resize.h = dp->cv->height;
     387    dp->resize.w = cucul_get_canvas_width(dp->cv);
     388    dp->resize.h = cucul_get_canvas_height(dp->cv);
    387389}
    388390
Note: See TracChangeset for help on using the changeset viewer.