summaryrefslogtreecommitdiff
path: root/src/editor.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-11-30 21:30:40 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-11-30 21:30:40 (GMT)
commit75692592e49da1af2b1c8857298ca7085cd5b3d5 (patch)
tree33e5ee1aae1b9eb4514d735f00281a21f17325a0 /src/editor.cc
parentfd715c6526e961cb7f3d6ba6a0563788d7d1674d (diff)
parentf175bae46a8f15823780c5a9c89b11476acb3107 (diff)
Merge branch 'master' into issue410x
Diffstat (limited to 'src/editor.cc')
-rw-r--r--src/editor.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/editor.cc b/src/editor.cc
index 08bf005..069101f 100644
--- a/src/editor.cc
+++ b/src/editor.cc
@@ -108,3 +108,17 @@ void Editor::wheelEvent ( QWheelEvent * event )
}
}
+void Editor::setPlainText(const QString &text)
+{
+ int y = verticalScrollBar()->sliderPosition();
+ // Save current cursor position
+ QTextCursor cursor = textCursor();
+ int n = cursor.position();
+ QTextEdit::setPlainText(text);
+ // Restore cursor position
+ if (n < text.length()) {
+ cursor.setPosition(n);
+ setTextCursor(cursor);
+ verticalScrollBar()->setSliderPosition(y);
+ }
+}
contact: Jan Huwald // Impressum