1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

LibGUI: Display line number next to the first visual line

The number was previously vertically centered, but it prevents from
quickly seeing a line change.
This commit is contained in:
Lucas CHOLLET 2022-04-24 19:03:17 +02:00 committed by Andreas Kling
parent 4c027efc01
commit 86d4b7ebfc

View file

@ -466,6 +466,10 @@ void TextEditor::paint_event(PaintEvent& event)
for (size_t i = first_visible_line; i <= last_visible_line; ++i) {
bool is_current_line = i == m_cursor.line();
auto ruler_line_rect = ruler_content_rect(i);
// NOTE: Shrink the rectangle to be only on the first visual line.
auto const line_height = font().preferred_line_height();
if (ruler_line_rect.height() > line_height)
ruler_line_rect.set_height(line_height);
// NOTE: Use Painter::draw_text() directly here, as we want to always draw the line numbers in clear text.
painter.draw_text(
ruler_line_rect.shrunken(2, 0),