From 1b0086217cb45a9dea434a918bbdb04399e1753a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 23 Sep 2024 15:00:47 +0300 Subject: [PATCH] Terminal: Do scrolling in putchar if necessary I overlooked that handling *newline* scrolls would be enough. You can definitely scroll more if printing a lot of text which wraps to the next line. --- userspace/programs/Terminal/Terminal.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/userspace/programs/Terminal/Terminal.cpp b/userspace/programs/Terminal/Terminal.cpp index 6f5e313148..002dbe7cb5 100644 --- a/userspace/programs/Terminal/Terminal.cpp +++ b/userspace/programs/Terminal/Terminal.cpp @@ -518,8 +518,14 @@ Rectangle Terminal::putchar(uint8_t ch) m_cursor.y++; } - // scrolling is already handled in `read_shell()` - ASSERT(m_cursor.y < rows()); + if (m_cursor.y >= rows()) + { + const uint32_t scroll = m_cursor.y - rows() + 1; + m_cursor.y -= scroll; + m_window->shift_vertical(-scroll * (int32_t)m_font.height()); + m_window->fill_rect(0, m_window->height() - scroll * m_font.height(), m_window->width(), scroll * m_font.height(), m_bg_color); + should_invalidate = { 0, 0, m_window->width(), m_window->height() }; + } return should_invalidate; }