Переглянути джерело

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

tags/v0.99.beta17
Sam Hocevar sam 15 роки тому
джерело
коміт
6d526ea629
2 змінених файлів з 56 додано та 0 видалено
  1. +54
    -0
      caca/attr.c
  2. +2
    -0
      caca/caca.h

+ 54
- 0
caca/attr.c Переглянути файл

@@ -106,6 +106,60 @@ int caca_set_attr(caca_canvas_t *cv, uint32_t attr)
return 0;
}

/** \brief Unset flags in the default character attribute.
*
* Unset flags in the default character attribute for drawing. Attributes
* define foreground and background colour, transparency, bold, italics and
* underline styles, as well as blink. String functions such as
* caca_printf() and graphical primitive functions such as caca_draw_line()
* will use this attribute.
*
* The value of \e attr is a combination (bitwise OR) of style values
* (\e CACA_UNDERLINE, \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS).
* Unsetting these attributes does not modify the current colour information.
*
* To retrieve the current attribute value, use caca_get_attr(-1,-1).
*
* This function never fails.
*
* \param cv A handle to the libcaca canvas.
* \param attr The requested attribute values to unset.
* \return This function always returns 0.
*/
int caca_unset_attr(caca_canvas_t *cv, uint32_t attr)
{
cv->curattr &= ~(attr & 0x0000000f);

return 0;
}

/** \brief Toggle flags in the default character attribute.
*
* Toggle flags in the default character attribute for drawing. Attributes
* define foreground and background colour, transparency, bold, italics and
* underline styles, as well as blink. String functions such as
* caca_printf() and graphical primitive functions such as caca_draw_line()
* will use this attribute.
*
* The value of \e attr is a combination (bitwise OR) of style values
* (\e CACA_UNDERLINE, \e CACA_BLINK, \e CACA_BOLD and \e CACA_ITALICS).
* Toggling these attributes does not modify the current colour information.
*
* To retrieve the current attribute value, use caca_get_attr(-1,-1).
*
* This function never fails.
*
* \param cv A handle to the libcaca canvas.
* \param attr The requested attribute values to toggle.
* \return This function always returns 0.
*/
int caca_toggle_attr(caca_canvas_t *cv, uint32_t attr)
{
cv->curattr ^= attr & 0x0000000f;

return 0;
}

/** \brief Set the character attribute at the given coordinates.
*
* Set the character attribute, without changing the character's value. If


+ 2
- 0
caca/caca.h Переглянути файл

@@ -285,6 +285,8 @@ __extern int caca_stretch_right(caca_canvas_t *);
* @{ */
__extern uint32_t caca_get_attr(caca_canvas_t const *, int, int);
__extern int caca_set_attr(caca_canvas_t *, uint32_t);
__extern int caca_unset_attr(caca_canvas_t *, uint32_t);
__extern int caca_toggle_attr(caca_canvas_t *, uint32_t);
__extern int caca_put_attr(caca_canvas_t *, int, int, uint32_t);
__extern int caca_set_color_ansi(caca_canvas_t *, uint8_t, uint8_t);
__extern int caca_set_color_argb(caca_canvas_t *, uint16_t, uint16_t);


Завантаження…
Відмінити
Зберегти