# pyqode.core.modes

This package contains the core modes.

class `pyqode.core.modes.``AutoCompleteMode`

  Bases: `pyqode.core.api.mode.Mode`

  Generic auto complete mode that automatically completes the following symbols:

  > - ” -> “
  > - ‘ -> ‘
  > - ( -> )
  > - [ -> ]
  > - { -> }

class `pyqode.core.modes.``AutoIndentMode`

  Bases: `pyqode.core.api.mode.Mode`

  Generic indenter mode that indents the text when the user press RETURN.

  You can customize this mode by overriding `pyqode.core.modes.AutoIndentMode._get_indent()`

class `pyqode.core.modes.``CaretLineHighlighterMode`

  Bases: `pyqode.core.api.mode.Mode`

  This mode highlights the caret line (active line).

  `on_state_changed`(state)

    On state changed we (dis)connect to the cursorPositionChanged signal

  `refresh`()

    Updates the current line decoration

  `background`

    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

class `pyqode.core.modes.``CaseConverterMode`

  Bases: `pyqode.core.api.mode.Mode`

  Converts selected text to lower case or UPPER case.

  It does so by adding two new menu entries to the editor’s context menu:
    - Convert to lower case: ctrl-u
    - Convert to UPPER CASE: ctrl+shift+u
  `to_lower`(*args)

    Converts selected text to lower

  `to_upper`(*args)

    Converts selected text to upper

class `pyqode.core.modes.``CheckerMode`(worker, delay=500, marker_panel_id='markerPanel', clear_on_request=True, show_tooltip=False)

  Bases: `pyqode.core.api.mode.Mode`, `pyqode.core.qt.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 and optional markers can be added to a `pyqode.core.panels.MarkerPanel`

  `add_messages`(messages, clear=True)

    Adds a message or a list of message.

    Parameters: | messages – A list of messages or a single message clear – Clear messages before displaying the new ones. Default is True.

  `clear_messages`()

    Clears all messages.

  `remove_message`(message)

    Removes a message.

    Parameters: | message – Message to remove

  `request_analysis`()

    Requests an analysis.

class `pyqode.core.modes.``CheckerMessage`(description, status, line, col=None, icon=None, color=None, path=None)

  Bases: `builtins.object`

  Holds data for a message displayed by the `pyqode.core.modes.CheckerMode`.

  classmethod `status_to_string`(status)

    Converts a message status to a string.

    Parameters: | status – Status to convert (p yqode.core.modes.CheckerMessages)
    Returns: | The status string.
    Return type: | str

  `status_string`

    Returns the message status as a string.

    Returns: | The status string.

class `pyqode.core.modes.``CheckerMessages`

  Bases: `builtins.object`

  Enumerates the possible checker message types.

class `pyqode.core.modes.``CodeCompletionMode`

  Bases: `pyqode.core.api.mode.Mode`, `pyqode.core.qt.QtCore.QObject`

  This mode provides code completion system wich is extensible. It takes care of running the completion request in a background process using one or more completion provider(s).

  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).

  `request_completion`()

    Requests a code completion at the current cursor position.

  `completion_prefix`

    Returns the current completion prefix

class `pyqode.core.modes.``FileWatcherMode`

  Bases: `pyqode.core.api.mode.Mode`, `pyqode.core.qt.QtCore.QObject`

  FileWatcher mode, check if the opened file has changed externally.

  `on_state_changed`(state)

    Connects/Disconnects to the mouse_wheel_activated and key_pressed event

  `auto_reload`

    Automatically reloads changed files

class `pyqode.core.modes.``IndenterMode`

  Bases: `pyqode.core.api.mode.Mode`

  Implements classic indentation/tabulation.

  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`.

  `indent`()

    Indents text at cursor position.

  `indent_selection`(cursor)

    Indent selected text

    Parameters: | cursor – QTextCursor

  `unindent`()

    Un-indents text at cursor position.

  `unindent_selection`(cursor)

    Un-indents selected text

class `pyqode.core.modes.``PygmentsSyntaxHighlighter`(document, lexer=None)

  Bases: `pyqode.core.api.syntax_highlighter.SyntaxHighlighter`

  This mode enable syntax highlighting using the pygments library

  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.

  `on_install`(editor)

  `set_lexer_from_filename`(filename)

    Change the lexer based on the filename (actually only the extension is needed)

    Parameters: | filename – Filename or extension

  `set_lexer_from_mime_type`(mime, **options)

    Sets the pygments lexer from mime type.

  `pygments_style`

    Gets/Sets the pygments style

class `pyqode.core.modes.``RightMarginMode`

  Bases: `pyqode.core.api.mode.Mode`

  Display a right margin at column 80 by default.

  `on_state_changed`(state)

    Connects/Disconnects to the painted event of the editor

    Parameters: | state – Enable state

  `color`

    Gets/sets the color of the margin

  `position`

    Gets/sets the position of the margin

class `pyqode.core.modes.``SymbolMatcherMode`

  Bases: `pyqode.core.api.mode.Mode`

  Do symbols matches highlighting (parenthesis, 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.

  `do_symbols_matching`()

    Performs symbols matching.

  `symbol_pos`(cursor, character='(', symbol_type=0)

    Find the corresponding symbol position (line, column).

  `match_background`

    Background color of matching symbols.

  `match_foreground`

    Foreground color of matching symbols.

  `unmatch_background`

    Background color of non-matching symbols.

  `unmatch_foreground`

    Foreground color of matching symbols.

class `pyqode.core.modes.``WordClickMode`

  Bases: `pyqode.core.api.mode.Mode`, `pyqode.core.qt.QtCore.QObject`

  This mode adds support for document word click.

  It will highlight the click-able word when the user press control and move the mouse over a word.

  `pyqode.core.modes.WordClickMode.word_clicked` is emitted when the word is clicked by the user (while keeping control pressed).

  `on_state_changed`(state)

    Connects/disconnects slots to/from signals when the mode state changed.

class `pyqode.core.modes.``ZoomMode`

  Bases: `pyqode.core.api.mode.Mode`

  This mode make it possible to zoom in/out the editor view.

  Here are the controls:
    - zoom out: ctrl+- or ctrl+mouse wheel backward
    - zoom in: ctrl++ or ctrl+mouse wheel forward
    - reset: ctrl + 0
  `on_state_changed`(state)

    Connects/Disconnects to the mouse_wheel_activated and key_pressed event