diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-28 20:38:25 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-06-28 20:38:25 +0200 |
commit | 6e11c52dc933027ca5131bddf999953d1142edda (patch) | |
tree | 6b540a29f951fb8d965163df7a0382637ec5396f /3rdparty/python-console/modified | |
parent | 960c65047877c72498d65ecc401371ab1552c82a (diff) | |
download | nextpnr-6e11c52dc933027ca5131bddf999953d1142edda.tar.gz nextpnr-6e11c52dc933027ca5131bddf999953d1142edda.tar.bz2 nextpnr-6e11c52dc933027ca5131bddf999953d1142edda.zip |
make paste work, fix inserting in wrong lines
Diffstat (limited to '3rdparty/python-console/modified')
-rw-r--r-- | 3rdparty/python-console/modified/pyconsole.cc | 30 | ||||
-rw-r--r-- | 3rdparty/python-console/modified/pyconsole.h | 3 |
2 files changed, 32 insertions, 1 deletions
diff --git a/3rdparty/python-console/modified/pyconsole.cc b/3rdparty/python-console/modified/pyconsole.cc index 35f3e930..186d74d2 100644 --- a/3rdparty/python-console/modified/pyconsole.cc +++ b/3rdparty/python-console/modified/pyconsole.cc @@ -52,7 +52,8 @@ void PythonConsole::keyPressEvent( QKeyEvent* e ) if ( ! canGoLeft( ) ) return; } - + if (!cursorIsOnInputLine()) return; + if (textCursor().columnNumber() < PythonConsole::PROMPT.size()) return; QTextEdit::keyPressEvent( e ); } @@ -292,3 +293,30 @@ void PythonConsole::moveCursorToEnd( ) cursor.movePosition( QTextCursor::End ); setTextCursor( cursor ); } + +void PythonConsole::insertFromMimeData(const QMimeData *src) +{ + if (src->hasText()) { + QStringList list = src->text().split("\n",QString::KeepEmptyParts); + bool lastends = src->text().endsWith("\n"); + for (int i=0;i<list.size();i++) + { + QString line = list.at(i); + displayString(line); + if (!lastends && (i==list.size()-1)) break; + + m_parseHelper.process( line.toStdString( ) ); + if ( m_parseHelper.buffered( ) ) + { + append(""); + displayPrompt( ); + } + if ( line.size( ) ) + { + m_historyBuffer.push_back( line.toStdString( ) ); + m_historyIt = m_historyBuffer.end(); + } + moveCursorToEnd( ); + } + } +}
\ No newline at end of file diff --git a/3rdparty/python-console/modified/pyconsole.h b/3rdparty/python-console/modified/pyconsole.h index eb2c98a4..adf4ce20 100644 --- a/3rdparty/python-console/modified/pyconsole.h +++ b/3rdparty/python-console/modified/pyconsole.h @@ -25,6 +25,7 @@ SOFTWARE. #define PYCONSOLE_H #include <QColor> #include <QTextEdit> +#include <QMimeData> #include "ParseHelper.h" #include "ParseListener.h" @@ -47,6 +48,8 @@ class PythonConsole : public QTextEdit, ParseListener virtual void handleReturnKeyPress(); + virtual void insertFromMimeData(const QMimeData *src); + /** Handle a compilable chunk of Python user input. */ |