summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-22 20:21:48 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-22 20:24:14 +0200
commitb2daadf6fe64715705617e6a9b11163359b7d927 (patch)
tree423a2423990a0c3b02d69f8b51b417ab0a7d0993
parent771ea6375a9f2a254d050eedd1c0897d0f7e9861 (diff)
Introduce needs_preprocessing flag (incl. functionality) to TextEdit.
-rw-r--r--plugingui/textedit.cc9
-rw-r--r--plugingui/textedit.h1
2 files changed, 9 insertions, 1 deletions
diff --git a/plugingui/textedit.cc b/plugingui/textedit.cc
index b7603a1..4de6e52 100644
--- a/plugingui/textedit.cc
+++ b/plugingui/textedit.cc
@@ -54,6 +54,8 @@ TextEdit::~TextEdit()
void TextEdit::resize(std::size_t width, std::size_t height)
{
Widget::resize(width, height);
+
+ needs_preprocessing = true;
scroll.resize(scroll.width(), height - 14);
scroll.move(width - 23, 7);
}
@@ -72,7 +74,7 @@ void TextEdit::setText(const std::string& text)
{
_text = text;
- preprocessText();
+ needs_preprocessing = true;
redraw();
textChangedNotifier();
}
@@ -144,6 +146,11 @@ void TextEdit::preprocessText()
void TextEdit::repaintEvent(RepaintEvent* repaintEvent)
{
+ if(needs_preprocessing)
+ {
+ preprocessText();
+ }
+
Painter p(*this);
// update values of scroll bar
diff --git a/plugingui/textedit.h b/plugingui/textedit.h
index 81e00b8..5959ae9 100644
--- a/plugingui/textedit.h
+++ b/plugingui/textedit.h
@@ -76,6 +76,7 @@ private:
std::string _text;
bool readonly{true};
+ bool needs_preprocessing{false};
std::list< std::string > preprocessedtext;
};