4.52. umbra.ui.widgets.basic_QPlainTextEdit

basic_QPlainTextEdit.py

Platform:
Windows, Linux, Mac Os X.
Description:
Defines the Basic_QPlainTextEdit class.
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.52.1. Module Attributes

umbra.ui.widgets.basic_QPlainTextEdit.LOGGER

4.52.2. Functions

umbra.ui.widgets.basic_QPlainTextEdit.editBlock(object)[source]

Handles edit blocks undo states.

Parameters:object (object) – Object to decorate.
Returns:Object.
Return type:object
umbra.ui.widgets.basic_QPlainTextEdit.anchorTextCursor(object)[source]

Anchors the text cursor position.

Parameters:object (object) – Object to decorate.
Returns:Object.
Return type:object
umbra.ui.widgets.basic_QPlainTextEdit.centerTextCursor(object)[source]

Centers the text cursor position.

Parameters:object (object) – Object to decorate.
Returns:Object.
Return type:object

4.52.3. Classes

class umbra.ui.widgets.basic_QPlainTextEdit.Basic_QPlainTextEdit(parent=None, *args, **kwargs)[source]

Bases: PyQt4.QtGui.QPlainTextEdit

Defines a QPlainTextEdit subclass providing a basic editor base class.

Initializes the class.

Parameters:
  • parent (QObject) – Widget parent.
  • *args (*) – Arguments.
  • **kwargs (**) – Keywords arguments.
patternsReplaced

This signal is emited by the Basic_QPlainTextEdit class when patterns have been replaced. ( pyqtSignal )

Returns:Replaced patterns.
Return type:list
searchPattern[source]

Property for self.__searchPattern attribute.

Returns:self.__searchPattern.
Return type:unicode
minimumFontPointSize[source]

Property for self.__minimumFontPointSize attribute.

Returns:self.__minimumFontPointSize.
Return type:int
maximumFontPointSize[source]

Property for self.__maximumFontPointSize attribute.

Returns:self.__maximumFontPointSize.
Return type:int
wheelEvent(event)[source]

Reimplements the QPlainTextEdit.wheelEvent() method.

Parameters:event (QEvent) – Event.
getSelectedTextMetrics()[source]

Returns current document selected text metrics.

Returns:Selected text metrics.
Return type:tuple
getDefaultTextOption()[source]

Returns default text option.

Returns:Default text options.
Return type:QTextOption
setDefaultTextOption(textOption)[source]

Sets default text option using given flag.

Parameters:textOption (QTextOption) – Text option.
Returns:Method success.
Return type:bool
storeTextCursorAnchor()[source]

Stores the document cursor anchor.

Returns:Method success.
Return type:bool
restoreTextCursorAnchor()[source]

Restores the document cursor anchor.

Returns:Method success.
Return type:bool
getCursorLine()[source]

Returns the document cursor line.

Returns:Cursor line.
Return type:int
getCursorColumn()[source]

Returns the document cursor column.

Returns:Cursor column.
Return type:int
getPreviousCharacter()[source]

Returns the character before the cursor.

Returns:Previous cursor character.
Return type:QString
getNextCharacter()[source]

Returns the character after the cursor.

Returns:Next cursor character.
Return type:QString
getWords()[source]

Returns the document words.

Returns:Document words.
Return type:list
getSelectedText()[source]

Returns the document text under cursor.

Returns:Text under cursor.
Return type:QString
getWordUnderCursorLegacy()[source]

Returns the document word under cursor ( Using Qt legacy “QTextCursor.WordUnderCursor” ).

Returns:Word under cursor.
Return type:QString
getWordUnderCursor()[source]

Returns the document word under cursor.

Returns:Word under cursor.
Return type:QString
getPartialWordUnderCursor()[source]

Returns the document partial word under cursor ( From word start to cursor position ).

Returns:Partial word under cursor.
Return type:QString
isModified()[source]

Returns if the document is modified.

Returns:Document modified state.
Return type:bool
setModified(state)[source]

Sets the document modified state.

