30,8 → 30,8 |
#define __SCREENBUFFER_H__ |
|
|
#define DEFAULT_FOREGROUND_COLOR 0xffffff |
#define DEFAULT_BACKGROUND_COLOR 0x00003f |
#define DEFAULT_FOREGROUND_COLOR 0xffffff /**< default console foreground color */ |
#define DEFAULT_BACKGROUND_COLOR 0x00003f /**< default console background color */ |
|
typedef struct { |
unsigned int bg_color; /**< background color */ |
38,7 → 38,7 |
unsigned int fg_color; /**< foreground color */ |
} style_t; |
|
/** One field at screen. It contain one character and its attributes. */ |
/** One field on screen. It contain one character and its attributes. */ |
typedef struct { |
char character; /**< Character itself */ |
style_t style; /**< Character`s attributes */ |
54,11 → 54,22 |
unsigned int top_line; /**< Points to buffer[][] line that will be printed at screen as the first line */ |
} screenbuffer_t; |
|
/** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line. |
* @param scr screenbuffer |
* @oaram x position on screen |
* @param y position on screen |
* @return keyfield structure with character and its attributes on x,y |
*/ |
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y) |
{ |
return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x; |
} |
|
/** Compares two styles. |
* @param s1 first style |
* @param s2 second style |
* @return nonzero on equality |
*/ |
static inline int style_same(style_t s1, style_t s2) |
{ |
return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color; |
65,7 → 76,7 |
} |
|
|
int screenbuffer_putchar(screenbuffer_t *scr, char c); |
void screenbuffer_putchar(screenbuffer_t *scr, char c); |
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y); |
|
void screenbuffer_clear(screenbuffer_t *scr); |
72,6 → 83,7 |
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line); |
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest); |
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y); |
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color); |
|
#endif |
|