Gui::PythonConsole Class Reference

#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)
 
- Signals inherited from Gui::TextEdit
void findNext ()
 
void findPrevious ()
 
void showSearchBar ()
 

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=nullptr)
 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=nullptr)
 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

Enumerator
Complete 
Incomplete 
Flush 
Special 

Constructor & Destructor Documentation

◆ PythonConsole()

◆ ~PythonConsole()

PythonConsole::~PythonConsole ( )

Member Function Documentation

◆ canInsertFromMimeData()

bool PythonConsole::canInsertFromMimeData ( const QMimeData *  source) const
protected

Referenced by contextMenuEvent().

◆ changeEvent()

◆ contextMenuEvent()

◆ createMimeDataFromSelection()

◆ dragEnterEvent()

void PythonConsole::dragEnterEvent ( QDragEnterEvent *  e)
protected

Dragging of action objects is allowed.

◆ dragMoveEvent()

void PythonConsole::dragMoveEvent ( QDragMoveEvent *  e)
protected

Dragging of action objects is allowed.

◆ dropEvent()

void PythonConsole::dropEvent ( QDropEvent *  e)
protected

Drops the event e and writes the right Python command.

References printStatement().

◆ inputBegin()

QTextCursor PythonConsole::inputBegin ( void  ) const
protected

◆ insertFromMimeData()

void PythonConsole::insertFromMimeData ( const QMimeData *  source)
protected

Allow to paste plain text or urls of text files.

◆ keyPressEvent()

void PythonConsole::keyPressEvent ( QKeyEvent *  e)
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()

void PythonConsole::mouseReleaseEvent ( QMouseEvent *  e)
protected

References inputBegin().

◆ OnChange()

void PythonConsole::OnChange ( Base::Subject< const char * > &  rCaller,
const char *  rcReason 
)

◆ onClearConsole

void PythonConsole::onClearConsole ( )
slot

◆ onCopyCommand

void PythonConsole::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

void PythonConsole::onCopyHistory ( )
slot

◆ onFlush

void PythonConsole::onFlush ( )
slot

References Flush.

◆ onInsertFileName

void PythonConsole::onInsertFileName ( )
slot

◆ onSaveHistoryAs

◆ overrideCursor()

void PythonConsole::overrideCursor ( const QString &  txt)
protected

Overwrites the text of the cursor.

References inputBegin().

Referenced by keyPressEvent().

◆ pendingSource

void Gui::PythonConsole::pendingSource ( void  )
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  )

◆ showEvent()

void PythonConsole::showEvent ( QShowEvent *  e)
protected

Shows the Python window and sets the focus to set text cursor.

Friends And Related Function Documentation

◆ PythonStderr

friend class PythonStderr
friend

Referenced by PythonConsole().

◆ PythonStdout

friend class PythonStdout
friend

Referenced by PythonConsole().


The documentation for this class was generated from the following files: