Minor changes to document re-highlighting

This commit is contained in:
Veronica K. B. Olsen
2020-10-07 20:20:59 +02:00
parent dc5da378ed
commit 8bbdbde7ca
2 changed files with 10 additions and 4 deletions
+2 -3
View File
@@ -285,7 +285,7 @@ class GuiDocEditor(QTextEdit):
self._allowAutoReplace(True) self._allowAutoReplace(True)
afTime = time() afTime = time()
logger.debug("Document highlighted in %.3f milliseconds" % (1000*(afTime-bfTime))) logger.debug("Document highlighted in %.3f ms" % (1000*(afTime-bfTime)))
self.lastEdit = time() self.lastEdit = time()
self._runCounter() self._runCounter()
@@ -557,9 +557,8 @@ class GuiDocEditor(QTextEdit):
qApp.restoreOverrideCursor() qApp.restoreOverrideCursor()
afTime = time() afTime = time()
logger.debug( logger.debug(
"Document re-highlighted in %.3f milliseconds" % (1000*(afTime-bfTime)) "Document highlighted in %.3f ms" % (1000*(afTime-bfTime))
) )
self.theParent.statusBar.showMessage("Spell check complete") self.theParent.statusBar.showMessage("Spell check complete")
return True return True
+8 -1
View File
@@ -28,6 +28,8 @@
import nw import nw
import logging import logging
from time import time
from PyQt5.QtCore import Qt, QRegularExpression from PyQt5.QtCore import Qt, QRegularExpression
from PyQt5.QtGui import ( from PyQt5.QtGui import (
QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush
@@ -244,10 +246,15 @@ class GuiDocHighlighter(QSyntaxHighlighter):
""" """
qDocument = self.document() qDocument = self.document()
nBlocks = qDocument.blockCount() nBlocks = qDocument.blockCount()
bfTime = time()
for i in range(nBlocks): for i in range(nBlocks):
theBlock = qDocument.findBlockByNumber(i) theBlock = qDocument.findBlockByNumber(i)
if theBlock.userState() & theType == theType: if theBlock.userState() & theType > 0:
self.rehighlightBlock(theBlock) self.rehighlightBlock(theBlock)
afTime = time()
logger.debug(
"Document highlighted in %.3f ms" % (1000*(afTime-bfTime))
)
return return
## ##