From 8bbdbde7ca4bd1300fb8b47a3c0e36b63e96c922 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 7 Oct 2020 20:20:59 +0200 Subject: [PATCH] Minor changes to document re-highlighting --- nw/gui/doceditor.py | 5 ++--- nw/gui/dochighlight.py | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 6592c6f1..16683d1f 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -285,7 +285,7 @@ class GuiDocEditor(QTextEdit): self._allowAutoReplace(True) 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._runCounter() @@ -557,9 +557,8 @@ class GuiDocEditor(QTextEdit): qApp.restoreOverrideCursor() afTime = time() 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") return True diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index e6e97533..564b1a9b 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -28,6 +28,8 @@ import nw import logging +from time import time + from PyQt5.QtCore import Qt, QRegularExpression from PyQt5.QtGui import ( QColor, QTextCharFormat, QFont, QSyntaxHighlighter, QBrush @@ -244,10 +246,15 @@ class GuiDocHighlighter(QSyntaxHighlighter): """ qDocument = self.document() nBlocks = qDocument.blockCount() + bfTime = time() for i in range(nBlocks): theBlock = qDocument.findBlockByNumber(i) - if theBlock.userState() & theType == theType: + if theBlock.userState() & theType > 0: self.rehighlightBlock(theBlock) + afTime = time() + logger.debug( + "Document highlighted in %.3f ms" % (1000*(afTime-bfTime)) + ) return ##