Salome HOME
Merge branch 'V8_3_BR' into V8_4_BR V8_4_BR
authorvsr <vsr@opencascade.com>
Wed, 21 Mar 2018 07:27:37 +0000 (10:27 +0300)
committervsr <vsr@opencascade.com>
Wed, 21 Mar 2018 07:27:37 +0000 (10:27 +0300)
tools/PyEditor/src/PyEditor.cxx
tools/PyEditor/src/PyEditor_Editor.cxx
tools/PyEditor/src/PyEditor_Editor.h
tools/PyEditor/src/PyEditor_Settings.cxx
tools/PyEditor/src/PyEditor_Widget.cxx
tools/PyEditor/src/PyEditor_Widget.h
tools/PyEditor/src/PyEditor_Window.cxx
tools/PyEditor/src/PyEditor_Window.h
tools/PyEditor/src/python/PyEditorPy.sip

index 5a213338de0723da06f0de98c9156078ae83298b..0c8d2b295bd7e338d32151ee90db03c9f87c6370 100644 (file)
@@ -20,6 +20,7 @@
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 //
 
+#include "PyEditor_Widget.h"
 #include "PyEditor_Window.h"
 #include "PyEditor_StdSettings.h"
 
@@ -110,6 +111,10 @@ int main( int argc, char *argv[] )
   QCommandLineParser parser;
   parser.setApplicationDescription( QApplication::translate( "PyEditor", "PROGRAM_DESCRIPTION" ) );
   parser.addHelpOption();
+  QCommandLineOption gotoOption( QStringList() << "l" << "line",
+                                QApplication::translate( "PyEditor", "Set initial line number." ),
+                                "line" );
+  parser.addOption( gotoOption );
   parser.addPositionalArgument( QApplication::translate( "PyEditor", "FILE_PARAM_NAME" ),
                                 QApplication::translate( "PyEditor", "FILE_PARAM_DESCRIPTION" ) );
 
@@ -121,8 +126,16 @@ int main( int argc, char *argv[] )
   window.resize( 650, 700 );
   window.show();
 
-  if ( args.count() > 0 )
+  if ( args.count() > 0 ) {
     window.loadFile( args[0], false );
+
+    if ( parser.isSet( gotoOption ) ) {
+      bool ok;
+      int line = parser.value( gotoOption ).toInt( &ok );
+      if ( ok )
+       window.editor()->setCurrentLine( line );
+    }
+  }
   
   return app.exec();
 }
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();
+}
index 8ec6883667b78d8dc66b3797d5f3de399eb3b391..1cdcabe96492ed56c529fdee5791bd68c4a9992a 100644 (file)
@@ -46,6 +46,7 @@ public:
   
   void    setSettings( const PyEditor_Settings& );
   const PyEditor_Settings& settings() const;
+
   QString text() const;
 
   QStringList keywords() const;
@@ -59,6 +60,7 @@ public Q_SLOTS:
   void deleteSelected();
   void append( const QString& );  
   void setText( const QString& text );
+  void setCurrentLine( int );
 
 protected:
   virtual void keyPressEvent( QKeyEvent* );
index 64a43d700e8d4237db26bb62f7d5cd08012cf413..fff5cda6fcafb1af02cc57453b4aca4c4e995174 100644 (file)
@@ -64,7 +64,7 @@ PyEditor_Settings::PyEditor_Settings()
     myTabSpaceVisible( true ),
     myTabSize( 4 ),
     myFont( "Courier", 10 ),
-    myCompletionPolicy( PyEditor_Editor::Always )
+    myCompletionPolicy( PyEditor_Editor::None )
 {
 }
 
index 58d4c285c6ab3df391fa3651c479e4fdacf4a649..bc2701959ab80b0f6dc1bdd6943c3a5860196d2d 100644 (file)
@@ -267,3 +267,13 @@ const PyEditor_Settings& PyEditor_Widget::settings() const
 {
   return myEditor->settings();
 }
+
+/*!
+  \brief Move editor's cursor to the given line.
+  \note Line count starts from 1.
+  \param line Line number.
+*/
+void PyEditor_Widget::setCurrentLine( int line )
+{
+  myEditor->setCurrentLine( line );
+}
index f7ba959773adb48998441ea295893b44c070b8e1..4e5bffee53c4490148851e5037dc7aefa86af384 100644 (file)
@@ -72,6 +72,8 @@ public slots:
 
   void setText( const QString& );
 
+  void setCurrentLine( int );
+
 signals:
   void modificationChanged( bool );
   void undoAvailable( bool );
index cfeebe2bdc60a7efdc203a49bde4034461851fbc..33d6219476b8a970ca416b02b51f99b444f94011 100644 (file)
@@ -471,6 +471,16 @@ bool PyEditor_Window::saveFile( const QString& filePath, bool verbose )
   return true;
 }
 
+
+/*!
+  Get editor.
+  \return Editor widget.
+*/
+PyEditor_Widget* PyEditor_Window::editor()
+{
+  return myEditor;
+}
+
 /*!
   Slot, called when user clicks "Help" button in "Preferences" dialog box.
 */
index 1369db1cdaee63dc81e8523c734b679be8f5d066..cd16eddb611366f2010ca284898bc4cd5c682ddb 100644 (file)
@@ -46,6 +46,8 @@ public:
 
   void        loadFile( const QString&, bool = true );
   bool        saveFile( const QString&, bool = true );
+
+  PyEditor_Widget* editor();
   
 protected:
   virtual void closeEvent( QCloseEvent* );
index 854e7a86b54a01d9e70aea88f2febf7b3f02b807..ec0d1e7cc4c6668570092e3255b71c5db051b03b 100644 (file)
@@ -93,6 +93,7 @@ public slots:
   void deleteSelected();
   void append( const QString& );  
   void setText( const QString& text );
+  void setCurrentLine( int );
 
 protected:
   virtual void keyPressEvent( QKeyEvent* );
@@ -165,6 +166,8 @@ public slots:
 
   void setText( const QString& );
 
+  void setCurrentLine( int );
+
 signals:
   void modificationChanged( bool );
   void undoAvailable( bool );