Subversion Repositories HelenOS-historic

Rev

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

Rev 1497 Rev 1525
Line 28... Line 28...
28
 
28
 
29
#include <screenbuffer.h>
29
#include <screenbuffer.h>
30
#include <malloc.h>
30
#include <malloc.h>
31
#include <unistd.h>
31
#include <unistd.h>
32
 
32
 
33
/** Get field from buffer that corresponds to character at position x,y at screen
33
/** Store one character to screenbuffer. Its position is determined by scr->position_x and scr->position_y.
34
 *
34
 * @param scr   screenbuffer
-
 
35
 * @param c stored character
35
 */
36
 */
36
 
-
 
37
int screenbuffer_putchar(screenbuffer_t *scr, char c)
37
void screenbuffer_putchar(screenbuffer_t *scr, char c)
38
{
38
{
39
    keyfield_t *field;
39
    keyfield_t *field;
40
   
40
   
41
    field = get_field_at(scr, scr->position_x, scr->position_y);
41
    field = get_field_at(scr, scr->position_x, scr->position_y);
42
 
42
 
43
    field->character = c;
43
    field->character = c;
44
    field->style = scr->style;
44
    field->style = scr->style;
45
   
-
 
46
    return 1;
-
 
47
}
45
}
48
 
46
 
-
 
47
/** Initilize screenbuffer. Allocate space for screen content in accordance to given size.
-
 
48
 * @param scr       initialized screenbuffer
-
 
49
 * @param size_x   
-
 
50
 * @param size_y
-
 
51
 */
49
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y)
52
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y)
50
{
53
{
51
    if ((scr->buffer = (keyfield_t *)malloc(sizeof(keyfield_t) * size_x * size_y)) == NULL) {
54
    if ((scr->buffer = (keyfield_t *)malloc(sizeof(keyfield_t) * size_x * size_y)) == NULL) {
52
        return NULL;
55
        return NULL;
53
    }
56
    }
Line 100... Line 103...
100
}
103
}
101
 
104
 
102
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y)
105
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y)
103
{
106
{
104
    scr->position_x = x % scr->size_x;
107
    scr->position_x = x % scr->size_x;
105
    scr->position_y = y  % scr->size_y;
108
    scr->position_y = y % scr->size_y;
-
 
109
}
-
 
110
 
-
 
111
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color)
-
 
112
{
-
 
113
    scr->style.fg_color = fg_color;
-
 
114
    scr->style.bg_color = bg_color;
106
}
115
}
107
 
116