diff --git a/kernel/kernel/Shell.cpp b/kernel/kernel/Shell.cpp index be87003147..a95bcee31d 100644 --- a/kernel/kernel/Shell.cpp +++ b/kernel/kernel/Shell.cpp @@ -606,7 +606,7 @@ argument_done: } } - TTY_PRINT("\e[{}G", m_prompt_length + m_cursor_pos.col + 1); + TTY_PRINT("\e[{}G", (m_prompt_length + m_cursor_pos.col) % m_tty->width() + 1); } } \ No newline at end of file diff --git a/kernel/kernel/TTY.cpp b/kernel/kernel/TTY.cpp index 1fdb899f3d..41eaf069ee 100644 --- a/kernel/kernel/TTY.cpp +++ b/kernel/kernel/TTY.cpp @@ -55,6 +55,28 @@ void TTY::set_cursor_position(uint32_t x, uint32_t y) void TTY::set_font(const Kernel::Font& font) { m_terminal_driver->set_font(font); + + uint32_t new_width = m_terminal_driver->width(); + uint32_t new_height = m_terminal_driver->height(); + + if (m_width != new_width || m_height != new_height) + { + Cell* new_buffer = new Cell[new_width * new_height]; + ASSERT(new_buffer); + + for (uint32_t i = 0; i < new_width * m_height; i++) + new_buffer[i] = { .foreground = m_foreground, .background = m_background, .character = ' ' }; + + for (uint32_t y = 0; y < BAN::Math::min(m_height, new_height); y++) + for (uint32_t x = 0; x < BAN::Math::min(m_width, new_width); x++) + new_buffer[y * new_width + x] = m_buffer[y * m_width + x]; + + delete[] m_buffer; + m_buffer = new_buffer; + m_width = new_width; + m_height = new_height; + } + for (uint32_t y = 0; y < m_height; y++) for (uint32_t x = 0; x < m_width; x++) render_from_buffer(x, y);