4.53. umbra.ui.widgets.basic_QPlainTextEdit

basic_QPlainTextEdit.py

Platform:
Windows, Linux, Mac Os X.
Description:
This module 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.53.1. Module Attributes

umbra.ui.widgets.basic_QPlainTextEdit.LOGGER

4.53.2. Functions

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

This decorator is used to handle edit blocks undo states.

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

This decorator is used to anchor the text cursor position.

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

This decorator is used to center the text cursor position.

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

4.53.3. Classes

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

Bases: PyQt4.QtGui.QPlainTextEdit

This class is a QPlainTextEdit subclass providing a basic editor base class.

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

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

Returns:Replaced patterns. ( List )
searchPattern[source]

This method is the property for self.__searchPattern attribute.

Returns:self.__searchPattern. ( String )
minimumFontPointSize[source]

This method is the property for self.__minimumFontPointSize attribute.

Returns:self.__minimumFontPointSize. ( Integer )
maximumFontPointSize[source]

This method is the property for self.__maximumFontPointSize attribute.

Returns:self.__maximumFontPointSize. ( Integer )
wheelEvent(event)[source]

This method reimplements the QPlainTextEdit.wheelEvent() method.

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

This method returns current document selected text metrics.

Returns:Selected text metrics. ( Tuple )
getDefaultTextOption()[source]

This method returns default text option.

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

This method sets default text option using given flag.

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

This method stores the document cursor anchor.

Returns:Method success. ( Boolean )
restoreTextCursorAnchor()[source]

This method restores the document cursor anchor.

Returns:Method success. ( Boolean )
getCursorLine()[source]

This method returns the document cursor line.

Returns:Cursor line. ( Integer )
getCursorColumn()[source]

This method returns the document cursor column.

Returns:Cursor column. ( Integer )
getPreviousCharacter()[source]

This method returns the character before the cursor.

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

This method returns the character after the cursor.

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

This method returns the document words.

Returns:Document words. ( List )
getSelectedText()[source]

This method returns the document text under cursor.

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

This method returns the document word under cursor ( Using Qt legacy “QTextCursor.WordUnderCursor” ).

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

This method returns the document word under cursor.

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

This method returns the document partial word under cursor ( From word start to cursor position ).

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

This method returns if the document is modified.

Returns:Document modified state. ( Boolean )
setModified(state)[source]

This method sets the document modified state.

Parameters:state – Modified state. ( Boolean )
Returns:Method success. ( Boolean )
isEmpty()[source]

This method returns if the document is empty.

Returns:Document empty state. ( Boolean )
setContent(content)[source]

This method sets document with given content while providing undo capability.

Parameters:content – Content to set. ( List )
Returns:Method success. ( Boolean )
delete()[source]

This method deletes the document text under cursor.

Returns:Method success. ( Boolean )
deleteLines()[source]

This method deletes the document lines under cursor.

Returns:Method success. ( Boolean )
duplicateLines()[source]

This method duplicates the document lines under cursor.

Returns:Method success. ( Boolean )
moveLines(direction=2)[source]

This method moves the document lines under cursor.

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

This method moves up the document lines under cursor.

Returns:Method success. ( Boolean )
moveLinesDown()[source]

This method moves down the document lines under cursor.

Returns:Method success. ( Boolean )
search(pattern, **kwargs)[source]

This method 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 – Pattern to search for. ( String )
  • **kwargs – Search settings. ( Key / Value pairs )
Returns:

Method success. ( Boolean )

searchNext()[source]

This method searchs the next search pattern in the document.

Returns:Method success. ( Boolean )
searchPrevious()[source]

This method searchs the previous search pattern in the document.

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

This method 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 – Pattern to replace. ( String )
  • replacementPattern – Replacement pattern. ( String )
  • **kwargs – Format settings. ( Key / Value pairs )
Returns:

Method success. ( Boolean )

replaceAll(pattern, replacementPattern, **kwargs)[source]
This method replaces every given pattern occurences 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 – Pattern to replace. ( String )
  • replacementPattern – Replacement pattern. ( String )
  • **kwargs – Format settings. ( Key / Value pairs )
Returns:

Method success. ( Boolean )

gotoLine(line)[source]

This method moves the text cursor to given line.

Parameters:line – Line to go to. ( Integer )
Returns:Method success. ( Boolean )
gotoColumn(column)[source]

This method moves the text cursor to given column.

Parameters:column – Column to go to. ( Integer )
Returns:Method success. ( Boolean )
gotoPosition(position)[source]

This method moves the text cursor to given position.

Parameters:position – Position to go to. ( Integer )
Returns:Method success. ( Boolean )
toggleWordWrap()[source]

This method toggles document word wrap.

Returns:Method success. ( Boolean )
toggleWhiteSpaces()[source]

This method toggles document white spaces display.

Returns:Method success. ( Boolean )
setFontIncrement(value)[source]

This method increments the document font size.

Parameters:value – Font size increment. ( Integer )
Returns:Method success. ( Boolean )
zoomIn()[source]

This method increases the document font size.

Returns:Method success. ( Boolean )
zoomOut()[source]

This method increases the document font size.

Returns:Method success. ( Boolean )