Source editor¶
This module contains source code editing classes for Myokit’s IDE.
Implementation¶
- class myokit.gui.source.Editor(parent=None)¶
Source code editor used in Myokit.
Provides the signal
find_action(str)
which is fired everything a find action occurred with a description that can be used in an application’s status bar.- cursor_changed()¶
Slot: Called when the cursor position is changed
- cursor_position()¶
Returns a tuple
(line, char)
with the current cursor position. If a selection is made only the left position is used.Line and char counts both start at zero.
- get_text()¶
Returns the text in this editor.
- jump_to(line, char)¶
Jumps to the given line and row (with indices starting at 0).
- keyPressEvent(event)¶
Qt event: A key was pressed.
- paintEvent(e)¶
Paints this editor.
- replace(text)¶
Replaces the current text with the given text, in a single operation that does not reset undo/redo.
- resizeEvent(event)¶
Qt event: Editor is resized.
- set_cursor(pos)¶
Changes the current cursor to the given position and scrolls so that its visible.
- set_text(text)¶
Replaces the text in this editor.
- toggle_comment()¶
Comments or uncomments the selected lines
- trim_trailing_whitespace()¶
Trims all trailing whitespace from this document.
- class myokit.gui.source.LineNumberArea(editor)¶
Line number area widget for the editor. All real actions are delegated to the text area class.
The line number is drawn in the left margin of the
Editor
widget, the space to do so is created by setting the editor’s viewport margins.- paintEvent(event)¶
Qt event: Paint this area.
- sizeHint()¶
Qt event: Suggest a size for this area.
- update_contents(rect, scroll)¶
Slot: Invoked when the text editor view has changed and the line numbers need to be redrawn.
- update_width(count)¶
Slot: Invoked when the number of lines in the text area changed, which might change the size of the number area.
- class myokit.gui.source.FindReplaceWidget(parent, editor)¶
Find/replace widget for
Editor
.- action_find()¶
Qt slot: Find (next) item.
- action_replace()¶
Qt slot: Replace found item with replacement.
- action_replace_all()¶
Qt slot: Replace all found items with replacement
- activate()¶
Updates the contents of the search field and gives it focus.
- keyPressEvent(event)¶
Qt event: A key-press reaches the widget.
- load_config(config, section)¶
Loads this search’s configuration using the given
ConfigParser
config
. Loads all settings from the sectionsection
.
- save_config(config, section)¶
Saves this search’s configuration using the given
ConfigParser
config
. Stores all settings in the sectionsection
.
Syntax highlighting¶
- class myokit.gui.source.ModelHighlighter(document)¶
Syntax highlighter for
mmt
model definitions.- highlightBlock(text)¶
Qt: Called whenever a block should be highlighted.