Index: src/app/qgspythondialog.h =================================================================== --- src/app/qgspythondialog.h (revision 10610) +++ src/app/qgspythondialog.h (working copy) @@ -37,11 +37,12 @@ public slots: - void on_edtCmdLine_returnPressed(); + void on_pbnPrev_clicked(); + void on_pbnExecute_clicked(); + void on_pbnNext_clicked(); protected: - void keyPressEvent( QKeyEvent *event ); void closeEvent( QCloseEvent *event ); void showEvent( QShowEvent *event ); Index: src/app/qgspythondialog.cpp =================================================================== --- src/app/qgspythondialog.cpp (revision 10610) +++ src/app/qgspythondialog.cpp (working copy) @@ -16,6 +16,7 @@ #include "qgspythondialog.h" #include "qgspythonutils.h" +#include "qgslogger.h" #include #include @@ -43,43 +44,35 @@ return text.replace( "<", "<" ).replace( ">", ">" ); } -void QgsPythonDialog::keyPressEvent( QKeyEvent *ev ) +void QgsPythonDialog::on_pbnPrev_clicked() { - switch ( ev->key() ) + if ( pos > 0 ) { - case Qt::Key_Up: - { - if ( pos > 0 ) - { - if ( pos == history.size() ) - history << edtCmdLine->text(); - else - history[pos] = edtCmdLine->text(); - pos--; - edtCmdLine->setText( history[pos] ); - } - } - break; - case Qt::Key_Down: - { - if ( pos < history.size() - 1 ) - { - history[pos] = edtCmdLine->text(); - pos++; - edtCmdLine->setText( history[pos] ); - } - } - break; - default: - QWidget::keyPressEvent( ev ); - break; + if ( pos == history.size() ) + history << edtCmdLine->toPlainText(); + else + history[pos] = edtCmdLine->toPlainText(); + pos--; + edtCmdLine->setText( history[pos] ); } } -void QgsPythonDialog::on_edtCmdLine_returnPressed() +void QgsPythonDialog::on_pbnNext_clicked() { - QString command = edtCmdLine->text(); + if ( pos < history.size() - 1 ) + { + history[pos] = edtCmdLine->toPlainText(); + pos++; + edtCmdLine->setText( history[pos] ); + } +} +void QgsPythonDialog::on_pbnExecute_clicked() +{ + QString command = edtCmdLine->toPlainText(); + + QgsDebugMsg( QString("command: |%1|").arg( command ) ); + if ( !command.isEmpty() ) { history << command; @@ -90,7 +83,7 @@ // when using Py_single_input the return value will be always null // we're using custom hooks for output and exceptions to show output in console - if ( mPythonUtils->runStringUnsafe( command ) ) + if ( mPythonUtils->runStringUnsafe( command, false ) ) { mPythonUtils->evalString( "sys.stdout.get_and_clean_data()", output ); QString result = mPythonUtils->getResult(); Index: src/python/qgspythonutilsimpl.cpp =================================================================== --- src/python/qgspythonutilsimpl.cpp (revision 10610) +++ src/python/qgspythonutilsimpl.cpp (working copy) @@ -167,12 +167,12 @@ } -bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command ) +bool QgsPythonUtilsImpl::runStringUnsafe( const QString& command, bool single ) { // TODO: convert special characters from unicode strings u"..." to \uXXXX // so that they're not mangled to utf-8 // (non-unicode strings can be mangled) - PyRun_String( command.toUtf8().data(), Py_single_input, mMainDict, mMainDict ); + PyRun_String( command.toUtf8().data(), single ? Py_single_input : Py_file_input, mMainDict, mMainDict ); return ( PyErr_Occurred() == 0 ); } Index: src/python/qgspythonutils.h =================================================================== --- src/python/qgspythonutils.h (revision 10610) +++ src/python/qgspythonutils.h (working copy) @@ -52,7 +52,7 @@ //! run a statement, error reporting is not done //! @return true if no error occured - virtual bool runStringUnsafe( const QString& command ) = 0; + virtual bool runStringUnsafe( const QString& command, bool single = true ) = 0; virtual bool evalString( const QString& command, QString& result ) = 0; Index: src/python/qgspythonutilsimpl.h =================================================================== --- src/python/qgspythonutilsimpl.h (revision 10610) +++ src/python/qgspythonutilsimpl.h (working copy) @@ -57,7 +57,7 @@ //! run a statement, error reporting is not done //! @return true if no error occured - bool runStringUnsafe( const QString& command ); + bool runStringUnsafe( const QString& command, bool single = true ); bool evalString( const QString& command, QString& result ); Index: src/ui/qgspythondialog.ui =================================================================== --- src/ui/qgspythondialog.ui (revision 10610) +++ src/ui/qgspythondialog.ui (working copy) @@ -5,26 +5,39 @@ 0 0 - 541 - 338 + 709 + 265 Python console - - - 9 - - - 6 - - + + + + + &Execute + + + + + + + &Previous + + + + + + + &Next + + + + - - 7 - 5 + 0 0 @@ -37,37 +50,43 @@ - + - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> - - - - 0 + + + + + 0 + 0 + - - 6 + + >>> - - - - >>> - - - - - - - + + + + + pbnExecute + pbnPrev + pbnNext + lblInfo + txtHistory + lblPrompt + edtCmdLine - edtCmdLine txtHistory