0000822: Two little tweaks for the python console
This commit is contained in:
parent
a26f42b7b3
commit
3140c13baf
|
@ -442,13 +442,8 @@ void PythonConsole::OnChange( Base::Subject<const char*> &rCaller,const char* sR
|
|||
void PythonConsole::keyPressEvent(QKeyEvent * e)
|
||||
{
|
||||
bool restartHistory = true;
|
||||
QTextCursor cursor = this->textCursor();
|
||||
|
||||
// construct reference cursor at begin of input line ...
|
||||
QTextCursor inputLineBegin = cursor;
|
||||
inputLineBegin.movePosition( QTextCursor::End );
|
||||
inputLineBegin.movePosition( QTextCursor::StartOfLine );
|
||||
inputLineBegin.movePosition( QTextCursor::Right, QTextCursor::MoveAnchor, promptLength );
|
||||
QTextCursor cursor = this->textCursor();
|
||||
QTextCursor inputLineBegin = this->inputBegin();
|
||||
|
||||
if (cursor < inputLineBegin)
|
||||
{
|
||||
|
@ -579,6 +574,9 @@ void PythonConsole::keyPressEvent(QKeyEvent * e)
|
|||
// the event and afterwards update the list widget
|
||||
if (d->callTipsList->isVisible())
|
||||
{ d->callTipsList->validateCursor(); }
|
||||
|
||||
// disable history restart if input line changed
|
||||
restartHistory &= (inputLine != inputBlock.text().mid(promptLength));
|
||||
}
|
||||
// any cursor move resets the history to its latest item.
|
||||
if (restartHistory)
|
||||
|
@ -806,6 +804,21 @@ void PythonConsole::changeEvent(QEvent *e)
|
|||
TextEdit::changeEvent(e);
|
||||
}
|
||||
|
||||
void PythonConsole::mouseReleaseEvent( QMouseEvent *e )
|
||||
{
|
||||
TextEdit::mouseReleaseEvent( e );
|
||||
if (e->button() == Qt::LeftButton)
|
||||
{
|
||||
QTextCursor cursor = this->textCursor();
|
||||
if (cursor.hasSelection() == false
|
||||
&& cursor < this->inputBegin())
|
||||
{
|
||||
cursor.movePosition( QTextCursor::End );
|
||||
this->setTextCursor( cursor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the event \a e and writes the right Python command.
|
||||
*/
|
||||
|
@ -904,6 +917,16 @@ void PythonConsole::insertFromMimeData (const QMimeData * source)
|
|||
}
|
||||
}
|
||||
|
||||
QTextCursor PythonConsole::inputBegin( void ) const
|
||||
{
|
||||
// construct cursor at begin of input line ...
|
||||
QTextCursor inputLineBegin( this->textCursor() );
|
||||
inputLineBegin.movePosition( QTextCursor::End );
|
||||
inputLineBegin.movePosition( QTextCursor::StartOfLine );
|
||||
inputLineBegin.movePosition( QTextCursor::Right, QTextCursor::MoveAnchor, promptLength );
|
||||
return inputLineBegin;
|
||||
}
|
||||
|
||||
QMimeData * PythonConsole::createMimeDataFromSelection () const
|
||||
{
|
||||
QMimeData* mime = new QMimeData();
|
||||
|
|
|
@ -126,6 +126,7 @@ protected:
|
|||
void dragEnterEvent ( QDragEnterEvent * e );
|
||||
void dragMoveEvent ( QDragMoveEvent * e );
|
||||
void changeEvent ( QEvent * e );
|
||||
void mouseReleaseEvent( QMouseEvent * e );
|
||||
|
||||
void overrideCursor(const QString& txt);
|
||||
|
||||
|
@ -134,6 +135,7 @@ protected:
|
|||
bool canInsertFromMimeData ( const QMimeData * source ) const;
|
||||
QMimeData * createMimeDataFromSelection () const;
|
||||
void insertFromMimeData ( const QMimeData * source );
|
||||
QTextCursor inputBegin( void ) const;
|
||||
|
||||
private:
|
||||
void runSource(const QString&);
|
||||
|
|
Loading…
Reference in New Issue
Block a user