[escher] TextArea: fix drawStringAt action with negative length

This commit is contained in:
Émilie Feral
2020-01-30 16:15:27 +01:00
committed by Léa Saviot
parent eff0a26835
commit 0348db5d2e
2 changed files with 5 additions and 2 deletions

View File

@@ -106,7 +106,7 @@ protected:
m_cursorLocation = m_text.text();
}
void drawRect(KDContext * ctx, KDRect rect) const override;
void drawStringAt(KDContext * ctx, int line, int column, const char * text, size_t length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const;
void drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const;
virtual void drawLine(KDContext * ctx, int line, const char * text, size_t length, int fromColumn, int toColumn, const char * selectionStart, const char * selectionEnd) const = 0;
virtual void clearRect(KDContext * ctx, KDRect rect) const = 0;
KDSize minimalSizeForOptimalDisplay() const override;

View File

@@ -407,7 +407,10 @@ void TextArea::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
}
}
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, size_t length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const {
void TextArea::ContentView::drawStringAt(KDContext * ctx, int line, int column, const char * text, int length, KDColor textColor, KDColor backgroundColor, const char * selectionStart, const char * selectionEnd, KDColor backgroundHighlightColor) const {
if (length < 0) {
return;
}
KDSize glyphSize = m_font->glyphSize();
bool drawSelection = selectionStart != nullptr && selectionEnd > text && selectionStart < text + length;