make paste work, fix inserting in wrong lines
This commit is contained in:
parent
960c650478
commit
6e11c52dc9
30
3rdparty/python-console/modified/pyconsole.cc
vendored
30
3rdparty/python-console/modified/pyconsole.cc
vendored
@ -52,7 +52,8 @@ void PythonConsole::keyPressEvent( QKeyEvent* e )
|
|||||||
if ( ! canGoLeft( ) )
|
if ( ! canGoLeft( ) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!cursorIsOnInputLine()) return;
|
||||||
|
if (textCursor().columnNumber() < PythonConsole::PROMPT.size()) return;
|
||||||
QTextEdit::keyPressEvent( e );
|
QTextEdit::keyPressEvent( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,3 +293,30 @@ void PythonConsole::moveCursorToEnd( )
|
|||||||
cursor.movePosition( QTextCursor::End );
|
cursor.movePosition( QTextCursor::End );
|
||||||
setTextCursor( cursor );
|
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( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
3rdparty/python-console/modified/pyconsole.h
vendored
3
3rdparty/python-console/modified/pyconsole.h
vendored
@ -25,6 +25,7 @@ SOFTWARE.
|
|||||||
#define PYCONSOLE_H
|
#define PYCONSOLE_H
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QMimeData>
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
#include "ParseListener.h"
|
#include "ParseListener.h"
|
||||||
|
|
||||||
@ -47,6 +48,8 @@ class PythonConsole : public QTextEdit, ParseListener
|
|||||||
|
|
||||||
virtual void handleReturnKeyPress();
|
virtual void handleReturnKeyPress();
|
||||||
|
|
||||||
|
virtual void insertFromMimeData(const QMimeData *src);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Handle a compilable chunk of Python user input.
|
Handle a compilable chunk of Python user input.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user