Changeset 4145 for libcaca


Ignore:
Timestamp:
Dec 18, 2009, 10:36:15 PM (10 years ago)
Author:
Sam Hocevar
Message:

Implement caca_unset_attr() and caca_toggle_attr(). Fixes #7.

Location:
libcaca/trunk/caca
Files:
2 edited

Legend:

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

    r3583 r4145  
    103103
    104104    cv->curattr = attr;
     105
     106    return 0;
     107}
     108
     109/** \brief Unset flags in the default character attribute.
     110 *
     111 *  Unset flags in the default character attribute for drawing. Attributes
     112 *  define foreground and background colour, transparency, bold, italics and
     113 *  underline styles, as well as blink. String functions such as
     114 *  caca_printf() and graphical primitive functions such as caca_draw_line()
     115 *  will use this attribute.
     116 *
     117 *  The value of \e attr is a combination (bitwise OR) of style values
     118 *  (\e CACA_UNDERLINE, \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS).
     119 *  Unsetting these attributes does not modify the current colour information.
     120 *
     121 *  To retrieve the current attribute value, use caca_get_attr(-1,-1).
     122 *
     123 *  This function never fails.
     124 *
     125 *  \param cv A handle to the libcaca canvas.
     126 *  \param attr The requested attribute values to unset.
     127 *  \return This function always returns 0.
     128 */
     129int caca_unset_attr(caca_canvas_t *cv, uint32_t attr)
     130{
     131    cv->curattr &= ~(attr & 0x0000000f);
     132
     133    return 0;
     134}
     135
     136/** \brief Toggle flags in the default character attribute.
     137 *
     138 *  Toggle flags in the default character attribute for drawing. Attributes
     139 *  define foreground and background colour, transparency, bold, italics and
     140 *  underline styles, as well as blink. String functions such as
     141 *  caca_printf() and graphical primitive functions such as caca_draw_line()
     142 *  will use this attribute.
     143 *
     144 *  The value of \e attr is a combination (bitwise OR) of style values
     145 *  (\e CACA_UNDERLINE, \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS).
     146 *  Toggling these attributes does not modify the current colour information.
     147 *
     148 *  To retrieve the current attribute value, use caca_get_attr(-1,-1).
     149 *
     150 *  This function never fails.
     151 *
     152 *  \param cv A handle to the libcaca canvas.
     153 *  \param attr The requested attribute values to toggle.
     154 *  \return This function always returns 0.
     155 */
     156int caca_toggle_attr(caca_canvas_t *cv, uint32_t attr)
     157{
     158    cv->curattr ^= attr & 0x0000000f;
    105159
    106160    return 0;
  • libcaca/trunk/caca/caca.h

    r3926 r4145  
    286286__extern uint32_t caca_get_attr(caca_canvas_t const *, int, int);
    287287__extern int caca_set_attr(caca_canvas_t *, uint32_t);
     288__extern int caca_unset_attr(caca_canvas_t *, uint32_t);
     289__extern int caca_toggle_attr(caca_canvas_t *, uint32_t);
    288290__extern int caca_put_attr(caca_canvas_t *, int, int, uint32_t);
    289291__extern int caca_set_color_ansi(caca_canvas_t *, uint8_t, uint8_t);
Note: See TracChangeset for help on using the changeset viewer.