Jelajahi Sumber

TextEditor: Let's have line numbers starting at 1.

Thanks to Dan for pointing this out on IRC:

<danboid> I see TextEditor still numbers its lines from 0. You're too much of a programmer sometimes kling! :)
<  kling> that might be the most extreme form of "programmer design" I've seen in serenity
Andreas Kling 6 tahun lalu
induk
melakukan
b98c77229d

+ 1 - 1
Applications/TextEditor/TextEditorWidget.cpp

@@ -25,7 +25,7 @@ TextEditorWidget::TextEditorWidget()
 
 
     m_editor->on_cursor_change = [statusbar, this] {
     m_editor->on_cursor_change = [statusbar, this] {
         StringBuilder builder;
         StringBuilder builder;
-        builder.appendf("Line: %d, Column: %d", m_editor->cursor().line(), m_editor->cursor().column());
+        builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
         statusbar->set_text(builder.to_string());
         statusbar->set_text(builder.to_string());
     };
     };
 
 

+ 1 - 1
Libraries/LibGUI/GTextEditor.cpp

@@ -292,7 +292,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
             auto ruler_line_rect = ruler_content_rect(i);
             auto ruler_line_rect = ruler_content_rect(i);
             painter.draw_text(
             painter.draw_text(
                 ruler_line_rect.shrunken(2, 0),
                 ruler_line_rect.shrunken(2, 0),
-                String::number(i),
+                String::number(i + 1),
                 is_current_line ? Font::default_bold_font() : font(),
                 is_current_line ? Font::default_bold_font() : font(),
                 TextAlignment::CenterRight,
                 TextAlignment::CenterRight,
                 is_current_line ? Color::DarkGray : Color::MidGray);
                 is_current_line ? Color::DarkGray : Color::MidGray);