-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <QTextStream>
#include <QChar>
+//VSR: uncomment below macro to support unicode text properly in SALOME
+// current commented out due to regressions
+//#define PAL22528_UNICODE
+
+namespace
+{
+ QString fromUtf8( const char* txt )
+ {
+#ifdef PAL22528_UNICODE
+ return QString::fromUtf8( txt );
+#else
+ return QString( txt );
+#endif
+ }
+}
+
static QString READY_PROMPT = ">>> ";
static QString DOTS_PROMPT = "... ";
{
if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
PyConsole_Editor* e = (PyConsole_Editor*)data;
- e->putLog( QString::fromUtf8(c) );
- QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), false ) );
+ e->putLog( fromUtf8(c) );
+ QApplication::postEvent( e, new PrintEvent( fromUtf8(c), false ) );
}
}
{
if(!((PyConsole_Editor*)data)->isSuppressOutput()) {
PyConsole_Editor* e = (PyConsole_Editor*)data;
- e->putLog( QString::fromUtf8(c) );
- QApplication::postEvent( e, new PrintEvent( QString::fromUtf8(c), true ) );
+ e->putLog( fromUtf8(c) );
+ QApplication::postEvent( e, new PrintEvent( fromUtf8(c), true ) );
}
}
/*!
\brief Destructor.
-
- Does nothing for the moment.
*/
PyConsole_Editor::~PyConsole_Editor()
{
- myInterp->destroy();
- delete myInterp;
myInterp = 0;
}
+/*!
+ \brief Get Python interpreter
+*/
+PyConsole_Interp* PyConsole_Editor::getInterp() const
+{
+ return myInterp;
+}
+
/*!
\brief Get synchronous mode flag value.
return;
// create new event loop
- myEventLoop = new QEventLoop( this );
+ bool sync = isSync();
+ if ( !sync ) {
+ myEventLoop = new QEventLoop( this );
+ }
+
// execute command
exec( command );
- // run event loop
- myEventLoop->exec();
- // delete event loop after command is processed
- delete myEventLoop;
- myEventLoop = 0;
+
+ if ( !sync ) {
+ // run event loop
+ myEventLoop->exec();
+ // delete event loop after command is processed
+ delete myEventLoop;
+ myEventLoop = 0;
+ }
}
/*!
}
}
/*!
- \brief "Save log" operation.
+ \brief "Start log" operation.
*/
void PyConsole_Editor::startLog()
{
aFilters, tr( "TOT_SAVE_PYLOG" ),
false, true );
if ( !fileName.isEmpty() ) {
- QFile file( fileName );
- if ( file.open( QFile::WriteOnly ) ) {
- file.close();
- myLogFile = fileName;
+ if ( startLog( fileName ) ) {
break;
}
else {
}
}
+/*!
+ \brief Start python trace logging
+ \param fileName the path to the log file
+ \sa stopLog()
+ */
+bool PyConsole_Editor::startLog( const QString& fileName )
+{
+ bool ok = false;
+ if ( !fileName.isEmpty() ) {
+ QFile file( fileName );
+ if ( file.open( QFile::WriteOnly ) ) {
+ file.close();
+ myLogFile = fileName;
+ ok = true;
+ }
+ }
+ return ok;
+}
/*!
\brief "Stop log" operation.