Modes¶
This page contains documentation about the available pcef modes.
HighlightLineMode¶
Contains the Current Line Highlighter mode.
- class pcef.modes.clh.HighlightLineMode[source]¶
This mode highlights the current line.
Line color is defined by pcef.style.Style.activeLineColor
- DESCRIPTION = 'Highlight the current line in the editor'¶
Mode description
- IDENTIFIER = 'Highlight line'¶
Mode identifier
Code completion¶
- class pcef.modes.code_completion.CodeCompletionMode[source]¶
This mode provides code completion to the CodeEdit widget.
The list of suggestion is supplied by a CodeCompletionModel.
Code completion may use more than one completion model. The suggestions list is then filled model per model by beginning by the highest priority as long as the number of suggestions is lower than pcef.modes.code_completion.CodeCompletion.minSuggestions. For example, a python editor will use a smart completion model with a high priority and use the DocumentWordsCompletion model as a fallback system when the smart model fails to provide enough suggestions.
The mode uses a QCompleter to provides display the list of suggestions.
Code completion is triggered using ctrl+space or when there is at least three characters in the word being typed.
- DESCRIPTION = 'Provides code completion though completion models'¶
Mode description
- IDENTIFIER = 'Code completion'¶
Mode identifier
- caseSensitivity¶
The completion case sensitivity
- static containsAny(txt, charsSet)[source]¶
Check whether ‘txt’ contains ANY of the chars in ‘charsSet’
- install(editor)[source]¶
Setup the completer with the CodeEdit.
Parameters: editor – CodeEditorWidget instance
- minSuggestions = None¶
Defines the min number of suggestions. This is used to know we should avoid using lower priority models.
- nbTriggerChars = None¶
Number of chars needed to trigger the code completion
- triggerKey = None¶
Trigger key (automatically associated with the control modifier)
- class pcef.modes.code_completion.CompletionModel(words=None, priority=0)[source]¶
Base class for representing a completion model.
A completion model is a single list of suggestions associated with a priority.
This base class can be used directly with a static list of words.
- priority = None¶
Model priority
- class pcef.modes.code_completion.DocumentWordsCompletionModel[source]¶
Provides suggestions based on the current document words.
- class pcef.modes.code_completion.Suggestion(txt, icon=None)[source]¶
- Represent a suggestion in the completion list. A suggestion is made up of the following elements:
- display: suggestion text (display role)
- decoration: an optional decoration icon (decoration role)
- decoration = None¶
QIcon used for the decoration role.
- display = None¶
Displayed text.
Auto indent¶
Contains smart indent modes
- class pcef.modes.indent.AutoIndentMode[source]¶
A basic auto indent mode that provides a basic auto indentation based on the previous line indentation.
This mode can be extended by overriding the _getIndent method.
- DESCRIPTION = ' A basic auto indent mode that provides a basic auto indentation based on the previous\n line indentation.\n '¶
Mode description
- IDENTIFIER = 'Auto indent'¶
Mode identifier
Right margin¶
Contains the right margin mode
Syntax highlighting¶
This module contains Syntax Highlighting mode and the QSyntaxHighlighter based on pygments
- class pcef.modes.sh.PygmentsBlockUserData(**kwds)[source]¶
Storage for the user data associated with each line.
- class pcef.modes.sh.QPygmentsHighlighter(parent, lexer=None)[source]¶
Syntax highlighter that uses Pygments for parsing.
- setLexerFromFilename(filename)[source]¶
Change the lexer based on the filename (actually only the extension is needed)
Parameters: filename – Filename or extension
- set_style_sheet(stylesheet)[source]¶
Sets a CSS stylesheet. The classes in the stylesheet should correspond to those generated by:
pygmentize -S <style> -f htmlNote that ‘set_style’ and ‘set_style_sheet’ completely override each other, i.e. they cannot be used in conjunction.
- style¶
gets/sets the pygments style.
- class pcef.modes.sh.SyntaxHighlighterMode[source]¶
This mode enable syntax highlighting (using the QPygmentsHighlighter)
- DESCRIPTION = 'Apply syntax highlighting to the editor using '¶
Mode description
- IDENTIFIER = 'Syntax highlighter'¶
Mode identifier