1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

Terminal: Don't compute buffer positions outside the possible area.

This commit is contained in:
Andreas Kling 2019-06-23 15:34:36 +02:00
parent 5aefd7f828
commit cf0d05d54a

View file

@ -1185,6 +1185,14 @@ BufferPosition Terminal::buffer_position_at(const Point& position) const
auto adjusted_position = position.translated(-(frame_thickness() + m_inset), -(frame_thickness() + m_inset));
int row = adjusted_position.y() / m_line_height;
int column = adjusted_position.x() / font().glyph_width('x');
if (row < 0)
row = 0;
if (column < m_columns)
column = 0;
if (row >= m_rows)
row = m_rows - 1;
if (column >= m_columns)
column = m_columns - 1;
return { row, column };
}