Include file:

#include "mcrl2/gui/codeeditor.h
class mcrl2::gui::qt::CodeEditor

The CodeEditor class defines a text editor for code (used for specification and properties)

Private attributes

QFont mcrl2::gui::qt::CodeEditor::codeFont
CodeHighlighter *mcrl2::gui::qt::CodeEditor::highlighter
bool mcrl2::gui::qt::CodeEditor::isSpecificationEditor
bool mcrl2::gui::qt::CodeEditor::lightPalette
LineNumberArea *mcrl2::gui::qt::CodeEditor::lineNumberArea
QFont mcrl2::gui::qt::CodeEditor::lineNumberFont
QAction *mcrl2::gui::qt::CodeEditor::zoomInAction
QAction *mcrl2::gui::qt::CodeEditor::zoomOutAction

Public member functions

void changeHighlightingRules()

changeHighlightingRules Change the highlighting rules depending on the purpose of the code editor and its colour palette

CodeEditor(QWidget *parent = 0)

CodeEditor Constructor.


  • parent The parent of this widget
void lineNumberAreaPaintEvent(QPaintEvent *event)

lineNumberAreaPaintEvent Paints the line number area on the screen


  • event A paint event
int lineNumberAreaWidth()

lineNumberAreaWidth Computes the width needed for the line number area

Returns: The width needed for the line number area

void setPurpose(bool isSpecificationEditor)

setPurpose Set whether this code editor is for editing specifications or mu-calculus formulae


  • isSpecificationEditor Whether this code editor is for editing specifications



deleteChar Allows the user to delete text


zoomIn Allows the user to zoom in on the text


  • range How much to zoom in


zoomOut Allows the user to zoom out from the text


  • range How much to zoom out

Protected member functions

void changeEvent(QEvent *event) override

changeEvent Changes the syntax highlighting when the colour palette of the window changes

event The change event

void keyPressEvent(QKeyEvent *event) override

keyPressEvent Add or remove key events


  • event The key event
void paintEvent(QPaintEvent *event) override

paintEvent Adds placeholder text


  • event The paint event
void resizeEvent(QResizeEvent *event) override

resizeEvent Resizes the line number area when the window is resized


  • event The resize event
void wheelEvent(QWheelEvent *event) override

wheelEvent Adds mouse wheel events for zooming


  • event The mouse wheel event

Private member functions

bool characterIsCommentedOut(const QString &text, int pos)

characterIsCommentedOut Checks whether the character at the given position in the given string is commented out


  • text The text to check the character in
  • pos The position of the character to check for in the text return Whether the character is commented out
void highlightCurrentLine()

highlightCurrentLine Highlights the line the cursor is on

void highlightParentheses()

highlightParentheses Highlights the parenthesis that corresponds to the one the cursor is next to

int matchingParenthesisPosition(int toMatchPos, int direction)

matchingParenthesisPosition Finds the position of the parenthesis that matches the one on the given position in the given direction


  • toMatchPos The position in the text of the parenthesis to match with
  • direction In which direction to look for the matching parenthesis. Equals 1 if we need to look forward for a ‘)’, equals -1 if we need to look back for a ‘(‘.
QTextEdit::ExtraSelection parenthesisHighlighting(int position)

parenthesisHighlighting Creates a highlighting for a single character on a given position for highlighting matching parentheses


  • position The position of the character to highlight

Returns: A selection that defines a highlighted parenthesis

void setFontSize(int pixelSize)

setFontSize Sets the font size and tab width


  • pixelSize The desired font size in pixels



showContextMenu Creates and shows a context menu


  • position The position where to create the context menu


updateLineNumberArea Updates the line number area after the scrollbar has been used


  • rect The rectangle that covers the line number area
  • dy The amount of pixels scrolled


updateLineNumberAreaWidth Updates the width of the line number area