Rev 1525 | Rev 1553 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1525 | Rev 1526 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | field->style = scr->style; |
44 | field->style = scr->style; |
45 | } |
45 | } |
46 | 46 | ||
47 | /** Initilize screenbuffer. Allocate space for screen content in accordance to given size. |
47 | /** Initilize screenbuffer. Allocate space for screen content in accordance to given size. |
48 | * @param scr initialized screenbuffer |
48 | * @param scr initialized screenbuffer |
49 | * @param size_x |
49 | * @param size_x width in characters |
50 | * @param size_y |
50 | * @param size_y height in characters |
- | 51 | * @return pointer to screenbuffer (same as scr parameter) or NULL |
|
51 | */ |
52 | */ |
52 | screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) |
53 | screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) |
53 | { |
54 | { |
54 | if ((scr->buffer = (keyfield_t *)malloc(sizeof(keyfield_t) * size_x * size_y)) == NULL) { |
55 | if ((scr->buffer = (keyfield_t *)malloc(sizeof(keyfield_t) * size_x * size_y)) == NULL) { |
55 | return NULL; |
56 | return NULL; |
Line 63... | Line 64... | ||
63 | screenbuffer_clear(scr); |
64 | screenbuffer_clear(scr); |
64 | 65 | ||
65 | return scr; |
66 | return scr; |
66 | } |
67 | } |
67 | 68 | ||
- | 69 | /** Clear screenbuffer. |
|
- | 70 | * @param scr screenbuffer |
|
- | 71 | */ |
|
68 | void screenbuffer_clear(screenbuffer_t *scr) |
72 | void screenbuffer_clear(screenbuffer_t *scr) |
69 | { |
73 | { |
70 | unsigned int i; |
74 | unsigned int i; |
71 | 75 | ||
72 | for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
76 | for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
Line 77... | Line 81... | ||
77 | scr->top_line = 0; |
81 | scr->top_line = 0; |
78 | scr->position_y = 0; |
82 | scr->position_y = 0; |
79 | scr->position_x = 0; |
83 | scr->position_x = 0; |
80 | } |
84 | } |
81 | 85 | ||
82 | /** Clear one buffer line |
86 | /** Clear one buffer line. |
83 | * @param scr |
87 | * @param scr |
84 | * @param line One buffer line (not a screen line!) |
88 | * @param line One buffer line (not a screen line!) |
85 | */ |
89 | */ |
86 | void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line) |
90 | void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line) |
87 | { |
91 | { |
Line 91... | Line 95... | ||
91 | scr->buffer[i + line*scr->size_x].character = ' '; |
95 | scr->buffer[i + line*scr->size_x].character = ' '; |
92 | scr->buffer[i + line*scr->size_x].style = scr->style; |
96 | scr->buffer[i + line*scr->size_x].style = scr->style; |
93 | } |
97 | } |
94 | } |
98 | } |
95 | 99 | ||
- | 100 | /** Copy content buffer from screenbuffer to given memory. |
|
- | 101 | * @param scr source screenbuffer |
|
- | 102 | * @param dest destination |
|
- | 103 | */ |
|
96 | void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest) |
104 | void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest) |
97 | { |
105 | { |
98 | unsigned int i; |
106 | unsigned int i; |
99 | 107 | ||
100 | for (i = 0; i < scr->size_x * scr->size_y; i++) { |
108 | for (i = 0; i < scr->size_x * scr->size_y; i++) { |
101 | dest[i] = scr->buffer[i]; |
109 | dest[i] = scr->buffer[i]; |
102 | } |
110 | } |
103 | } |
111 | } |
104 | 112 | ||
- | 113 | /** Set new cursor position in screenbuffer. |
|
- | 114 | * @param scr |
|
- | 115 | * @param x |
|
- | 116 | * @param y |
|
- | 117 | */ |
|
105 | void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) |
118 | void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) |
106 | { |
119 | { |
107 | scr->position_x = x % scr->size_x; |
120 | scr->position_x = x % scr->size_x; |
108 | scr->position_y = y % scr->size_y; |
121 | scr->position_y = y % scr->size_y; |
109 | } |
122 | } |
110 | 123 | ||
- | 124 | /** Set new style. |
|
- | 125 | * @param scr |
|
- | 126 | * @param fg_color |
|
- | 127 | * @param bg_color |
|
- | 128 | */ |
|
111 | void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
129 | void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color) |
112 | { |
130 | { |
113 | scr->style.fg_color = fg_color; |
131 | scr->style.fg_color = fg_color; |
114 | scr->style.bg_color = bg_color; |
132 | scr->style.bg_color = bg_color; |
115 | } |
133 | } |