itom
Loading...
Searching...
No Matches
ito::ConsoleWidget Class Reference
Inheritance diagram for ito::ConsoleWidget:
ito::AbstractCodeEditorWidget ito::CodeEditor

Classes

struct  CmdQueueItem
 
struct  InputTextMode
 
struct  StreamBuffer
 

Public Slots

virtual void copy ()
 
virtual void paste ()
 
virtual void cut ()
 
void receiveStream (QString text, ito::tStreamMessageType msgType)
 
void pythonRunSelection (QString selectionText)
 
void pythonStateChanged (tPythonTransitions pyTransition)
 
void clearCommandLine ()
 
void interruptCommandInput ()
 
void startInputCommandLine (QSharedPointer< QByteArray > buffer, ItomSharedSemaphore *inputWaitCond)
 
- Public Slots inherited from ito::AbstractCodeEditorWidget
void reloadSettings ()
 

Signals

void wantToCopy ()
 
void sendToLastCommand (QString cmd)
 
- Signals inherited from ito::AbstractCodeEditorWidget
void userSelectionChanged (int lineFrom, int indexFrom, int lineTo, int indexTo)
 
- Signals inherited from ito::CodeEditor
void dirtyChanged (bool state)
 
void painted (QPaintEvent *e)
 
void keyPressed (QKeyEvent *e)
 
void keyReleased (QKeyEvent *e)
 
void postKeyPressed (QKeyEvent *e)
 
void mouseDoubleClicked (QMouseEvent *e)
 
void mousePressed (QMouseEvent *e)
 
void mouseReleased (QMouseEvent *e)
 
void mouseMoved (QMouseEvent *e)
 
void mouseWheelActivated (QWheelEvent *e)
 
void focusedIn (QFocusEvent *e)
 
void indentRequested ()
 
void unindentRequested ()
 
void updateRequest ()
 
void updateActions ()
 
void newTextSet ()
 Signal emitted when a new text is set on the widget.
 

Public Member Functions

 ConsoleWidget (QWidget *parent=nullptr)
 
virtual QString codeText (int &line, int &column) const
 
- Public Member Functions inherited from ito::AbstractCodeEditorWidget
 AbstractCodeEditorWidget (QWidget *parent=NULL)
 
QString getWordAtPosition (const int &line, const int &index) const
 
virtual void copy ()
 copy selected code to the clipboard
 
virtual void paste ()
 paste code from the clipboard at the current cursor position
 
virtual void cut ()
 cut selected code and puts it into the clipboard
 
- Public Member Functions inherited from ito::CodeEditor
 CodeEditor (QWidget *parent=NULL, bool createDefaultActions=true)
 
bool useSpacesInsteadOfTabs () const
 
void setUseSpacesInsteadOfTabs (bool value)
 
bool selectLineOnCopyEmpty () const
 
void setSelectLineOnCopyEmpty (bool value)
 
bool showContextMenu () const
 
void setShowContextMenu (bool value)
 
bool showWhitespaces () const
 
void setShowWhitespaces (bool value)
 
QString fontName () const
 
void setFontName (const QString &value)
 
int fontSize () const
 
void setFontSize (int fontSize)
 
int zoomLevel () const
 
void setZoomLevel (int value)
 
int tabLength () const
 
void setTabLength (int value)
 
QColor background () const
 
void setBackground (const QColor &value)
 
QColor foreground () const
 
void setForeground (const QColor &value)
 
QColor selectionForeground () const
 
void setSelectionForeground (const QColor &value)
 
QColor selectionBackground () const
 
void setSelectionBackground (const QColor &value)
 
QColor whitespacesForeground () const
 
void setWhitespacesForeground (const QColor &value)
 
bool saveOnFocusOut () const
 
void setSaveOnFocusOut (bool value)
 
EdgeMode edgeMode () const
 
void setEdgeMode (EdgeMode mode)
 
int edgeColumn () const
 
void setEdgeColumn (int column)
 
QColor edgeColor () const
 
