Salome HOME
Splash screen was implemented. Changes in packages SUIT and Session are integrated.
[modules/gui.git] / src / PythonConsole / PythonConsole_PyEditor.cxx
index da6b4df6605303b0c7035c9e4427b514894b803d..9ffed0f034d41af5ab70c37bee770b3190ad7f5a 100755 (executable)
 
 using namespace std;
 
+//#ifdef _DEBUG_
+//static int MYDEBUG = 1;
+//#else
+//static int MYDEBUG = 0;
+//#endif
+
+
 enum { IdCopy, IdPaste, IdClear, IdSelectAll };
 
+
 static QString READY_PROMPT = ">>> ";
 static QString DOTS_PROMPT  = "... ";
 #define PROMPT_SIZE _currentPrompt.length()
@@ -127,6 +135,25 @@ void PythonConsole_PyEditor::setText(QString s)
   setCursorPosition( n, paragraphLength(n)); 
 }
 
+/*!
+    Convenient method for executing a Python command,
+    as if the user typed it manually
+*/
+void PythonConsole_PyEditor::exec( const QString& command )
+{
+  // Some interactive command is being executed in this editor -> do nothing
+  if ( isReadOnly() )
+    return;
+  int para=paragraphs()-1;
+  removeParagraph( para );
+  _currentPrompt = READY_PROMPT;
+  _buf.truncate(0);
+  _isInHistory = false;
+  setText( "\n" + _currentPrompt); 
+  setText( command + "\n" ); 
+  handleReturn();
+}
+
 /*!
     Called when an handleReturn
 */
@@ -689,5 +716,11 @@ QPopupMenu* PythonConsole_PyEditor::createPopupMenu( const QPoint& pos )
 
   SUIT_Tools::simplifySeparators( popup );
 
+  if ( !popup->count() )
+  {
+    delete popup;
+    popup = 0;
+  }
+
   return popup;
 }