[Gui] Make autocompletion global
Now auto complete is in all TextEdit objects. Fixes #12850
This commit is contained in:
committed by
Chris Hennes
parent
44221711f8
commit
81a27a9252
@@ -43,7 +43,6 @@
|
||||
#include "PythonConsolePy.h"
|
||||
#include "PythonTracing.h"
|
||||
#include "Application.h"
|
||||
#include "CallTips.h"
|
||||
#include "FileDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Tools.h"
|
||||
@@ -90,7 +89,6 @@ struct PythonConsoleP
|
||||
CopyType type;
|
||||
PyObject *_stdoutPy=nullptr, *_stderrPy=nullptr, *_stdinPy=nullptr, *_stdin=nullptr;
|
||||
InteractiveInterpreter* interpreter=nullptr;
|
||||
CallTipsList* callTipsList=nullptr;
|
||||
ConsoleHistory history;
|
||||
QString output, error, info, historyFile;
|
||||
QStringList statements;
|
||||
@@ -439,17 +437,6 @@ PythonConsole::PythonConsole(QWidget *parent)
|
||||
|
||||
setVisibleLineNumbers(false);
|
||||
setEnabledHighlightCurrentLine(false);
|
||||
|
||||
// create the window for call tips
|
||||
d->callTipsList = new CallTipsList(this);
|
||||
d->callTipsList->setFrameStyle(QFrame::Box);
|
||||
d->callTipsList->setFrameShadow(QFrame::Raised);
|
||||
d->callTipsList->setLineWidth(2);
|
||||
installEventFilter(d->callTipsList);
|
||||
viewport()->installEventFilter(d->callTipsList);
|
||||
d->callTipsList->setSelectionMode( QAbstractItemView::SingleSelection );
|
||||
d->callTipsList->hide();
|
||||
|
||||
QFont serifFont(QLatin1String("Courier"), 10, QFont::Normal);
|
||||
setFont(serifFont);
|
||||
|
||||
@@ -536,6 +523,18 @@ void PythonConsole::OnChange(Base::Subject<const char*> &rCaller, const char* sR
|
||||
}
|
||||
}
|
||||
|
||||
int PythonConsole::getInputStringPosition()
|
||||
{
|
||||
QString rawLine = textCursor().block().text();
|
||||
return textCursor().positionInBlock() - promptLength(rawLine);
|
||||
}
|
||||
|
||||
QString PythonConsole::getInputString()
|
||||
{
|
||||
QString rawLine = textCursor().block().text();
|
||||
return stripPromptFrom(rawLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the input of the console to make the correct indentations.
|
||||
* After a command is prompted completely the Python interpreter is started.
|
||||
@@ -625,22 +624,6 @@ void PythonConsole::keyPressEvent(QKeyEvent * e)
|
||||
runSource( inputStrg ); //< commit input string
|
||||
} break;
|
||||
|
||||
case Qt::Key_Period:
|
||||
{
|
||||
// In Qt 4.8 there is a strange behaviour because when pressing ":"
|
||||
// then key is also set to 'Period' instead of 'Colon'. So we have
|
||||
// to make sure we only handle the period.
|
||||
if (e->text() == QLatin1String(".")) {
|
||||
// analyse context and show available call tips
|
||||
int contextLength = cursor.position() - inputLineBegin.position();
|
||||
PythonTextEditor::keyPressEvent(e);
|
||||
d->callTipsList->showTips( inputStrg.left( contextLength ) );
|
||||
}
|
||||
else {
|
||||
PythonTextEditor::keyPressEvent(e);
|
||||
}
|
||||
} break;
|
||||
|
||||
case Qt::Key_Home:
|
||||
{
|
||||
QTextCursor::MoveMode mode = (e->modifiers() & Qt::ShiftModifier)? QTextCursor::KeepAnchor
|
||||
@@ -690,10 +673,6 @@ void PythonConsole::keyPressEvent(QKeyEvent * e)
|
||||
PythonTextEditor::keyPressEvent(e);
|
||||
} break;
|
||||
}
|
||||
// This can't be done in CallTipsList::eventFilter() because we must first perform
|
||||
// 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());
|
||||
|
||||
Reference in New Issue
Block a user