void setEdgeColor (const QColor &color)
 
bool showIndentationGuides () const
 
void setShowIndentationGuides (bool value)
 
QColor indentationGuidesColor () const
 
void setIndentationGuidesColor (const QColor &color)
 
QList< VisibleBlockvisibleBlocks () const
 
bool dirty () const
 
int firstVisibleLine () const
 
void setFirstVisibleLine (int line)
 
bool isModified () const
 
void setModified (bool modified)
 
QString wordSeparators () const
 
bool isUndoAvailable () const
 
bool isRedoAvailable () const
 
void setMouseCursor (const QCursor &cursor)
 
void cursorPosition (int &line, int &column) const
 
void setViewportMargins (int left, int top, int right, int bottom)
 
QRectF blockBoundingGeometry (const QTextBlock &block) const
 
QPointF contentOffset () const
 
PanelsManagerpanels () const
 
TextDecorationsManagerdecorations () const
 
ModesManagermodes () const
 
SyntaxHighlighterBasesyntaxHighlighter () const
 
int currentLineNumber () const
 
int currentColumnNumber () const
 
int lineNbrFromPosition (int yPos) const
 
int lineCount () const
 
int lineLength (int line) const
 
QTextCursor selectWholeLine (int line=-1, bool applySelection=true)
 
QTextCursor selectLines (int start=0, int end=-1, bool applySelection=true)
 
QPair< int, int > selectionRange () const
 
void getSelection (int *lineFrom, int *indexFrom, int *lineTo, int *indexTo)
 
void setSelection (int lineFrom, int indexFrom, int lineTo, int indexTo)
 
bool hasSelectedText () const
 
int linePosFromNumber (int lineNumber) const
 
void lineIndexFromPosition (const QPoint &pos, int *line, int *column) const
 
void lineIndexFromPosition (int pos, int *line, int *column) const
 
void getCursorPosition (int *line, int *column) const
 
QTextCursor setCursorPosition (int line, int column, bool applySelection=true)
 
void unfoldCursorPosition ()
 
void ensureLineVisible (int line)
 
QTextCursor gotoLine (int line, int column, bool move=true)
 
void removeSelectedText ()
 
bool findFirst (const QString &expr, bool re, bool cs, bool wo, bool wrap, bool forward=true, int line=-1, int index=-1, bool show=true)
 
bool findNext ()
 
void replace (const QString &text)
 
void endUndoAction ()
 
void beginUndoAction ()
 
QString selectedText () const
 
int length () const
 
int positionFromLineIndex (int line, int column) const
 
int lineIndent (int lineNumber=-1) const
 
int lineIndent (const QTextBlock *lineNbr) const
 
QString lineText (int lineIdx) const
 
void markWholeDocDirty ()
 
void callResizeEvent (QResizeEvent *evt)
 
void indent ()
 
void unindent ()
 
void resetStylesheet ()
 
void rehighlight ()
 
void rehighlightBlock (int lineFromIdx, int lineToIdx)
 
void showTooltip (const QPoint &pos, const QString &tooltip)
 
void showTooltip (const QPoint &pos, const QString &tooltip, const TextDecoration::Ptr &senderDeco)
 
void setPlainText (const QString &text, const QString &mimeType="", const QString &encoding="")
 
void insertAt (const QString &text, int line, int index)
 
void append (const QString &text)
 
bool isCommentOrString (const QTextCursor &cursor, const QList< StyleItem::StyleType > &formats=QList< StyleItem::StyleType >())
 
bool isCommentOrString (const QTextBlock &block, const QList< StyleItem::StyleType > &formats=QList< StyleItem::StyleType >())
 
bool isNumber (const QTextCursor &cursor) const
 
bool isNumber (const QTextBlock &block) const
 
QTextCursor wordUnderCursor (bool selectWholeWord) const
 
QTextCursor wordUnderCursor (const QTextCursor &cursor, bool selectWholeWord) const
 
