From 62bbc522055a5c5a680b55846922ae9418dae83b Mon Sep 17 00:00:00 2001 From: antifallobst Date: Thu, 4 May 2023 11:30:28 +0200 Subject: [PATCH] feature (renderer): implemented cursor moving ascii extension --- src/drivers/graphics/renderer.c | 60 ++++++++++++++++++++++++++++----- src/drivers/ps2/keyboard.c | 3 ++ 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/drivers/graphics/renderer.c b/src/drivers/graphics/renderer.c index e335aaf..1297304 100644 --- a/src/drivers/graphics/renderer.c +++ b/src/drivers/graphics/renderer.c @@ -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; diff --git a/src/drivers/ps2/keyboard.c b/src/drivers/ps2/keyboard.c index 00cf96e..16c17ce 100644 --- a/src/drivers/ps2/keyboard.c +++ b/src/drivers/ps2/keyboard.c @@ -97,6 +97,9 @@ void ps2_keyboard_read() { return; } } + + tty_write(chr); + return; } if (scancode == PS2_SCANCODE_SET_1_MODIFIER) {