Subversion Repositories HelenOS

Rev

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

Rev 4439 Rev 4537
Line 35... Line 35...
35
#ifndef SCREENBUFFER_H__
35
#ifndef SCREENBUFFER_H__
36
#define SCREENBUFFER_H__
36
#define SCREENBUFFER_H__
37
 
37
 
38
#include <stdint.h>
38
#include <stdint.h>
39
#include <sys/types.h>
39
#include <sys/types.h>
-
 
40
#include <bool.h>
40
 
41
 
41
#define DEFAULT_FOREGROUND 0x0       /**< default console foreground color */
42
#define DEFAULT_FOREGROUND  0x0       /**< default console foreground color */
42
#define DEFAULT_BACKGROUND 0xf0f0f0  /**< default console background color */
43
#define DEFAULT_BACKGROUND  0xf0f0f0  /**< default console background color */
43
 
44
 
44
typedef struct {
45
typedef struct {
45
    uint8_t style;
46
    uint8_t style;
46
} attr_style_t;
47
} attr_style_t;
47
 
48
 
Line 70... Line 71...
70
} attrs_t;
71
} attrs_t;
71
 
72
 
72
/** One field on screen. It contain one character and its attributes. */
73
/** One field on screen. It contain one character and its attributes. */
73
typedef struct {
74
typedef struct {
74
    wchar_t character;  /**< Character itself */
75
    wchar_t character;  /**< Character itself */
75
    attrs_t attrs;      /**< Character`s attributes */
76
    attrs_t attrs;      /**< Character attributes */
76
} keyfield_t;
77
} keyfield_t;
77
 
78
 
78
/** Structure for buffering state of one virtual console.
79
/** Structure for buffering state of one virtual console.
79
 */
80
 */
80
typedef struct {
81
typedef struct {
81
    keyfield_t *buffer;               /**< Screen content - characters and
82
    keyfield_t *buffer;      /**< Screen content - characters and
82
                                           their attributes (used as a circular buffer) */
83
                                  their attributes (used as a circular buffer) */
83
    unsigned int size_x;              /**< Number of columns  */
84
    size_t size_x;           /**< Number of columns  */
84
    unsigned int size_y;              /**< Number of rows */
85
    size_t size_y;           /**< Number of rows */
85
   
86
   
86
    /** Coordinates of last printed character for determining cursor position */
87
    /** Coordinates of last printed character for determining cursor position */
87
    unsigned int position_x;
88
    size_t position_x;
88
    unsigned int position_y;
89
    size_t position_y;
89
   
90
   
90
    attrs_t attrs;                    /**< Current attributes. */
91
    attrs_t attrs;           /**< Current attributes. */
91
    unsigned int top_line;            /**< Points to buffer[][] line that will
92
    size_t top_line;         /**< Points to buffer[][] line that will
92
                                           be printed at screen as the first line */
93
                                  be printed at screen as the first line */
93
    unsigned char is_cursor_visible;  /**< Cursor state - default is visible */
94
    bool is_cursor_visible;  /**< Cursor state - default is visible */
94
} screenbuffer_t;
95
} screenbuffer_t;
95
 
96
 
96
/** Returns keyfield for position on screen
97
/** Returns keyfield for position on screen
97
 *
98
 *
98
 * Screenbuffer->buffer is cyclic buffer so we
99
 * Screenbuffer->buffer is cyclic buffer so we
Line 103... Line 104...
103
 * @param y   Position on screen
104
 * @param y   Position on screen
104
 *
105
 *
105
 * @return Keyfield structure with character and its attributes on x, y
106
 * @return Keyfield structure with character and its attributes on x, y
106
 *
107
 *
107
 */
108
 */
108
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
109
static inline keyfield_t *get_field_at(screenbuffer_t *scr, size_t x, size_t y)
109
{
110
{
110
    return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
111
    return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
111
}
112
}
112
 
113
 
113
/** Compares two sets of attributes.
114
/** Compares two sets of attributes.
Line 136... Line 137...
136
    }
137
    }
137
}
138
}
138
 
139
 
139
 
140
 
140
void screenbuffer_putchar(screenbuffer_t *scr, wchar_t c);
141
void screenbuffer_putchar(screenbuffer_t *scr, wchar_t c);
141
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y);
142
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, size_t size_x, size_t size_y);
142
 
143
 
143
void screenbuffer_clear(screenbuffer_t *scr);
144
void screenbuffer_clear(screenbuffer_t *scr);
144
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line);
145
void screenbuffer_clear_line(screenbuffer_t *scr, size_t line);
145
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
146
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
146
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y);
147
void screenbuffer_goto(screenbuffer_t *scr, size_t x, size_t y);
147
void screenbuffer_set_style(screenbuffer_t *scr, int style);
148
void screenbuffer_set_style(screenbuffer_t *scr, uint8_t style);
148
void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color,
149
void screenbuffer_set_color(screenbuffer_t *scr, uint8_t fg_color,
149
    unsigned int bg_color, unsigned int attr);
150
    uint8_t bg_color, uint8_t attr);
150
void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color,
151
void screenbuffer_set_rgb_color(screenbuffer_t *scr, uint32_t fg_color,
151
    unsigned int bg_color);
152
    uint32_t bg_color);
152
 
153
 
153
#endif
154
#endif
154
 
155
 
155
/** @}
156
/** @}
156
 */
157
 */