4.42. umbra.ui.highlighters — Umbra 1.0.8 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Umbra 1.0.8 documentation »
- 4. Api »

# 4.42. umbra.ui.highlighters

highlighters.py

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

## 4.42.1. Module Attributes

`umbra.ui.highlighters.` `LOGGER`

## 4.42.2. Classes

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

  Bases: `foundations.dataStructures.Structure`

  This class represents a storage object for highlighters rule.

  Parameters: | **kwargs – pattern, format. ( Key / Value pairs )

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

  Bases: `object`

  This class defines the formats tree object representing higlighters theme.

  Parameters: | theme – Theme. ( Dictionary )

  `rootNode`

    This method is the property for self.__rootNode attribute.

    Returns: | self.__rootNode. ( AbstractCompositeNode )

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

    This method lists the object formats in sorted order.

    Parameters: | node – Root node to start listing the formats from. ( AbstractCompositeNode ) path – Walked paths. ( Tuple ) formats – Formats. ( List )
    Returns: | Formats. ( List )

  `getFormat`(name)

    This method returns the closest format or closest parent format associated to given name.

    Parameters: | name – Format name. ( String)
    Returns: | Format. ( QTextCharFormat )

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

  Bases: `PyQt4.QtGui.QSyntaxHighlighter`

  This class is a QSyntaxHighlighter subclass used as a base for highlighters classes.

  Parameters: | parent – Widget parent. ( QObject )

  `formats`

    This method is the property for self.__formats attribute.

    Returns: | self.__formats. ( FormatsTree )

  `rules`

    This method is the property for self.__rules attribute.

    Returns: | self.__rules. ( Tuple / List )

  `highlightBlock`(block)

    This method reimplements the `QSyntaxHighlighter.highlightBlock()` method.

    Parameters: | block – Text block. ( QString )

  `highlightText`(text, start, end)

    This method highlights given text.

    Parameters: | text – Text. ( QString ) start – Text start index. ( Integer ) end – Text end index. ( Integer )
    Returns: | Method success. ( Boolean )

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

  Bases: `umbra.ui.highlighters.AbstractHighlighter`

  This class is a `AbstractHighlighter` subclass providing syntax highlighting for documents.

  Parameters: | parent – Widget parent. ( QObject ) rules – Rules. ( Tuple / List ) theme – Theme. ( Dictionary )

  `theme`

    This method is the property for self.__theme attribute.

    Returns: | self.__theme. ( Dictionary )

  `highlightBlock`(block)

    This method reimplements the `AbstractHighlighter.highlightBlock()` method.

    Parameters: | block – Text block. ( QString )

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

    This method highlights given multiline text block.

    Parameters: | block – Text block. ( QString ) pattern – Start regex pattern. ( QRegExp ) pattern – End regex pattern. ( QRegExp ) format – Format. ( QTextCharFormat ) state – Block state. ( Integer )
    Returns: | Current block matching state. ( Boolean )

### Navigation

- index
- modules |
- next |
- previous |
- Umbra 1.0.8 documentation »
- 4. Api »