QString wordAtPosition (int line, int index, bool selectWholeWord) const
 
QTextCursor wordUnderMouseCursor () const
 
TextBlockUserDatagetTextBlockUserData (int lineIndex, bool createIfNotExist=true)
 
TextBlockUserDatagetTextBlockUserData (QTextBlock &block, bool createIfNotExist=true)
 
QSet< TextBlockUserData * > & textBlockUserDataList ()
 
const QSet< TextBlockUserData * > & textBlockUserDataList () const
 
const TextBlockUserDatagetConstTextBlockUserData (int lineIndex) const
 
virtual bool removeTextBlockUserData (TextBlockUserData *userData)
 
bool bookmarksAvailable () const
 
bool breakpointsAvailable () const
 
void callWheelEvent (QWheelEvent *e)
 
void reportPositionAsGoBackNavigationItem (const QTextCursor &cursor, const QString &reason) const
 

Static Public Attributes

static const QString lineBreak = QString("\n")
 < constants
 
static const QString newCommandPrefix = QString(">>")
 

Protected Member Functions

virtual void loadSettings ()
 
virtual void contextMenuAboutToShow (int contextMenuLine)
 
virtual int startLineOffset (int lineIdx) const
 
void initMenus ()
 
virtual bool keyPressInternalEvent (QKeyEvent *event)
 
void dropEvent (QDropEvent *event)
 
void dragEnterEvent (QDragEnterEvent *event)
 
void dragMoveEvent (QDragMoveEvent *event)
 
void wheelEvent (QWheelEvent *event)
 
bool canInsertFromMimeData (const QMimeData *source) const
 
void mouseDoubleClickEvent (QMouseEvent *e)
 
- Protected Member Functions inherited from ito::AbstractCodeEditorWidget
void init ()
 
QString formatCodeBeforeInsertion (const QString &text, int &lineCount, bool trimText=false, const QString &newIndent="") const
 
QString formatCodeForClipboard (const QString &code, const QString &prependedTextInFirstLine) const
 this method modifies a code string such before copying it to the clipboard or a mimedata.
 
QPixmap loadMarker (const QString &name, int sizeAt96dpi) const
 
- Protected Member Functions inherited from ito::CodeEditor
CodeEditoroperator= (const CodeEditor &)
 
QMenu * contextMenu () const
 
void showTooltipDelayJobRunner (QList< QVariant > args)
 
void initSettings ()
 
void initStyle ()
 
QString previousLineText () const
 
QString currentLineText () const
 
void setWhitespacesFlags (bool show)
 
void updateTabStopAndIndentationWidth ()
 
void updateVisibleBlocks ()
 
void doHomeKey (QEvent *event=NULL, bool select=false)
 
QTextCursor moveCursorTo (int line) const
 
virtual void reportGoBackNavigationCursorMovement (const CursorPosition &cursor, const QString &origin) const
 
virtual void resizeEvent (QResizeEvent *e)
 
virtual void closeEvent (QCloseEvent *e)
 
virtual void keyPressEvent (QKeyEvent *e)
 
virtual void keyReleaseEvent (QKeyEvent *e)
 
virtual void mousePressEvent (QMouseEvent *e)
 
virtual void mouseReleaseEvent (QMouseEvent *e)
 
virtual void mouseMoveEvent (QMouseEvent *e)
 
virtual void showEvent (QShowEvent *e)
 
virtual void paintEvent (QPaintEvent *e)
 
virtual void contextMenuEvent (QContextMenuEvent *e)
 
virtual void focusInEvent (QFocusEvent *e)
 
virtual void focusOutEvent (QFocusEvent *e)
 
virtual bool eventFilter (QObject *obj, QEvent *e)
 

Private Slots

void selChanged ()
 
void textDoubleClicked (int position, int line, int modifiers)
 
void clearAndStartNewCommand ()
 
void toggleAutoWheel (bool enable)
 
void processStreamBuffer ()
 

Private Member Functions

RetVal initEditor ()
 
