#include <PythonConsole.h>
Public Types | |
enum | Prompt { Complete = 0, Incomplete = 1, Flush = 2, Special = 3 } |
Public Slots | |
void | onClearConsole () |
void | onCopyCommand () |
Copy the selected commands into the clipboard. More... | |
void | onCopyHistory () |
Copy the history of the console into the clipboard. More... | |
void | onFlush () |
void | onInsertFileName () |
void | onSaveHistoryAs () |
Signals | |
void | pendingSource (void) |
Public Member Functions | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *rcReason) |
Set new font and colors according to the parameters. More... | |
void | printStatement (const QString &cmd) |
Prints the Python statement cmd to the console. More... | |
PythonConsole (QWidget *parent=0) | |
Constructs a PythonConsole which is a child of 'parent'. More... | |
QString | readline (void) |
~PythonConsole () | |
Destroys the object and frees any allocated resources. More... | |
Public Member Functions inherited from Gui::TextEdit | |
TextEdit (QWidget *parent=0) | |
Constructs a TextEdit which is a child of 'parent'. More... | |
virtual | ~TextEdit () |
Destroys the object and frees any allocated resources. More... | |
Public Member Functions inherited from Gui::WindowParameter | |
ParameterGrp::handle | getWindowParameter (void) |
return the parameter group of this window More... | |
void | OnChange (Base::Subject< const char * > &rCaller, const char *sReason) |
bool | setGroupName (const char *name) |
Sets the group of the window to name. More... | |
WindowParameter (const char *name) | |
virtual | ~WindowParameter () |
Protected Member Functions | |
bool | canInsertFromMimeData (const QMimeData *source) const |
void | changeEvent (QEvent *e) |
void | contextMenuEvent (QContextMenuEvent *e) |
Pops up the context menu with some extensions. More... | |
QMimeData * | createMimeDataFromSelection () const |
void | dragEnterEvent (QDragEnterEvent *e) |
Dragging of action objects is allowed. More... | |
void | dragMoveEvent (QDragMoveEvent *e) |
Dragging of action objects is allowed. More... | |
void | dropEvent (QDropEvent *e) |
Drops the event e and writes the right Python command. More... | |
QTextCursor | inputBegin (void) const |
void | insertFromMimeData (const QMimeData *source) |
Allow to paste plain text or urls of text files. More... | |
void | keyPressEvent (QKeyEvent *e) |
Checks the input of the console to make the correct indentations. More... | |
void | mouseReleaseEvent (QMouseEvent *e) |
void | overrideCursor (const QString &txt) |
Overwrites the text of the cursor. More... | |
void | showEvent (QShowEvent *e) |
Shows the Python window and sets the focus to set text cursor. More... | |
Protected Member Functions inherited from Gui::TextEdit | |
void | keyPressEvent (QKeyEvent *) |
Set the approproriate item of the completion box or hide it, if needed. More... | |
Friends | |
class | PythonStderr |
class | PythonStdout |
Additional Inherited Members | |
Static Public Member Functions inherited from Gui::WindowParameter | |
static ParameterGrp::handle | getDefaultParameter (void) |
get the parameters More... | |
Member Enumeration Documentation
◆ Prompt
Constructor & Destructor Documentation
◆ PythonConsole()
PythonConsole::PythonConsole | ( | QWidget * | parent = 0 | ) |
Constructs a PythonConsole which is a child of 'parent'.
References Base::Subject< _MessageType >::Attach(), Gui::PythonConsoleP::callTipsList, Complete, Gui::WindowParameter::getWindowParameter(), Gui::PythonConsoleP::info, Gui::PythonConsoleP::interactive, Gui::PythonConsoleP::interpreter, ParameterGrp::NotifyAll(), Gui::PythonConsoleP::output, PythonStderr, and PythonStdout.
◆ ~PythonConsole()
PythonConsole::~PythonConsole | ( | ) |
Destroys the object and frees any allocated resources.
References Base::Subject< _MessageType >::Detach(), Gui::WindowParameter::getWindowParameter(), and Gui::PythonConsoleP::interpreter.
Member Function Documentation
◆ canInsertFromMimeData()
|
protected |
Referenced by contextMenuEvent().
◆ changeEvent()
|
protected |
◆ contextMenuEvent()
|
protected |
Pops up the context menu with some extensions.
References canInsertFromMimeData(), Gui::cursorBeyond(), App::GetApplication(), ParameterGrp::GetBool(), ParameterGrp::GetGroup(), App::Application::GetUserParameter(), Gui::PythonConsoleP::history, inputBegin(), Gui::ConsoleHistory::isEmpty(), onClearConsole(), onCopyCommand(), onCopyHistory(), onInsertFileName(), onSaveHistoryAs(), and ParameterGrp::SetBool().
◆ createMimeDataFromSelection()
|
protected |
◆ dragEnterEvent()
|
protected |
Dragging of action objects is allowed.
◆ dragMoveEvent()
|
protected |
Dragging of action objects is allowed.
◆ dropEvent()
|
protected |
Drops the event e and writes the right Python command.
References printStatement().
◆ inputBegin()
|
protected |
References Gui::promptLength().
Referenced by contextMenuEvent(), keyPressEvent(), mouseReleaseEvent(), and overrideCursor().
◆ insertFromMimeData()
|
protected |
Allow to paste plain text or urls of text files.
◆ keyPressEvent()
|
protected |
Checks the input of the console to make the correct indentations.
After a command is prompted completely the Python interpreter is started.
The cursor is placed not on the input line (or within the prompt string) So we handle key input as follows:
- don't allow changing previous lines.
- allow full movement (no prompt restriction)
- allow copying content (Ctrl+C)
- "escape" to end of input line
The cursor sits somewhere on the input line (after the prompt) Here we handle key input a bit different:
- restrict cursor movement to input line range (excluding the prompt characters)
- roam the history by Up/Down keys
- show call tips on period
References Gui::ConsoleHistory::append(), Gui::PythonConsoleP::callTipsList, Complete, Gui::cursorBeyond(), Gui::InteractiveInterpreter::hasPendingInput(), Gui::PythonConsoleP::history, Incomplete, inputBegin(), Gui::PythonConsoleP::interpreter, Gui::TextEdit::keyPressEvent(), Gui::ConsoleHistory::next(), overrideCursor(), Gui::ConsoleHistory::prev(), Gui::ConsoleHistory::restart(), Gui::CallTipsList::showTips(), Gui::stripPromptFrom(), Gui::CallTipsList::validateCursor(), and Gui::ConsoleHistory::value().
◆ mouseReleaseEvent()
|
protected |
References inputBegin().
◆ OnChange()
void PythonConsole::OnChange | ( | Base::Subject< const char * > & | rCaller, |
const char * | rcReason | ||
) |
Set new font and colors according to the parameters.
References Gui::PythonConsoleP::colormap, App::GetApplication(), ParameterGrp::GetASCII(), ParameterGrp::GetBool(), ParameterGrp::GetGroup(), ParameterGrp::GetInt(), ParameterGrp::GetUnsigned(), App::Application::GetUserParameter(), Gui::WindowParameter::getWindowParameter(), and Gui::SyntaxHighlighter::setColor().
◆ onClearConsole
|
slot |
References Complete, Gui::PythonConsoleP::info, and Gui::PythonConsoleP::output.
Referenced by contextMenuEvent().
◆ onCopyCommand
|
slot |
Copy the selected commands into the clipboard.
This is a subset of the history.
References Gui::PythonConsoleP::Command, Gui::PythonConsoleP::Normal, and Gui::PythonConsoleP::type.
Referenced by contextMenuEvent().
◆ onCopyHistory
|
slot |
Copy the history of the console into the clipboard.
References createMimeDataFromSelection(), Gui::PythonConsoleP::History, Gui::PythonConsoleP::history, Gui::ConsoleHistory::isEmpty(), Gui::PythonConsoleP::Normal, and Gui::PythonConsoleP::type.
Referenced by contextMenuEvent().
◆ onFlush
|
slot |
References Flush.
◆ onInsertFileName
|
slot |
References Gui::getMainWindow(), and Gui::FileDialog::getOpenFileName().
Referenced by contextMenuEvent().
◆ onSaveHistoryAs
|
slot |
◆ overrideCursor()
|
protected |
◆ pendingSource
|
signal |
Referenced by readline().
◆ printStatement()
void PythonConsole::printStatement | ( | const QString & | cmd | ) |
Prints the Python statement cmd to the console.
- Note
- The statement gets only printed and added to the history but not invoked.
References Gui::ConsoleHistory::append(), Complete, Gui::PythonConsoleP::history, Gui::PythonConsoleP::interactive, and Gui::PythonConsoleP::statements.
Referenced by Gui::MacroManager::addLine(), and dropEvent().
◆ readline()
QString PythonConsole::readline | ( | void | ) |
References Gui::PythonConsoleP::output, pendingSource(), and Special.
Referenced by Gui::PythonStdin::readline().
◆ showEvent()
|
protected |
Shows the Python window and sets the focus to set text cursor.
Friends And Related Function Documentation
◆ PythonStderr
|
friend |
Referenced by PythonConsole().
◆ PythonStdout
|
friend |
Referenced by PythonConsole().
The documentation for this class was generated from the following files:
- src/Gui/PythonConsole.h
- src/Gui/PythonConsole.cpp