feature (renderer): implemented cursor moving ascii extension
This commit is contained in:
parent
f2584f7754
commit
62bbc52205
|
@ -99,15 +99,6 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
|
|||
position_T pos = (position_T){x, y};
|
||||
uint64_t strlen = string_length(string);
|
||||
for (int i = 0; i < strlen; i++) {
|
||||
if (pos.x + g_renderer.font.width >= graphics_buffer->width) {
|
||||
pos.x = 0;
|
||||
pos.y += g_renderer.font.height;
|
||||
}
|
||||
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
|
||||
pos.y -= g_renderer.font.height;
|
||||
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
|
||||
}
|
||||
|
||||
switch (string[i]) {
|
||||
case '\n': {
|
||||
pos.x = 0;
|
||||
|
@ -129,8 +120,59 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
|
|||
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, ' ');
|
||||
break;
|
||||
}
|
||||
case 0x0F: {
|
||||
string_ext_header_T* header = (string_ext_header_T*)&string[i];
|
||||
switch (header->command) {
|
||||
case STRING_EXT_CMD_CURSOR_MOVE: {
|
||||
switch (header->data) {
|
||||
case 0: {
|
||||
if (pos.x >= g_renderer.font.width) {
|
||||
pos.x -= g_renderer.font.width;
|
||||
} else if (pos.y >= g_renderer.font.height) {
|
||||
pos.y -= g_renderer.font.height;
|
||||
pos.x = FLOOR_TO(graphics_buffer->width, g_renderer.font.width) - g_renderer.font.width;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (pos.x < FLOOR_TO(graphics_buffer->width, g_renderer.font.width) - g_renderer.font.width) {
|
||||
pos.x += g_renderer.font.width;
|
||||
} else if (pos.y < FLOOR_TO(graphics_buffer->height, g_renderer.font.height) - g_renderer.font.height) {
|
||||
pos.y += g_renderer.font.height;
|
||||
pos.x = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (pos.y >= g_renderer.font.height) {
|
||||
pos.y -= g_renderer.font.height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (pos.y < FLOOR_TO(graphics_buffer->height, g_renderer.font.height) - g_renderer.font.height) {
|
||||
pos.y += g_renderer.font.height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += STRING_EXT_SIZE(header->length);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
if (pos.x + g_renderer.font.width >= graphics_buffer->width) {
|
||||
pos.x = 0;
|
||||
pos.y += g_renderer.font.height;
|
||||
}
|
||||
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
|
||||
pos.y -= g_renderer.font.height;
|
||||
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
|
||||
}
|
||||
|
||||
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
|
||||
pos.x += g_renderer.font.width;
|
||||
break;
|
||||
|
|
|
@ -97,6 +97,9 @@ void ps2_keyboard_read() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tty_write(chr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (scancode == PS2_SCANCODE_SET_1_MODIFIER) {
|
||||
|
|
Loading…
Reference in New Issue