feature (TTY): implemented a cursor
This commit is contained in:
parent
ee90b275b2
commit
99cd492570
|
@ -45,6 +45,7 @@ typedef struct {
|
||||||
graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer);
|
graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer);
|
||||||
void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
|
void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
|
||||||
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
|
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
|
||||||
|
void graphics_buffer_move (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);
|
||||||
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
|
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
|
||||||
void graphics_buffer_shift_up (graphics_buffer_T* graphics_buffer, uint16_t shift);
|
void graphics_buffer_shift_up (graphics_buffer_T* graphics_buffer, uint16_t shift);
|
||||||
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
|
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
|
||||||
|
|
|
@ -11,6 +11,7 @@ typedef struct {
|
||||||
graphics_buffer_T* graphics_buffer;
|
graphics_buffer_T* graphics_buffer;
|
||||||
pipe_T* output;
|
pipe_T* output;
|
||||||
pipe_T input;
|
pipe_T input;
|
||||||
|
graphics_buffer_T* cursor_overlay;
|
||||||
position_T cursor;
|
position_T cursor;
|
||||||
color_argb_T color;
|
color_argb_T color;
|
||||||
} tty_T;
|
} tty_T;
|
||||||
|
|
|
@ -39,6 +39,11 @@ void graphics_buffer_hide (graphics_buffer_T* graphics_buffer) {
|
||||||
graphics_buffer->render = false;
|
graphics_buffer->render = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void graphics_buffer_move(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y) {
|
||||||
|
graphics_buffer->pos_x = x;
|
||||||
|
graphics_buffer->pos_y = y;
|
||||||
|
}
|
||||||
|
|
||||||
void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) {
|
void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) {
|
||||||
if (graphics_buffer->prev != NULL) {
|
if (graphics_buffer->prev != NULL) {
|
||||||
graphics_buffer->prev->next = graphics_buffer->next;
|
graphics_buffer->prev->next = graphics_buffer->next;
|
||||||
|
|
|
@ -9,11 +9,14 @@ tty_T* g_tty;
|
||||||
void tty_init() {
|
void tty_init() {
|
||||||
g_tty = memory_allocate(sizeof(tty_T));
|
g_tty = memory_allocate(sizeof(tty_T));
|
||||||
g_tty->graphics_buffer = graphics_buffer_request(0, 0, graphics_renderer_get_width(), graphics_renderer_get_height(), GRAPHICS_BUFFER_STANDARD);
|
g_tty->graphics_buffer = graphics_buffer_request(0, 0, graphics_renderer_get_width(), graphics_renderer_get_height(), GRAPHICS_BUFFER_STANDARD);
|
||||||
|
g_tty->cursor_overlay = graphics_buffer_request(0, 0, 8, 16, GRAPHICS_BUFFER_OVERLAY);
|
||||||
g_tty->cursor.x = 0;
|
g_tty->cursor.x = 0;
|
||||||
g_tty->cursor.y = 0;
|
g_tty->cursor.y = 0;
|
||||||
g_tty->color = g_color_palette[COLOR_PAL_GREY_LIGHT];
|
g_tty->color = g_color_palette[COLOR_PAL_GREY_LIGHT];
|
||||||
g_tty->output = NULL;
|
g_tty->output = NULL;
|
||||||
pipe_init(&g_tty->input, NULL, tty_update);
|
pipe_init(&g_tty->input, NULL, tty_update);
|
||||||
|
|
||||||
|
graphics_buffer_draw_char(g_tty->cursor_overlay, 0, 0, g_color_palette[COLOR_PAL_GREY_DARK], '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_update() {
|
void tty_update() {
|
||||||
|
@ -25,6 +28,8 @@ void tty_update() {
|
||||||
g_tty->cursor = graphics_buffer_draw_string(g_tty->graphics_buffer, g_tty->cursor.x, g_tty->cursor.y, g_tty->color, buffer);
|
g_tty->cursor = graphics_buffer_draw_string(g_tty->graphics_buffer, g_tty->cursor.x, g_tty->cursor.y, g_tty->color, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
graphics_buffer_move(g_tty->cursor_overlay, g_tty->cursor.x, g_tty->cursor.y);
|
||||||
|
|
||||||
graphics_renderer_update();
|
graphics_renderer_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,5 +37,6 @@ uint32_t tty_write(string_t string) {
|
||||||
pipe_write(g_tty->output, string, string_length(string));
|
pipe_write(g_tty->output, string, string_length(string));
|
||||||
|
|
||||||
g_tty->cursor = graphics_buffer_draw_string(g_tty->graphics_buffer, g_tty->cursor.x, g_tty->cursor.y, g_tty->color, string);
|
g_tty->cursor = graphics_buffer_draw_string(g_tty->graphics_buffer, g_tty->cursor.x, g_tty->cursor.y, g_tty->color, string);
|
||||||
|
graphics_buffer_move(g_tty->cursor_overlay, g_tty->cursor.x, g_tty->cursor.y);
|
||||||
graphics_renderer_update();
|
graphics_renderer_update();
|
||||||
}
|
}
|
Loading…
Reference in New Issue