This package contains the core modes.
Bases: pyqode.core.api.mode.Mode
Automatically complete quotes and parentheses
Generic auto complete mode that automatically completes the following symbols:
- ” -> “
- ‘ -> ‘
- ( -> )
- [ -> ]
- { -> }
Auto complete mapping, maps input key with completion text.
The format to use for each symbol in mapping when there is no selection
The format to use for each symbol in mapping when there is a selection
Bases: pyqode.core.api.mode.Mode
Highlights the caret line
Updates the current line decoration
Background color of the caret line. Default is to use a color slightly darker/lighter than the background color. You can override the automatic color by setting up this property
Bases: pyqode.core.api.mode.Mode
Provides context actions for converting case of the selected text.
Converts selected text to lower case or UPPER case.
Converts selected text to lower
Converts selected text to upper
Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject
Performs a user defined code analysis job using the backend and display the results on the editor instance.
The user defined code analysis job is a simple function with the following signature:
def analysisProcess(data)
where data is the request data:
request_data = {
'code': self.editor.toPlainText(),
'path': self.editor.file.path,
'encoding': self.editor.file.encoding
}
and the return value is a tuple made up of the following elements:
(description, status, line, [col], [icon], [color], [path])
The background process is ran when the text changed and the ide is an idle state for a few seconds.
You can also request an analysis manually using pyqode.core.modes.CheckerMode.request_analysis()
Messages are displayed as text decorations on the editor. A checker panel will take care of display message icons next to each line.
Adds a message or a list of message.
Parameters: | messages – A list of messages or a single message |
---|
Clears all messages.
Removes a message.
Parameters: | message – Message to remove |
---|
Requests an analysis.
Returns the entire list of checker messages.
Bases: builtins.object
Holds data for a message displayed by the pyqode.core.modes.CheckerMode.
Converts a message status to a string.
Parameters: | status – Status to convert (p yqode.core.modes.CheckerMessages) |
---|---|
Returns: | The status string. |
Return type: | str |
Default colors foreach message status
store a reference to the associated QTextBlock, for quick acces
The start column (used for the text decoration). If the col is None, the whole line is highlighted.
The color used for the text decoration. If None, the default color is used (pyqode.core.CheckerMessage.COLORS)
The description of the message, used as a tooltip.
The line of the message
Returns the message status as a string.
Returns: | The status string. |
---|
Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject
Provides code completions when typing or when pressing Ctrl+Space.
This mode provides a code completion system which is extensible. µ It takes care of running the completion request in a background process using one or more completion provider.
To implement a code completion for a specific language, you only need to implement new pyqode.core.backend.workers.CodeCompletionWorker.Provider
The completion popup is shown the user press ctrl+space or automatically while the user is typing some code (this can be configured using a series of properties).
Requests a code completion at the current cursor position.
Strips control character from input_txt :param input_txt: text to strip. :return: stripped text
True to performs case sensitive completion matching.
Returns the current completion prefix
True to show tooltips next to the current completion.
The key that triggers code completion (Default is Space: Ctrl + Space).
The trigger length defines the word length required to run code completion.
Defines the list of symbols that immediately trigger a code completion requiest. BY default, this list contains the dot character.
For C++, we would add the ‘->’ operator to that list.
Bases: pyqode.core.api.mode.Mode
Adds extended selection capabilities (Ctrl/Alt + Double click).
This mode adds extended selections capabilities to CodeEdit.
Extended selection is a feature that can be found in the Ulipad editor: https://code.google.com/p/ulipad
It consists in adding a few shortcuts and contextual action to do some smarter selections. This mode adds the following new kind of selections:
- word selection: select word under cursor
- extended word selection: select word under cursor including continuation characters such as ”.”.
- matched selection: select text inside quotes or parenthesis
- line selection: select the whole line
- select all: select entire document
Extended selection and matched selection can be performed by combining ctrl or alt with a double click (modifiers are configurable through extended_sel_modifier or matched_sel_modifier).
Creates the extended selection menu.
Performs extended word selection. :param event: QMouseEvent
Performs line selection (select the entire line).
Performs matched selection. :param event: QMouseEvent
Performs word selection :param event: QMouseEvent
Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject
Watches the current file for external modifications.
FileWatcher mode, check if the opened file has changed externally.
Automatically reloads changed files
Signal emitted when the file has been deleted. The Signal is emitted with the current editor instance so that user have a chance to close the editor.
Signal emitted when the file has been reloaded in the editor.
Bases: pyqode.core.api.mode.Mode
Implements classic indentation/tabulation (Tab/Shift+Tab)
It inserts/removes tabulations (a series of spaces defined by the tabLength settings) at the cursor position if there is no selection, otherwise it fully indents/un-indents selected lines.
To trigger an indentation/un-indentation programatically, you must emit pyqode.core.api.CodeEdit.indent_requested or pyqode.core.api.CodeEdit.unindent_requested.
Indents text at cursor position.
Indent selected text
Parameters: | cursor – QTextCursor |
---|
Un-indents text at cursor position.
Un-indents selected text
Parameters: | cursor – QTextCursor |
---|
Bases: pyqode.core.api.mode.Mode
Highlights occurrences of the word under the text text cursor.
The delay before searching for occurrences is configurable.
Background or underline color (if underlined is True).
Delay before searching for occurrences. The timer is rearmed as soon as the cursor position changed.
Foreground color of occurences, not used if underlined is True.
Timer used to run the search request with a specific delay
True to use to underlined occurrences instead of changing the background. Default is True.
If this mode is ON, the foreground color is ignored, the background color is then used as the underline color.
Bases: pyqode.core.api.syntax_highlighter.SyntaxHighlighter
Highlights code using the pygments parser.
This mode enable syntax highlighting using the pygments library. This is a generic syntax highlighter, it is slower than a native highlighter and does not do any code folding detection. Use it as a fallback for languages that do not have a native highlighter available. Check the other pyqode namespace packages to see what other languages are available (at the time of writing, only python has specialised support).
Warning
There are some issues with multi-line comments, they are not properly highlighted until a full re-highlight is triggered. The text is automatically re-highlighted on save.
Highlights the block using a pygments lexer.
Parameters: |
|
---|
Change the lexer based on the filename (actually only the extension is needed)
Parameters: | filename – Filename or extension |
---|
Sets the pygments lexer from mime type.
Parameters: |
|
---|
Update the highlighter lexer based on a mime type.
Parameters: | mime_type – mime type of the new lexer to setup. |
---|
Mode description
Gets/Sets the pygments style
Bases: pyqode.core.api.mode.Mode
Displays a right margin at column the specified position.
Connects/Disconnects to the painted event of the editor
Parameters: | state – Enable state |
---|
Gets/sets the color of the margin
Gets/sets the position of the margin
Bases: pyqode.core.api.mode.Mode
Improves backspace behaviour.
When you press backspace and there are spaces on the left of the cursor, those spaces will be deleted (at most tab_len spaces).
Basically this turns backspace into Shitf+Tab
Bases: pyqode.core.api.mode.Mode
Highlights matching symbols (parentheses, braces,...)
Note
This mode requires the document to be filled with pyqode.core.api.TextBlockUserData, i.e. a pyqode.core.api.SyntaxHighlighter must be installed on the editor instance.
Performs symbols matching.
Find the corresponding symbol position (line, column) of the specified symbol. If symbol type is PAREN and character_type is OPEN, the function will look for ‘(‘.
Parameters: |
|
---|
known symbols {SYMBOL: (OPEN, CLOSE)}, you can customise this map to add support for other symbols
Background color of matching symbols.
Foreground color of matching symbols.
Background color of non-matching symbols.
Foreground color of matching symbols.
Bases: pyqode.core.api.mode.Mode, PyQt5.QtCore.QObject
Adds support for word click events.
It will highlight the click-able word when the user press control and move the mouse over a word.
Detecting whether a word is click-able is the responsability of the subclasses. You must override _check_word_cursor and call _select_word_cursor if this is a click-able word (this process might be asynchrone) otherwise _clear_selection.
pyqode.core.modes.WordClickMode.word_clicked is emitted when the word is clicked by the user (while keeping control pressed).
Signal emitted when a word is clicked. The parameter is a QTextCursor with the clicked word set as the selected text.
Bases: pyqode.core.api.mode.Mode
Zooms/Unzooms the editor (Ctrl+mouse wheel or Ctrl + 0 to reset).
This mode make it possible to zoom in/out the editor view.