RetVal clearEditor ()
 
RetVal startNewCommand (bool clearEditorFirst=false)
 < new command is a new line starting with ">>" (newCommandPrefix)
 
RetVal execCommand (int lineBegin, int lineEnd)
 
RetVal useCmdListCommand (int dir)
 
RetVal executeCmdQueue ()
 
void autoLineDelete ()
 delete the first N lines if the command line has more than M (M>=N) lines
 
void moveCursorToEnd ()
 
void moveCursorToValidRegion ()
 
int checkValidDropRegion (const QPoint &pos)
 
void enableInputTextMode ()
 
void disableInputTextMode ()
 
QList< ito::TextBlockUserData::AnsiTextCharFormatparseReceiveStreamBufferForAnsiCodes (const QString &inputText, QString &strippedText)
 
QList< QSharedPointer< QList< ito::TextBlockUserData::AnsiTextCharFormat > > > handleTextLinesAndSplitLongLines (QString &text, const QList< ito::TextBlockUserData::AnsiTextCharFormat > &ansiTextCharFormat, bool smartSplitting)
 
QList< QSharedPointer< QList< ito::TextBlockUserData::AnsiTextCharFormat > > > splitLongLinesText (QString &text, const QSharedPointer< QList< ito::TextBlockUserData::AnsiTextCharFormat > > &ansiTextCharFormat, bool smartSplitting)
 
void updateAnsiTextCharFormat (ito::TextBlockUserData::AnsiTextCharFormat &format, const QString &mainChar, const QString &args)
 

Private Attributes

int m_startLineBeginCmd
 zero-based, first-line of actual (not evaluated command), last line which starts with ">>", -1: no command active
 
DequeCommandListm_pCmdList
 
std::queue< CmdQueueItemm_cmdQueue
 upcoming events to handle
 
bool m_canCopy
 
bool m_canCut
 
StreamBuffer m_receiveStreamBuffer
 
QTimer m_receiveStreamBufferTimer
 
bool m_splitLongLines
 
int m_splitLongLinesMaxLength
 
CmdQueueItem m_currentlyExecutedCommand
 
QSharedPointer< LineBackgroundMarkerModem_markErrorLineMode
 
QSharedPointer< LineBackgroundMarkerModem_markCurrentLineMode
 
QSharedPointer< LineBackgroundMarkerModem_markInputLineMode
 
QSharedPointer< LineNumberPanelm_lineNumberPanel
 
bool m_waitForCmdExecutionDone
 true: command in this console is being executed and sends a finish-event, when done.
 
bool m_pythonBusy
 true: python is executing or debugging a script, a command...
 
QString m_temporaryRemovedCommands
 removed commands, if python busy, caused by another console instance or script (we assume that these removed commands are always python commands and no printed text)
 
ItomSharedSemaphorem_inputStreamWaitCond
 if this is != NULL, a input(...) command is currently running in Python and the command line is ready to receive inputs from the user.
 
QSharedPointer< QByteArray > m_inputStreamBuffer
 
int m_inputStartLine
 if python-input command is currently used to ask for user-input, this variable holds the line of the input command
 
int m_inputStartCol
 if python-input command is currently used to ask for user-input, this variable holds the column in line m_inputStartLine, where the first input character starts
 
bool m_autoWheel
 true if command line should automatically move to the last line if new lines are appended, this is set to false upon a wheel event and will be reset to true if the command line is cleared (clc) or if a new input is added
 
QMap< QString, QAction * > m_contextMenuActions
 
InputTextMode m_inputTextMode
 
ito::TextBlockUserData::AnsiTextCharFormat m_recentAnsiTextCharFormat
 
QRegularExpression m_ansiEscapeSeqRegExp
 
bool m_considerAnsiEscapeSequences
 

Static Private Attributes

static const QString longLineWrapPrefix = QString("... ")
 

Additional Inherited Members

- Public Types inherited from ito::CodeEditor
enum  EdgeMode { EdgeNone , EdgeLine , EdgeBackground }
 
