4.41. umbra.ui.highlighters — Umbra 1.0.9 documentation

# 4.41. umbra.ui.highlighters

highlighters.py

Platform:
  Windows, Linux, Mac Os X.
Description:
  Defines the Application highlighters classes.
Others:
  Portions of the code from PyQtWiki: http://diotavelli.net/PyQtWiki/Python%20syntax%20highlighting

## 4.41.1. Module Attributes

`umbra.ui.highlighters.` `LOGGER`

## 4.41.2. Classes

class `umbra.ui.highlighters.` `Rule`(**kwargs)

  Bases: `foundations.dataStructures.Structure`

  Defines a storage object for highlighters rule.

  Initializes the class.

  Parameters: | **kwargs (dict) – pattern, format.

class `umbra.ui.highlighters.` `FormatsTree`(theme=None)

  Bases: `object`

  Defines the formats tree object representing higlighters theme.

  Initializes the class.

  Parameters: | theme (dict) – Theme.

  `rootNode`

    Property for self.__rootNode attribute.

    Returns: | self.__rootNode.
    Return type: | AbstractCompositeNode

  `listFormats`(node, path=(), formats=None)

    Lists the object formats in sorted order.

    Parameters: | node (AbstractCompositeNode) – Root node to start listing the formats from. path (tuple) – Walked paths. formats (list) – Formats.
    Returns: | Formats.
    Return type: | list

  `getFormat`(name)

    Returns the closest format or closest parent format associated to given name.

    Parameters: | name (unicode) – Format name.
    Returns: | Format.
    Return type: | QTextCharFormat

class `umbra.ui.highlighters.` `AbstractHighlighter`(parent=None)

  Bases: `PyQt4.QtGui.QSyntaxHighlighter`

  Defines a QSyntaxHighlighter subclass used as a base for highlighters classes.

  Initializes the class.

  Parameters: | parent (QObject) – Widget parent.

  `formats`

    Property for self.__formats attribute.

    Returns: | self.__formats.
    Return type: | FormatsTree

  `rules`

    Property for self.__rules attribute.

    Returns: | self.__rules.
    Return type: | tuple or list

  `highlightBlock`(block)

    Reimplements the `QSyntaxHighlighter.highlightBlock()` method.

    Parameters: | block (QString) – Text block.

  `highlightText`(text, start, end)

    Highlights given text.

    Parameters: | text (QString) – Text. start (int) – Text start index. end (int) – Text end index.
    Returns: | Method success.
    Return type: | bool

class `umbra.ui.highlighters.` `DefaultHighlighter`(parent=None, rules=None, theme=None)

  Bases: `umbra.ui.highlighters.AbstractHighlighter`

  Defines a `AbstractHighlighter` subclass providing syntax highlighting for documents.

  Initializes the class.

  Parameters: | parent (QObject) – Widget parent. rules (tuple or list) – Rules. theme (dict) – Theme.

  `theme`

    Property for self.__theme attribute.

    Returns: | self.__theme.
    Return type: | dict

  `highlightBlock`(block)

    Reimplements the `AbstractHighlighter.highlightBlock()` method.

    Parameters: | block (QString) – Text block.

  `highlightMultilineBlock`(block, startPattern, endPattern, state, format)

    Highlights given multiline text block.

    Parameters: | block (QString) – Text block. pattern (QRegExp) – Start regex pattern. pattern – End regex pattern. format (QTextCharFormat) – Format. state (int) – Block state.
    Returns: | Current block matching state.
    Return type: | bool