Salome HOME
Add setCurrentLine to PyEditor API.
[modules/gui.git] / tools / PyEditor / src / PyEditor_Editor.cxx
index 7e62c6f7bf2205c8b8170a35baff3a9a9c58d02c..4f62b82217afda0f9e0741089659ae086b1b6945 100644 (file)
@@ -30,6 +30,7 @@
 #include <QMenu>
 #include <QPainter>
 #include <QTextBlock>
+#include <QScrollBar>
 
 #include <iostream>
 
@@ -920,3 +921,15 @@ PyEditor_Keywords* PyEditor_Editor::standardKeywords() const
 {
   return myStdKeywords;
 }
+
+/*!
+  \brief Move cursor to the given line.
+  \note Line count starts from 1.
+  \param line Line number.
+*/
+void PyEditor_Editor::setCurrentLine( int line )
+{
+  QTextCursor cursor( document()->findBlockByLineNumber( line - 1 ) );
+  setTextCursor( cursor );
+  ensureCursorVisible();
+}