Changeset 1601f3c in mainline for uspace/srv/console/screenbuffer.h


Ignore:
Timestamp:
2009-05-21T15:32:42Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d158097
Parents:
a095d20
Message:

console cleanup (no functional changes)

File:
1 edited

Legend:

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

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef __SCREENBUFFER_H__
    36 #define __SCREENBUFFER_H__
     35#ifndef SCREENBUFFER_H__
     36#define SCREENBUFFER_H__
    3737
    3838#include <stdint.h>
    3939#include <sys/types.h>
    4040
    41 #define DEFAULT_FOREGROUND 0x0  /**< default console foreground color */
    42 #define DEFAULT_BACKGROUND 0xf0f0f0     /**< default console background color */
     41#define DEFAULT_FOREGROUND 0x0       /**< default console foreground color */
     42#define DEFAULT_BACKGROUND 0xf0f0f0  /**< default console background color */
    4343
    4444typedef struct {
     
    5353
    5454typedef struct {
    55         uint32_t bg_color;      /**< background color */
    56         uint32_t fg_color;      /**< foreground color */
     55        uint32_t bg_color;  /**< background color */
     56        uint32_t fg_color;  /**< foreground color */
    5757} attr_rgb_t;
    5858
     
    6767                attr_idx_t i;
    6868                attr_rgb_t r;
    69         } a; 
     69        } a;
    7070} attrs_t;
    7171
    7272/** One field on screen. It contain one character and its attributes. */
    7373typedef struct {
    74         wchar_t character;              /**< Character itself */
    75         attrs_t attrs;                  /**< Character`s attributes */
     74        wchar_t character;  /**< Character itself */
     75        attrs_t attrs;      /**< Character`s attributes */
    7676} keyfield_t;
    7777
     
    7979 */
    8080typedef struct {
    81         keyfield_t *buffer;                     /**< Screen content - characters and their attributes. Used as a circular buffer. */
    82         unsigned int size_x, size_y;            /**< Number of columns and rows */
    83         unsigned int position_x, position_y;    /**< Coordinates of last printed character for determining cursor position */
    84         attrs_t attrs;                          /**< Current attributes. */
    85         unsigned int top_line;                  /**< Points to buffer[][] line that will be printed at screen as the first line */
    86         unsigned char is_cursor_visible;        /**< Cursor state - default is visible */
     81        keyfield_t *buffer;               /**< Screen content - characters and
     82                                               their attributes (used as a circular buffer) */
     83        unsigned int size_x;              /**< Number of columns  */
     84        unsigned int size_y;              /**< Number of rows */
     85       
     86        /** Coordinates of last printed character for determining cursor position */
     87        unsigned int position_x;
     88        unsigned int position_y;
     89       
     90        attrs_t attrs;                    /**< Current attributes. */
     91        unsigned int top_line;            /**< Points to buffer[][] line that will
     92                                               be printed at screen as the first line */
     93        unsigned char is_cursor_visible;  /**< Cursor state - default is visible */
    8794} screenbuffer_t;
    8895
    89 /** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line.
    90  * @param scr   screenbuffer
    91  * @param x     position on screen
    92  * @param y     position on screen
    93  * @return      keyfield structure with character and its attributes on x,y
     96/** Returns keyfield for position on screen
     97 *
     98 * Screenbuffer->buffer is cyclic buffer so we
     99 * must couted in index of the topmost line.
     100 *
     101 * @param scr Screenbuffer
     102 * @param x   Position on screen
     103 * @param y   Position on screen
     104 *
     105 * @return Keyfield structure with character and its attributes on x, y
     106 *
    94107 */
    95108static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
     
    99112
    100113/** Compares two sets of attributes.
    101  * @param s1 first style
    102  * @param s2 second style
    103  * @return nonzero on equality
     114 *
     115 * @param s1 First style
     116 * @param s2 Second style
     117 *
     118 * @return Nonzero on equality
     119 *
    104120 */
    105121static inline int attrs_same(attrs_t a1, attrs_t a2)
    106122{
    107         if (a1.t != a2.t) return 0;
    108 
     123        if (a1.t != a2.t)
     124                return 0;
     125       
    109126        switch (a1.t) {
    110         case at_style: return a1.a.s.style == a2.a.s.style;
    111         case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color &&
    112             a1.a.i.bg_color == a2.a.i.bg_color &&
    113             a1.a.i.flags == a2.a.i.flags;
    114         case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color &&
    115             a1.a.r.bg_color == a2.a.r.bg_color;
     127        case at_style:
     128                return (a1.a.s.style == a2.a.s.style);
     129        case at_idx:
     130                return (a1.a.i.fg_color == a2.a.i.fg_color)
     131                    && (a1.a.i.bg_color == a2.a.i.bg_color)
     132                    && (a1.a.i.flags == a2.a.i.flags);
     133        case at_rgb:
     134                return (a1.a.r.fg_color == a2.a.r.fg_color)
     135                    && (a1.a.r.bg_color == a2.a.r.bg_color);
    116136        }
    117137}
     
    133153#endif
    134154
    135  
    136155/** @}
    137156 */
    138 
Note: See TracChangeset for help on using the changeset viewer.