Support multi-line input in the python shell

This commit is contained in:
baldurk
2017-11-20 20:01:02 +00:00
parent 31b7662db1
commit 657c343ac8
6 changed files with 48 additions and 10 deletions
@@ -49,3 +49,17 @@ void RDLineEdit::keyPressEvent(QKeyEvent *e)
QLineEdit::keyPressEvent(e);
emit(keyPress(e));
}
bool RDLineEdit::event(QEvent *e)
{
if(m_acceptTabs && e->type() == QEvent::KeyPress)
{
QKeyEvent *ke = (QKeyEvent *)e;
if(ke->key() == Qt::Key_Tab)
{
insert(lit("\t"));
return true;
}
}
return QLineEdit::event(e);
}
+6
View File
@@ -33,6 +33,8 @@ public:
explicit RDLineEdit(QWidget *parent = 0);
~RDLineEdit();
void setAcceptTabCharacters(bool accept) { m_acceptTabs = accept; }
bool acceptTabCharacters() { return m_acceptTabs; }
signals:
void enter();
void leave();
@@ -44,4 +46,8 @@ protected:
void focusInEvent(QFocusEvent *e);
void focusOutEvent(QFocusEvent *e);
void keyPressEvent(QKeyEvent *e);
bool event(QEvent *e);
private:
bool m_acceptTabs;
};