Browse Source

Fixed code editor line number display problem.

tags/2021-05-28
jules 12 years ago
parent
commit
318e9cf405
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp

+ 7
- 5
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -283,7 +283,7 @@ private:
class CodeEditorComponent::GutterComponent : public Component class CodeEditorComponent::GutterComponent : public Component
{ {
public: public:
GutterComponent() : lastNumLines (0) {}
GutterComponent() : firstLine (0), lastNumLines (0) {}
void paint (Graphics& g) override void paint (Graphics& g) override
{ {
@@ -313,18 +313,20 @@ public:
ga.draw (g); ga.draw (g);
} }
void documentChanged (CodeDocument& doc)
void documentChanged (CodeDocument& doc, int firstLineOnScreen)
{ {
const int newNumLines = doc.getNumLines(); const int newNumLines = doc.getNumLines();
if (newNumLines != lastNumLines)
if (newNumLines != lastNumLines || firstLineOnScreen != firstLine)
{ {
firstLine = firstLineOnScreen;
lastNumLines = newNumLines; lastNumLines = newNumLines;
repaint(); repaint();
} }
} }
private: private:
int lastNumLines;
int firstLine, lastNumLines;
}; };
@@ -538,7 +540,7 @@ void CodeEditorComponent::rebuildLineTokens()
verticalScrollBar.getX(), lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2); verticalScrollBar.getX(), lineHeight * (1 + maxLineToRepaint - minLineToRepaint) + 2);
if (gutter != nullptr) if (gutter != nullptr)
gutter->documentChanged (document);
gutter->documentChanged (document, firstLineOnScreen);
} }
void CodeEditorComponent::codeDocumentChanged (const int startIndex, const int endIndex) void CodeEditorComponent::codeDocumentChanged (const int startIndex, const int endIndex)


Loading…
Cancel
Save