Changeset 9805cde in mainline for uspace/srv/console/screenbuffer.h


Ignore:
Timestamp:
2009-01-01T13:31:23Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7122bc7
Parents:
666773c
Message:

Console color support overhaul. Create C library console interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/console/screenbuffer.h

    r666773c r9805cde  
    4242
    4343typedef struct {
     44        uint8_t style;
     45} attr_style_t;
     46
     47typedef struct {
     48        uint8_t fg_color;
     49        uint8_t bg_color;
     50        uint8_t flags;
     51} attr_idx_t;
     52
     53typedef struct {
    4454        uint32_t bg_color;      /**< background color */
    4555        uint32_t fg_color;      /**< foreground color */
    46 } style_t;
     56} attr_rgb_t;
     57
     58typedef struct {
     59        enum {
     60                at_style,
     61                at_idx,
     62                at_rgb
     63        } t;
     64        union {
     65                attr_style_t s;
     66                attr_idx_t i;
     67                attr_rgb_t r;
     68        } a;
     69} attrs_t;
    4770
    4871/** One field on screen. It contain one character and its attributes. */
    4972typedef struct {
    5073        char character;                 /**< Character itself */
    51         style_t style;                  /**< Character`s attributes */
     74        attrs_t attrs;                  /**< Character`s attributes */
    5275} keyfield_t;
    5376
     
    5578 */
    5679typedef struct {
    57         keyfield_t *buffer;                     /**< Screen content - characters and its style. Used as cyclyc buffer. */
     80        keyfield_t *buffer;                     /**< Screen content - characters and their attributes. Used as a circular buffer. */
    5881        unsigned int size_x, size_y;            /**< Number of columns and rows */
    5982        unsigned int position_x, position_y;    /**< Coordinates of last printed character for determining cursor position */
    60         style_t style;                          /**< Current style */
     83        attrs_t attrs;                          /**< Current attributes. */
    6184        unsigned int top_line;                  /**< Points to buffer[][] line that will be printed at screen as the first line */
    6285        unsigned char is_cursor_visible;        /**< Cursor state - default is visible */
     
    7497}
    7598
    76 /** Compares two styles.
     99/** Compares two sets of attributes.
    77100 * @param s1 first style
    78101 * @param s2 second style
    79102 * @return nonzero on equality
    80103 */
    81 static inline int style_same(style_t s1, style_t s2)
     104static inline int attrs_same(attrs_t a1, attrs_t a2)
    82105{
    83         return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color;
     106        if (a1.t != a2.t) return 0;
     107
     108        switch (a1.t) {
     109        case at_style: return a1.a.s.style == a2.a.s.style;
     110        case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color &&
     111            a1.a.i.bg_color == a2.a.i.bg_color &&
     112            a1.a.i.flags == a2.a.i.flags;
     113        case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color &&
     114            a1.a.r.bg_color == a2.a.r.bg_color;
     115        }
    84116}
    85117
     
    92124void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
    93125void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y);
    94 void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color);
     126void screenbuffer_set_style(screenbuffer_t *scr, int style);
     127void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color,
     128    unsigned int bg_color, unsigned int attr);
     129void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color,
     130    unsigned int bg_color);
    95131
    96132#endif
Note: See TracChangeset for help on using the changeset viewer.