Subversion Repositories HelenOS-historic

Rev

Rev 1509 | Rev 1575 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1509 Rev 1525
Line 28... Line 28...
28
 
28
 
29
#ifndef __SCREENBUFFER_H__
29
#ifndef __SCREENBUFFER_H__
30
#define __SCREENBUFFER_H__
30
#define __SCREENBUFFER_H__
31
 
31
 
32
 
32
 
33
#define DEFAULT_FOREGROUND_COLOR 0xffffff
33
#define DEFAULT_FOREGROUND_COLOR 0xffffff   /**< default console foreground color */
34
#define DEFAULT_BACKGROUND_COLOR 0x00003f
34
#define DEFAULT_BACKGROUND_COLOR 0x00003f   /**< default console background color */
35
 
35
 
36
typedef struct {
36
typedef struct {
37
    unsigned int bg_color;      /**< background color */
37
    unsigned int bg_color;      /**< background color */
38
    unsigned int fg_color;      /**< foreground color */
38
    unsigned int fg_color;      /**< foreground color */
39
} style_t;
39
} style_t;
40
 
40
 
41
/** One field at screen. It contain one character and its attributes. */
41
/** One field on screen. It contain one character and its attributes. */
42
typedef struct {
42
typedef struct {
43
    char character;         /**< Character itself */
43
    char character;         /**< Character itself */
44
    style_t style;          /**< Character`s attributes */
44
    style_t style;          /**< Character`s attributes */
45
} keyfield_t;
45
} keyfield_t;
46
 
46
 
Line 52... Line 52...
52
    unsigned int position_x, position_y;    /**< Coordinates of last printed character for determining cursor position */
52
    unsigned int position_x, position_y;    /**< Coordinates of last printed character for determining cursor position */
53
    style_t style;              /**< Current style */
53
    style_t style;              /**< Current style */
54
    unsigned int top_line;          /**< Points to buffer[][] line that will be printed at screen as the first line */
54
    unsigned int top_line;          /**< Points to buffer[][] line that will be printed at screen as the first line */
55
} screenbuffer_t;
55
} screenbuffer_t;
56
 
56
 
-
 
57
/** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line.
-
 
58
 * @param scr   screenbuffer
-
 
59
 * @oaram x position on screen
-
 
60
 * @param y position on screen
-
 
61
 * @return  keyfield structure with character and its attributes on x,y
-
 
62
 */
57
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
63
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
58
{
64
{
59
    return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
65
    return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
60
}
66
}
61
 
67
 
-
 
68
/** Compares two styles.
-
 
69
 * @param s1 first style
-
 
70
 * @param s2 second style
-
 
71
 * @return nonzero on equality
-
 
72
 */
62
static inline int style_same(style_t s1, style_t s2)
73
static inline int style_same(style_t s1, style_t s2)
63
{
74
{
64
    return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color;
75
    return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color;
65
}
76
}
66
 
77
 
67
 
78
 
68
int screenbuffer_putchar(screenbuffer_t *scr, char c);
79
void screenbuffer_putchar(screenbuffer_t *scr, char c);
69
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y);
80
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y);
70
 
81
 
71
void screenbuffer_clear(screenbuffer_t *scr);
82
void screenbuffer_clear(screenbuffer_t *scr);
72
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line);
83
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line);
73
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
84
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
74
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y);
85
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y);
-
 
86
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color);
75
 
87
 
76
#endif
88
#endif
77
 
89