Rev 2787 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2787 | Rev 4377 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 31 | */ |
31 | */ |
| 32 | /** @file |
32 | /** @file |
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| 35 | #include <screenbuffer.h> |
35 | #include <screenbuffer.h> |
| - | 36 | #include <console/style.h> |
|
| 36 | #include <malloc.h> |
37 | #include <malloc.h> |
| 37 | #include <unistd.h> |
38 | #include <unistd.h> |
| 38 | 39 | ||
| 39 | /** Store one character to screenbuffer. Its position is determined by |
40 | /** Store one character to screenbuffer. Its position is determined by |
| 40 | * scr->position_x and scr->position_y. |
41 | * scr->position_x and scr->position_y. |
| 41 | * |
42 | * |
| 42 | * @param scr screenbuffer |
43 | * @param scr screenbuffer |
| 43 | * @param c stored character |
44 | * @param c stored character |
| 44 | */ |
45 | */ |
| 45 | void screenbuffer_putchar(screenbuffer_t *scr, char c) |
46 | void screenbuffer_putchar(screenbuffer_t *scr, wchar_t ch) |
| 46 | { |
47 | { |
| 47 | keyfield_t *field; |
48 | keyfield_t *field; |
| 48 | 49 | ||
| 49 | field = get_field_at(scr, scr->position_x, scr->position_y); |
50 | field = get_field_at(scr, scr->position_x, scr->position_y); |
| 50 | 51 | ||
| 51 | field->character = c; |
52 | field->character = ch; |
| 52 | field->style = scr->style; |
53 | field->attrs = scr->attrs; |
| 53 | } |
54 | } |
| 54 | 55 | ||
| 55 | /** Initilize screenbuffer. Allocate space for screen content in accordance to given size. |
56 | /** Initilize screenbuffer. Allocate space for screen content in accordance to given size. |
| 56 | * @param scr initialized screenbuffer |
57 | * @param scr initialized screenbuffer |
| 57 | * @param size_x width in characters |
58 | * @param size_x width in characters |
| Line 65... | Line 66... | ||
| 65 | return NULL; |
66 | return NULL; |
| 66 | } |
67 | } |
| 67 | 68 | ||
| 68 | scr->size_x = size_x; |
69 | scr->size_x = size_x; |
| 69 | scr->size_y = size_y; |
70 | scr->size_y = size_y; |
| 70 | scr->style.fg_color = DEFAULT_FOREGROUND; |
71 | scr->attrs.t = at_style; |
| 71 | scr->style.bg_color = DEFAULT_BACKGROUND; |
72 | scr->attrs.a.s.style = STYLE_NORMAL; |
| 72 | scr->is_cursor_visible = 1; |
73 | scr->is_cursor_visible = 1; |
| 73 | 74 | ||
| 74 | screenbuffer_clear(scr); |
75 | screenbuffer_clear(scr); |
| 75 | 76 | ||
| 76 | return scr; |
77 | return scr; |
| Line 83... | Line 84... | ||
| 83 | { |
84 | { |
| 84 | unsigned int i; |
85 | unsigned int i; |
| 85 | 86 | ||
| 86 | for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
87 | for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
| 87 | scr->buffer[i].character = ' '; |
88 | scr->buffer[i].character = ' '; |
| 88 | scr->buffer[i].style = scr->style; |
89 | scr->buffer[i].attrs = scr->attrs; |
| 89 | } |
90 | } |
| 90 | 91 | ||
| 91 | scr->top_line = 0; |
92 | scr->top_line = 0; |
| 92 | scr->position_y = 0; |
93 | scr->position_y = 0; |
| 93 | scr->position_x = 0; |
94 | scr->position_x = 0; |
| Line 101... | Line 102... | ||
| 101 | { |
102 | { |
| 102 | unsigned int i; |
103 | unsigned int i; |
| 103 | 104 | ||
| 104 | for (i = 0; i < scr->size_x; i++) { |
105 | for (i = 0; i < scr->size_x; i++) { |
| 105 | scr->buffer[i + line * scr->size_x].character = ' '; |
106 | scr->buffer[i + line * scr->size_x].character = ' '; |
| 106 | scr->buffer[i + line * scr->size_x].style = scr->style; |
107 | scr->buffer[i + line * scr->size_x].attrs = scr->attrs; |
| 107 | } |
108 | } |
| 108 | } |
109 | } |
| 109 | 110 | ||
| 110 | /** Copy content buffer from screenbuffer to given memory. |
111 | /** Copy content buffer from screenbuffer to given memory. |
| 111 | * @param scr source screenbuffer |
112 | * @param scr source screenbuffer |
| Line 134... | Line 135... | ||
| 134 | /** Set new style. |
135 | /** Set new style. |
| 135 | * @param scr |
136 | * @param scr |
| 136 | * @param fg_color |
137 | * @param fg_color |
| 137 | * @param bg_color |
138 | * @param bg_color |
| 138 | */ |
139 | */ |
| - | 140 | void screenbuffer_set_style(screenbuffer_t *scr, int style) |
|
| - | 141 | { |
|
| - | 142 | scr->attrs.t = at_style; |
|
| - | 143 | scr->attrs.a.s.style = style; |
|
| - | 144 | } |
|
| - | 145 | ||
| - | 146 | /** Set new color. |
|
| - | 147 | * @param scr |
|
| - | 148 | * @param fg_color |
|
| - | 149 | * @param bg_color |
|
| - | 150 | */ |
|
| - | 151 | void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color, unsigned int flags) |
|
| - | 152 | { |
|
| - | 153 | scr->attrs.t = at_idx; |
|
| - | 154 | scr->attrs.a.i.fg_color = fg_color; |
|
| - | 155 | scr->attrs.a.i.bg_color = bg_color; |
|
| - | 156 | scr->attrs.a.i.flags = flags; |
|
| - | 157 | } |
|
| - | 158 | ||
| - | 159 | /** Set new RGB color. |
|
| - | 160 | * @param scr |
|
| - | 161 | * @param fg_color |
|
| - | 162 | * @param bg_color |
|
| - | 163 | */ |
|
| 139 | void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
164 | void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
| 140 | { |
165 | { |
| - | 166 | scr->attrs.t = at_rgb; |
|
| 141 | scr->style.fg_color = fg_color; |
167 | scr->attrs.a.r.fg_color = fg_color; |
| 142 | scr->style.bg_color = bg_color; |
168 | scr->attrs.a.r.bg_color = bg_color; |
| 143 | } |
169 | } |
| 144 | 170 | ||
| 145 | 171 | ||
| 146 | /** @} |
172 | /** @} |
| 147 | */ |
173 | */ |