feature (renderer): implemented cursor moving ascii extension

This commit is contained in:
antifallobst 2023-05-04 11:30:28 +02:00
parent f2584f7754
commit 62bbc52205
2 changed files with 54 additions and 9 deletions

View File

@ -99,15 +99,6 @@ position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint3
position_T pos = (position_T){x, y}; position_T pos = (position_T){x, y};
uint64_t strlen = string_length(string); uint64_t strlen = string_length(string);
for (int i = 0; i < strlen; i++) { 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]) { switch (string[i]) {
case '\n': { case '\n': {
pos.x = 0; 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, ' '); graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, ' ');
break; 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: { 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]); graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
pos.x += g_renderer.font.width; pos.x += g_renderer.font.width;
break; break;

View File

@ -97,6 +97,9 @@ void ps2_keyboard_read() {
return; return;
} }
} }
tty_write(chr);
return;
} }
if (scancode == PS2_SCANCODE_SET_1_MODIFIER) { if (scancode == PS2_SCANCODE_SET_1_MODIFIER) {