Parameters:state (bool) – Modified state.
Returns:Method success.
Return type:bool
isEmpty()[source]

Returns if the document is empty.

Returns:Document empty state.
Return type:bool
setContent(content)[source]

Sets document with given content while providing undo capability.

Parameters:content (list) – Content to set.
Returns:Method success.
Return type:bool
delete()[source]

Deletes the document text under cursor.

Returns:Method success.
Return type:bool
deleteLines()[source]

Deletes the document lines under cursor.

Returns:Method success.
Return type:bool
duplicateLines()[source]

Duplicates the document lines under cursor.

Returns:Method success.
Return type:bool
moveLines(direction=2)[source]

Moves the document lines under cursor.

Parameters:direction – Move direction ( QTextCursor.Down / QTextCursor.Up ). ( QTextCursor.MoveOperation )
Returns:Method success.
Return type:bool
moveLinesUp()[source]

Moves up the document lines under cursor.

Returns:Method success.
Return type:bool
moveLinesDown()[source]

Moves down the document lines under cursor.

Returns:Method success.
Return type:bool
search(pattern, **kwargs)[source]

Searchs given pattern text in the document.

Usage:

>>> scriptEditor = Umbra.componentsManager.getInterface("factory.scriptEditor")
True
>>> codeEditor = scriptEditor.getCurrentEditor()
True
>>> codeEditor.search(searchPattern, caseSensitive=True, wholeWord=True, regularExpressions=True, backwardSearch=True, wrapAround=True)
True
Parameters:
  • pattern (unicode) – Pattern to search for.
  • **kwargs (dict) – Search settings.
Returns:

Method success.

Return type:

bool

searchNext()[source]

Searchs the next search pattern in the document.

Returns:Method success.
Return type:bool
searchPrevious()[source]

Searchs the previous search pattern in the document.

Returns:Method success.
Return type:bool
replace(pattern, replacementPattern, **kwargs)[source]

Replaces current given pattern occurence in the document with the replacement pattern.

Usage:

>>> scriptEditor = Umbra.componentsManager.getInterface("factory.scriptEditor")
True
>>> codeEditor = scriptEditor.getCurrentEditor()
True
>>> codeEditor.replace(searchPattern, replacementPattern, caseSensitive=True, wholeWord=True, regularExpressions=True, backwardSearch=True, wrapAround=True)
True
Parameters:
  • pattern (unicode) – Pattern to replace.
  • replacementPattern (unicode) – Replacement pattern.
  • **kwargs (dict) – Format settings.
Returns:

Method success.

Return type:

bool

replaceAll(pattern, replacementPattern, **kwargs)[source]
Replaces every given pattern occurrences in the document with the replacement pattern.

Warning

Initializing wrapAround keyword to True leads to infinite recursion loop if the search pattern and the replacementPattern are the same.

Parameters:
  • pattern (unicode) – Pattern to replace.
  • replacementPattern (unicode) – Replacement pattern.
  • **kwargs (dict) – Format settings.
Returns:

Method success.

Return type:

bool

gotoLine(line)[source]

Moves the text cursor to given line.

Parameters:line (int) – Line to go to.
Returns:Method success.
Return type:bool
gotoColumn(column)[source]

Moves the text cursor to given column.

Parameters:column (int) – Column to go to.
Returns:Method success.
Return type:bool
gotoPosition(position)[source]

Moves the text cursor to given position.

Parameters:position (int) – Position to go to.
Returns:Method success.
Return type:bool
toggleWordWrap()[source]

Toggles document word wrap.

Returns:Method success.
Return type:bool
toggleWhiteSpaces()[source]

Toggles document white spaces display.

Returns:Method success.
Return type:bool
setFontIncrement(value)[source]

Increments the document font size.

Parameters:value (int) – Font size increment.
Returns:Method success.
Return type:bool
zoomIn()[source]

Increases the document font size.

Returns:Method success.
Return type:bool
zoomOut()[source]

Increases the document font size.

Returns:Method success.
Return type:bool