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.
This commit is contained in:
Bananymous 2024-09-23 15:00:47 +03:00
parent d395cf38b7
commit 1b0086217c
1 changed files with 8 additions and 2 deletions

View File

@ -518,8 +518,14 @@ Rectangle Terminal::putchar(uint8_t ch)
m_cursor.y++; m_cursor.y++;
} }
// scrolling is already handled in `read_shell()` if (m_cursor.y >= rows())
ASSERT(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; return should_invalidate;
} }