4.53. umbra.ui.widgets.codeEditor_QPlainTextEdit — Umbra 1.0.9 documentation

# 4.53. umbra.ui.widgets.codeEditor_QPlainTextEdit

codeEditor_QPlainTextEdit.py

Platform:
  Windows, Linux, Mac Os X.
Description:
  Defines the `LinesNumbers_QWidget` and `CodeEditor_QPlainTextEdit` classes.
  Those objects provides the basics building blocks of a code editor widget.
Others:
  Portions of the code from codeeditor.py by Roberto Alsina: http://lateral.netmanagers.com.ar/weblog/posts/BB832.html, KhtEditor.py by Benoit Hervier: http://khertan.net/khteditor, Ninja IDE: http://ninja-ide.org/ and Prymatex: https://github.com/D3f0/prymatex/

## 4.53.1. Module Attributes

`umbra.ui.widgets.codeEditor_QPlainTextEdit.` `LOGGER`

## 4.53.2. Classes

class `umbra.ui.widgets.codeEditor_QPlainTextEdit.` `LinesNumbers_QWidget`(parent, *args, **kwargs)

  Bases: `PyQt4.QtGui.QWidget`

  Defines a QWidget subclass providing a lines numbers widget.

  Initializes the class.

  Parameters: | parent (QObject) – Object parent. *args (*) – Arguments. **kwargs (**) – Keywords arguments.

  `editor`

    Property for self.__editor attribute.

    Returns: | self.__editor.
    Return type: | QWidget

  `margin`

    Property for self.__margin attribute.

    Returns: | self.__margin.
    Return type: | int

  `separatorWidth`

    Property for self.__separatorWidth attribute.

    Returns: | self.__separatorWidth.
    Return type: | int

  `backgroundColor`

    Property for self.__backgroundColor attribute.

    Returns: | self.__backgroundColor.
    Return type: | QColor

  `color`

    Property for self.__color attribute.

    Returns: | self.__color.
    Return type: | QColor

  `separatorColor`

    Property for self.__separatorColor attribute.

    Returns: | self.__separatorColor.
    Return type: | QColor

  `sizeHint`()

    Reimplements the `QWidget.sizeHint()` method.

    Returns: | Size hint.
    Return type: | QSize

  `paintEvent`(event)

    Reimplements the `QWidget.paintEvent()` method.

    Parameters: | event (QEvent) – Event.

  `getWidth`()

    Returns the Widget target width.

    Returns: | Widget target width.
    Return type: | int

  `setEditorViewportMargins`(newBlocksCount)

    Sets the editor viewport margins.

    Parameters: | newBlocksCount (int) – Updated editor blocks count.
    Returns: | Method success.
    Return type: | bool

  `updateRectangle`(rectangle, scrollY)

    Updates the given Widget rectangle.

    Parameters: | rectangle (QRect) – Rectangle to update. scrollY (int) – Amount of pixels the viewport was scrolled.
    Returns: | Method success.
    Return type: | bool

  `updateGeometry`()

    Updates the Widget geometry.

    Returns: | Method success.
    Return type: | bool

class `umbra.ui.widgets.codeEditor_QPlainTextEdit.` `CodeEditor_QPlainTextEdit`(parent=None, language=None, indentMarker=u't', indentWidth=4, commentMarker=u'#', *args, **kwargs)

  Bases: `umbra.ui.widgets.basic_QPlainTextEdit.Basic_QPlainTextEdit`

  Defines a code editor base class.

  Initializes the class.

  Parameters: | parent (QObject) – Widget parent. language (Language) – Editor language. indentMarker (unicode) – Indentation marker. indentWidth (int) – Indentation spaces count. commentMarker (unicode) – Comment marker. *args (*) – Arguments. **kwargs (**) – Keywords arguments.

  `languageChanged`

    This signal is emited by the `Editor` class when `ComponentsManagerUi.language` class property language is changed. ( pyqtSignal )

  `language`

    Property for self.__language attribute.

    Returns: | self.__language.
    Return type: | Language

  `indentMarker`

    Property for self.__indentMarker attribute.

    Returns: | self.__indentMarker.
    Return type: | unicode

  `indentWidth`

    Property for self.__indentWidth attribute.

    Returns: | self.__indentWidth.
    Return type: | int

  `commentMarker`

    Property for self.__commentMarker attribute.

    Returns: | self.__commentMarker.
    Return type: | unicode

  `marginArea_LinesNumbers_widget`

    Property for self.__marginArea_LinesNumbers_widget attribute.

    Returns: | self.__marginArea_LinesNumbers_widget.
    Return type: | LinesNumbers_QWidget

  `highlighter`

    Property for self.__highlighter attribute.

    Returns: | self.__highlighter.
    Return type: | QSyntaxHighlighter

  `completer`

    Property for self.__completer attribute.

    Returns: | self.__completer.
    Return type: | QCompleter

  `preInputAccelerators`

    Property for self.__preInputAccelerators attribute.

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

  `postInputAccelerators`

    Property for self.__postInputAccelerators attribute.

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

  `visualAccelerators`

    Property for self.__visualAccelerators attribute.

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

  `resizeEvent`(event)

    Reimplements the `Basic_QPlainTextEdit.resizeEvent()` method.

    Parameters: | event (QEvent) – Event.

  `keyPressEvent`(event)

    Reimplements the `Basic_QPlainTextEdit.keyPressEvent()` method.

    Parameters: | event (QEvent) – Event.

  `setLanguage`(language)

    Sets the language.

    Parameters: | language (Language) – Language to set.
    Returns: | Method success.
    Return type: | bool

  `setHighlighter`(highlighter)

    Sets given highlighter as the current document highlighter.

    Parameters: | highlighter (QSyntaxHighlighter) – Highlighter.
    Returns: | Method success.
    Return type: | bool

  `removeHighlighter`()

    Removes current highlighter.

    Returns: | Method success.
    Return type: | bool

  `setCompleter`(completer)

    Sets given completer as the current completer.

    Parameters: | completer (QCompleter) – Completer.
    Returns: | Method success.
    Return type: | bool

  `removeCompleter`()

    Removes current completer.

    Returns: | Method success.
    Return type: | bool

  `getMatchingSymbolsPairs`(cursor, openingSymbol, closingSymbol, backward=False)

    Returns the cursor for matching given symbols pairs.

    Parameters: | cursor (QTextCursor) – Cursor to match from. openingSymbol (unicode) – Opening symbol. closingSymbol (unicode) – Closing symbol to match.
    Returns: | Matching cursor.
    Return type: | QTextCursor

  `indent`()

    Indents the document text under cursor.

    Returns: | Method success.
    Return type: | bool

  `unindent`()

    Unindents the document text under cursor.

    Returns: | Method success.
    Return type: | bool

  `toggleComments`()

    Toggles comments on the document selected lines.

    Returns: | Method success.
    Return type: | bool

  `removeTrailingWhiteSpaces`()

    Removes document trailing white spaces.

    Returns: | Method success.
    Return type: | bool

  `convertIndentationToTabs`()

    Converts document indentation to tabs.

    Returns: | Method success.
    Return type: | bool

  `convertIndentationToSpaces`()

    Converts document indentation to spaces.

    Returns: | Method success.
    Return type: | bool