diff options
author | Don Bright <hugh.m.bright@gmail.com> | 2013-11-30 21:00:35 (GMT) |
---|---|---|
committer | Don Bright <hugh.m.bright@gmail.com> | 2013-11-30 21:00:35 (GMT) |
commit | 31199ea2d1f1a9ce2de763ca57fb0aa172cc1f66 (patch) | |
tree | 2dcb07e7c91e77bfd1d7caec7e6b91a33030ecf5 /src/editor.cc | |
parent | 6f6a8dff7669322a35ddc33ad195f2cb3de45de8 (diff) | |
parent | 961c380c840882da246aad1c30928f106aea8747 (diff) |
Merge branch 'master' of github.com:openscad/openscad
Diffstat (limited to 'src/editor.cc')
-rw-r--r-- | src/editor.cc | 14 |
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); + } +} |