def toggleNonprintable(self): if self.actionsSelector.nonprintableAction.isChecked(): option = QTextOption() option.setFlags(QTextOption.ShowTabsAndSpaces | QTextOption.ShowLineAndParagraphSeparators) self.editView.document().setDefaultTextOption(option) else: option = QTextOption() self.editView.document().setDefaultTextOption(option)
def __init__(self, parent=None): super(TagTextEdit, self).__init__(parent) self.is_undoing = False self.setAcceptRichText(False) # self.setUndoRedoEnabled(False) option = QTextOption() option.setFlags(QTextOption.ShowTabsAndSpaces | QTextOption.ShowLineAndParagraphSeparators) self.document().setDefaultTextOption(option)
def togglewhiteSpace(self, state=True): """ Show or hide whitespace and line ending markers """ option = QTextOption() if state: option.setFlags(QTextOption.ShowTabsAndSpaces | QTextOption.ShowLineAndParagraphSeparators) else: option.setFlags(option.flags() & ~option.ShowTabsAndSpaces & ~option.ShowLineAndParagraphSeparators) self.document().setDefaultTextOption(option) settings.set('editor:whiteSpace', state)
def initEditor(self): """Initialise or re-initialise the editor with the user's settings. This function is both called when the editor is created, and when the user changes the main editor preferences. """ # Some Constants self.nonWord = "\"'" self.nonWord += "".join(self.mainConf.fmtDoubleQuotes) self.nonWord += "".join(self.mainConf.fmtSingleQuotes) # Reload spell check and dictionaries self._setupSpellChecking() self.setDictionaries() # Set font theFont = QFont() if self.mainConf.textFont is None: # If none is defined, set the default back to config self.mainConf.textFont = self.qDocument.defaultFont().family() theFont.setFamily(self.mainConf.textFont) theFont.setPointSize(self.mainConf.textSize) self.setFont(theFont) docPalette = self.palette() docPalette.setColor(QPalette.Base, QColor(*self.theTheme.colBack)) docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText)) self.setPalette(docPalette) # Set default text margins self.qDocument.setDocumentMargin(self.mainConf.textMargin) # Also set the document text options for the document text flow theOpt = QTextOption() if self.mainConf.tabWidth is not None: if self.mainConf.verQtValue >= 51000: theOpt.setTabStopDistance(self.mainConf.tabWidth) if self.mainConf.doJustify: theOpt.setAlignment(Qt.AlignJustify) if self.mainConf.showTabsNSpaces: theOpt.setFlags(theOpt.flags() | QTextOption.ShowTabsAndSpaces) if self.mainConf.showLineEndings: theOpt.setFlags(theOpt.flags() | QTextOption.ShowLineAndParagraphSeparators) self.qDocument.setDefaultTextOption(theOpt) # Initialise the syntax highlighter self.hLight.initHighlighter() # If we have a document open, we should reload it in case the # font changed, otherwise we just clear the editor entirely, # which makes it read only. if self.theHandle is not None: # We must save the current handle as clearEditor() sets it # to None tHandle = self.theHandle self.clearEditor() self.loadText(tHandle) self.updateDocMargins() else: self.clearEditor() return True