- Protected Types inherited from ito::AbstractCodeEditorWidget
enum  tUserSelectionState { selNo , selRange }
 
- Protected Attributes inherited from ito::AbstractCodeEditorWidget
tUserSelectionState m_userSelectionState
 
QSharedPointer< SyntaxHighlighterBasem_pythonSyntaxHighlighter
 
QSharedPointer< CodeEditorStylem_editorStyle
 
QSharedPointer< SymbolMatcherModem_symbolMatcher
 
QSharedPointer< CaretLineHighlighterModem_caretLineHighlighter
 
QSharedPointer< PyCalltipsModem_calltipsMode
 
QSharedPointer< CodeCompletionModem_codeCompletionMode
 
QSharedPointer< PyAutoIndentModem_pyAutoIndentMode
 
QSharedPointer< PyCodeReferenceRenamerm_pyCodeReferenceRenamer
 

Constructor & Destructor Documentation

◆ ConsoleWidget()

ito::ConsoleWidget::ConsoleWidget ( QWidget * parent = nullptr)

< empty queue

Member Function Documentation

◆ checkValidDropRegion()

int ito::ConsoleWidget::checkValidDropRegion ( const QPoint & pos)
private

< pos is below last line

< mouse over margin left

< mouse at the end of this line

◆ codeText()

QString ito::ConsoleWidget::codeText ( int & line,
int & column ) const
virtual

Reimplemented from ito::CodeEditor.

◆ contextMenuAboutToShow()

void ito::ConsoleWidget::contextMenuAboutToShow ( int contextMenuLine)
protectedvirtual

Reimplemented from ito::CodeEditor.

◆ dragMoveEvent()

void ito::ConsoleWidget::dragMoveEvent ( QDragMoveEvent * event)
protected

< if text selected in this widget, starting point before valid region and move action -> ignore

< check, that selections are only in valid area

◆ dropEvent()

void ito::ConsoleWidget::dropEvent ( QDropEvent * event)
protected

< if text selected in this widget, starting point before valid region and move action -> ignore

< check, that selections are only in valid area

◆ keyPressInternalEvent()

bool ito::ConsoleWidget::keyPressInternalEvent ( QKeyEvent * event)
protectedvirtual

‍reimplementation to process the keyReleaseEvent

< no action necessary

‍return pressed

< new line for possible error or message

< do not emit keyPressEvent in QsciScintilla!!

< do not emit keyPressEvent in QsciScintilla!!

< do not emit keyPressEvent in QsciScintilla!!

< check that del and backspace is only pressed in valid cursor context

< no selection

< check that del and backspace is only pressed in valid cursor context

< no action necessary

Reimplemented from ito::CodeEditor.

◆ loadSettings()

void ito::ConsoleWidget::loadSettings ( )
protectedvirtual

Reimplemented from ito::AbstractCodeEditorWidget.

◆ mouseDoubleClickEvent()

void ito::ConsoleWidget::mouseDoubleClickEvent ( QMouseEvent * e)
protectedvirtual

Reimplemented from ito::CodeEditor.

◆ moveCursorToValidRegion()

void ito::ConsoleWidget::moveCursorToValidRegion ( )
private

< check, that selections are only in valid area

◆ processStreamBuffer

void ito::ConsoleWidget::processStreamBuffer ( )
privateslot

‍insert msg after last line

◆ startLineOffset()

int ito::ConsoleWidget::startLineOffset ( int lineIdx) const
protectedvirtual

Reimplemented from ito::AbstractCodeEditorWidget.

◆ startNewCommand()

RetVal ito::ConsoleWidget::startNewCommand ( bool clearEditorFirst = false)
private

< new command is a new line starting with ">>" (newCommandPrefix)

< empty editor, just start new command

< append at the end of the existing text

◆ wheelEvent()

void ito::ConsoleWidget::wheelEvent ( QWheelEvent * event)
protectedvirtual

Reimplemented from ito::CodeEditor.


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