![]() |
HAL
|
A plain text edit widget that is intended for editing code. More...
#include <code_editor.h>
Public Slots | |
void | search (const QString &string, SearchOptions searchOpts=8) |
void | toggleLineNumbers () |
void | toggleMinimap () |
void | setFontSize (int pt) |
Protected Member Functions | |
virtual void | resizeEvent (QResizeEvent *event) override |
![]() | |
virtual void | keyPressEvent (QKeyEvent *e) override |
virtual void | keyReleaseEvent (QKeyEvent *e) override |
virtual void | paintEvent (QPaintEvent *e) override |
virtual void | mousePressEvent (QMouseEvent *e) override |
virtual void | mouseMoveEvent (QMouseEvent *e) override |
virtual void | mouseReleaseEvent (QMouseEvent *e) override |
virtual void | mouseDoubleClickEvent (QMouseEvent *e) override |
virtual bool | focusNextPrevChild (bool next) override |
virtual void | contextMenuEvent (QContextMenuEvent *event) override |
virtual void | dragEnterEvent (QDragEnterEvent *e) override |
virtual void | dragLeaveEvent (QDragLeaveEvent *e) override |
virtual void | dragMoveEvent (QDragMoveEvent *e) override |
virtual void | dropEvent (QDropEvent *e) override |
virtual void | focusInEvent (QFocusEvent *e) override |
virtual void | focusOutEvent (QFocusEvent *e) override |
virtual void | showEvent (QShowEvent *) override |
virtual void | changeEvent (QEvent *e) override |
virtual void | wheelEvent (QWheelEvent *e) override |
virtual QMimeData * | createMimeDataFromSelection () const const |
virtual bool | canInsertFromMimeData (const QMimeData *source) const const |
virtual void | insertFromMimeData (const QMimeData *source) |
virtual void | inputMethodEvent (QInputMethodEvent *e) override |
virtual void | scrollContentsBy (int dx, int dy) override |
QTextBlock | firstVisibleBlock () const const |
QPointF | contentOffset () const const |
QRectF | blockBoundingRect (const QTextBlock &block) const const |
QRectF | blockBoundingGeometry (const QTextBlock &block) const const |
QAbstractTextDocumentLayout::PaintContext | getPaintContext () const const |
![]() | |
void | setViewportMargins (int left, int top, int right, int bottom) |
void | setViewportMargins (const QMargins &margins) |
QMargins | viewportMargins () const const |
virtual bool | event (QEvent *event) override |
virtual bool | viewportEvent (QEvent *event) |
virtual QSize | viewportSizeHint () const const |
![]() | |
void | initStyleOption (QStyleOptionFrame *option) const const |
![]() | |
virtual void | enterEvent (QEvent *event) |
virtual void | leaveEvent (QEvent *event) |
virtual void | moveEvent (QMoveEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | actionEvent (QActionEvent *event) |
virtual void | hideEvent (QHideEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual int | metric (QPaintDevice::PaintDeviceMetric m) const const override |
virtual void | initPainter (QPainter *painter) const const override |
void | updateMicroFocus () |
void | create (WId window, bool initializeWindow, bool destroyOldWindow) |
void | destroy (bool destroyWindow, bool destroySubWindows) |
bool | focusNextChild () |
bool | focusPreviousChild () |
![]() | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
![]() | |
QPaintDevice () | |
Additional Inherited Members | |
![]() | |
enum | LineWrapMode |
![]() | |
enum | SizeAdjustPolicy |
![]() | |
enum | Shape |
enum | Shadow |
enum | StyleMask |
![]() | |
enum | RenderFlag |
![]() | |
enum | PaintDeviceMetric |
![]() | |
void | setTabOrder (QWidget *first, QWidget *second) |
QWidget * | mouseGrabber () |
QWidget * | keyboardGrabber () |
QWidget * | find (WId id) |
QWidget * | createWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags) |
![]() | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
![]() | |
NoWrap | |
WidgetWidth | |
![]() | |
AdjustIgnored | |
AdjustToContentsOnFirstShow | |
AdjustToContents | |
![]() | |
NoFrame | |
Box | |
Panel | |
WinPanel | |
HLine | |
VLine | |
StyledPanel | |
Plain | |
Raised | |
Sunken | |
Shadow_Mask | |
Shape_Mask | |
![]() | |
typedef | RenderFlags |
DrawWindowBackground | |
DrawChildren | |
IgnoreMask | |
![]() | |
typedef | QObjectList |
![]() | |
PdmWidth | |
PdmHeight | |
PdmWidthMM | |
PdmHeightMM | |
PdmNumColors | |
PdmDepth | |
PdmDpiX | |
PdmDpiY | |
PdmPhysicalDpiX | |
PdmPhysicalDpiY | |
PdmDevicePixelRatio | |
PdmDevicePixelRatioScaled | |
A plain text edit widget that is intended for editing code.
Therefore it has numbered lines and provides a code minimap for easier navigation in larger files. Moreover it supports a search function to mark all occurrences of a specified string.
Definition at line 51 of file code_editor.h.
|
explicit |
Constructor.
parent | - The parent widget |
Definition at line 25 of file code_editor.cpp.
References QPlainTextEdit::blockCountChanged(), QObject::connect(), QPlainTextEdit::cursorPositionChanged(), QPlainTextEdit::document(), QWidget::ensurePolished(), QAbstractScrollArea::horizontalScrollBar(), QObject::installEventFilter(), Qt::NoContextMenu, QFrame::NoFrame, QPlainTextEdit::NoWrap, hal::CodeEditorMinimap::scrollbar(), QWidget::setContextMenuPolicy(), QTextDocument::setDocumentMargin(), QVariantAnimation::setDuration(), QFrame::setFrameStyle(), QPlainTextEdit::setLineWrapMode(), hal::CodeEditorScrollbar::setMinimapScrollbar(), hal::MinimapScrollbar::setScrollbar(), QAbstractScrollArea::setVerticalScrollBar(), QPlainTextEdit::updateRequest(), and QPlainTextEdit::WidgetWidth.
void hal::CodeEditor::centerOnLine | ( | const int | number | ) |
Scrolls to the specified line number using a scroll animation.
number | - The number to scroll to |
Definition at line 268 of file code_editor.cpp.
References QPlainTextEdit::document(), QTextDocument::lineCount(), QAbstractAnimation::Running, QVariantAnimation::setEndValue(), QVariantAnimation::setStartValue(), QAbstractAnimation::start(), QAbstractAnimation::state, QAbstractAnimation::stop(), and QAbstractScrollArea::verticalScrollBar().
Referenced by hal::CodeEditorMinimap::mousePressEvent().
QColor hal::CodeEditor::currentLineBackground | ( | ) | const |
Definition at line 325 of file code_editor.cpp.
Captures the mouse scroll event to zoom in and out via CTRL+SCROLL UP/DOWN.
object | - The object this filter is applied on. |
event | - The event to filter |
Reimplemented from QObject.
Definition at line 64 of file code_editor.cpp.
References Qt::ControlModifier, QWheelEvent::delta(), QAbstractScrollArea::event(), QInputEvent::modifiers(), QEvent::Wheel, QPlainTextEdit::zoomIn(), and QPlainTextEdit::zoomOut().
int hal::CodeEditor::first_visible_block | ( | ) |
Returns the index of the first visible block.
Definition at line 263 of file code_editor.cpp.
References QTextBlock::blockNumber(), and QPlainTextEdit::firstVisibleBlock().
Referenced by hal::CodeEditorMinimap::paintEvent().
void hal::CodeEditor::handleWheelEvent | ( | QWheelEvent * | event | ) |
This function can be used to pass a wheel event to the code editor. It is necessary for widgets that are associated with the code editor but are not part of it (e.g. the line number area or the minimap).
event | - The wheel event to pass to the code editor |
Definition at line 290 of file code_editor.cpp.
References QAbstractScrollArea::event(), and QPlainTextEdit::wheelEvent().
Referenced by hal::CodeEditorMinimap::wheelEvent(), and hal::LineNumberArea::wheelEvent().
void hal::CodeEditor::lineNumberAreaPaintEvent | ( | QPaintEvent * | event | ) |
Paint event handler to paint the line numbers. This function is called when an paint event of the line number area occurs. It draws the necessary line numbers in the line number area.
event | - The paint event |
Definition at line 85 of file code_editor.cpp.
References Qt::AlignRight, Qt::AlignVCenter, QPlainTextEdit::blockBoundingGeometry(), QTextBlock::blockNumber(), hal::bottom, QPlainTextEdit::contentOffset(), QPainter::drawText(), QPlainTextEdit::firstVisibleBlock(), QRectF::height(), QWidget::height, QTextBlock::isValid(), QTextBlock::isVisible(), QTextBlock::next(), QString::number(), hal::LineNumberArea::rightOffset, QPen::setColor(), QPainter::setFont(), QPainter::setPen(), QRectF::top(), QRectF::translated(), and QWidget::width.
Referenced by hal::LineNumberArea::paintEvent().
int hal::CodeEditor::lineNumberAreaWidth | ( | ) |
Gets the width of area where the line numbers are drawn.
Definition at line 121 of file code_editor.cpp.
References QPlainTextEdit::blockCount, hal::LineNumberArea::leftOffset, QString::number(), hal::LineNumberArea::rightOffset, and QFontMetrics::width().
QColor hal::CodeEditor::lineNumberBackground | ( | ) | const |
Definition at line 310 of file code_editor.cpp.
QColor hal::CodeEditor::lineNumberColor | ( | ) | const |
Definition at line 305 of file code_editor.cpp.
QFont hal::CodeEditor::lineNumberFont | ( | ) | const |
Definition at line 300 of file code_editor.cpp.
QColor hal::CodeEditor::lineNumberHighlightBackground | ( | ) | const |
Definition at line 320 of file code_editor.cpp.
QColor hal::CodeEditor::lineNumberHighlightColor | ( | ) | const |
Definition at line 315 of file code_editor.cpp.
CodeEditorMinimap * hal::CodeEditor::minimap | ( | ) |
Accesses the code editors minimap.
Definition at line 295 of file code_editor.cpp.
Referenced by hal::PythonEditor::handleActionNewTab().
void hal::CodeEditor::minimapPaintEvent | ( | QPaintEvent * | event | ) |
Paint event handler to paint the line numbers.
event | - The paint event |
Definition at line 114 of file code_editor.cpp.
References QAbstractScrollArea::event().
int hal::CodeEditor::minimapWidth | ( | ) |
Gets the width of the minimap.
Definition at line 128 of file code_editor.cpp.
|
overrideprotectedvirtual |
Captures the resize event to adjust the slider size of the minimap.
event | - The resize event |
Reimplemented from QPlainTextEdit.
Definition at line 133 of file code_editor.cpp.
References hal::CodeEditorMinimap::adjustSliderHeight(), QPlainTextEdit::blockBoundingGeometry(), QPlainTextEdit::document(), QAbstractScrollArea::event(), QRectF::height(), QWidget::height, QPlainTextEdit::resizeEvent(), and QAbstractScrollArea::viewport().
|
slot |
Marks all occurrences of the specified string in the code editor.
string | - The string to mark |
options | - Optional QTextDocument::FindFlags (e.g. "FindCaseSensitively" or "FindWholeWords") |
Definition at line 207 of file code_editor.cpp.
References Qt::CaseInsensitive, QRegularExpression::CaseInsensitiveOption, Qt::CaseSensitive, QPlainTextEdit::extraSelections(), QPlainTextEdit::find(), QTextDocument::FindCaseSensitively, QTextDocument::FindFlags, QTextDocument::FindWholeWords, hal::SearchOptions::isCaseSensitive(), hal::SearchOptions::isExactMatch(), hal::SearchOptions::isRegularExpression(), QPlainTextEdit::moveCursor(), QRegularExpression::NoPatternOption, QPlainTextEdit::setExtraSelections(), QTextCursor::Start, and QPlainTextEdit::textCursor().
Referenced by hal::PythonEditor::handleCurrentTabChanged().
void hal::CodeEditor::setCurrentLineBackground | ( | QColor & | color | ) |
Definition at line 355 of file code_editor.cpp.
|
slot |
Configures the font size of the code editor.
pt | - The new font size |
Definition at line 283 of file code_editor.cpp.
References QWidget::font, and QWidget::setFont().
Referenced by hal::PythonEditor::handleActionNewTab().
void hal::CodeEditor::setHighlightCurrentLineEnabled | ( | bool | enabled | ) |
Enables or disables the highlight of the current line.
enabled | - True to enable, False to disable. |
Definition at line 394 of file code_editor.cpp.
References QObject::connect(), QPlainTextEdit::cursorPositionChanged(), QObject::disconnect(), and QWidget::enabled.
Referenced by hal::PythonEditor::handleActionNewTab().
void hal::CodeEditor::setLineNumberBackground | ( | QColor & | color | ) |
Definition at line 340 of file code_editor.cpp.
void hal::CodeEditor::setLineNumberColor | ( | QColor & | color | ) |
Definition at line 335 of file code_editor.cpp.
void hal::CodeEditor::setLineNumberEnabled | ( | bool | enabled | ) |
Enables or disables the line numbers.
enabled | - True to enable, False to disable. |
Definition at line 388 of file code_editor.cpp.
References QWidget::enabled.
Referenced by hal::PythonEditor::handleActionNewTab().
void hal::CodeEditor::setLineNumberFont | ( | const QFont & | font | ) |
Definition at line 330 of file code_editor.cpp.
References QWidget::font.
void hal::CodeEditor::setLineNumberHighlightBackground | ( | QColor & | color | ) |
Definition at line 350 of file code_editor.cpp.
void hal::CodeEditor::setLineNumberHighlightColor | ( | QColor & | color | ) |
Definition at line 345 of file code_editor.cpp.
void hal::CodeEditor::setLineWrapEnabled | ( | bool | enabled | ) |
Enables or disables the linewrap.
enabled | - True to enable, False to disable. |
Definition at line 412 of file code_editor.cpp.
References QWidget::enabled, QPlainTextEdit::NoWrap, QPlainTextEdit::setLineWrapMode(), and QPlainTextEdit::WidgetWidth.
Referenced by hal::PythonEditor::handleActionNewTab().
void hal::CodeEditor::setMinimapEnabled | ( | bool | enabled | ) |
Enables or disables the minimap.
enabled | - True to enable, False to disable. |
Definition at line 419 of file code_editor.cpp.
References QWidget::enabled.
Referenced by hal::PythonEditor::handleActionNewTab().
|
slot |
Shows/Hides the line numbers at the left side of the code editor.
Definition at line 251 of file code_editor.cpp.
|
slot |
Shows/Hides the minimap of the code editor.
Definition at line 257 of file code_editor.cpp.
|
readwrite |
Definition at line 1 of file code_editor.h.
|
readwrite |
Definition at line 1 of file code_editor.h.
|
readwrite |
Definition at line 1 of file code_editor.h.
|
readwrite |
Definition at line 1 of file code_editor.h.
|
readwrite |
Definition at line 1 of file code_editor.h.
|
readwrite |
Definition at line 1 of file code_editor.h.