Disable initial spell checking for large documents
This commit is contained in:
@@ -93,6 +93,7 @@ class Config:
|
|||||||
self.wordCountTimer = 5.0
|
self.wordCountTimer = 5.0
|
||||||
self.showTabsNSpaces = False
|
self.showTabsNSpaces = False
|
||||||
self.showLineEndings = False
|
self.showLineEndings = False
|
||||||
|
self.bigDocLimit = 800
|
||||||
|
|
||||||
self.fmtApostrophe = nwUnicode.U_RSQUO
|
self.fmtApostrophe = nwUnicode.U_RSQUO
|
||||||
self.fmtSingleQuotes = [nwUnicode.U_LSQUO,nwUnicode.U_RSQUO]
|
self.fmtSingleQuotes = [nwUnicode.U_LSQUO,nwUnicode.U_RSQUO]
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.wordCount = 0
|
self.wordCount = 0
|
||||||
self.paraCount = 0
|
self.paraCount = 0
|
||||||
self.lastEdit = 0
|
self.lastEdit = 0
|
||||||
|
self.bigDoc = False
|
||||||
self.nonWord = "\"'"
|
self.nonWord = "\"'"
|
||||||
|
|
||||||
# Typography
|
# Typography
|
||||||
@@ -114,17 +115,22 @@ class GuiDocEditor(QTextEdit):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def clearEditor(self):
|
def clearEditor(self):
|
||||||
|
"""Clear the current document and reset all document related
|
||||||
|
flags and counters.
|
||||||
|
"""
|
||||||
|
|
||||||
self.nwDocument.clearDocument()
|
self.nwDocument.clearDocument()
|
||||||
self.setReadOnly(True)
|
self.setReadOnly(True)
|
||||||
self.clear()
|
self.clear()
|
||||||
self.wcTimer.stop()
|
self.wcTimer.stop()
|
||||||
|
|
||||||
self.theHandle = None
|
self.theHandle = None
|
||||||
self.charCount = 0
|
self.charCount = 0
|
||||||
self.wordCount = 0
|
self.wordCount = 0
|
||||||
self.paraCount = 0
|
self.paraCount = 0
|
||||||
self.lastEdit = 0
|
self.lastEdit = 0
|
||||||
|
self.bigDoc = False
|
||||||
|
|
||||||
self.hasSelection = False
|
self.hasSelection = False
|
||||||
|
|
||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
@@ -214,8 +220,12 @@ class GuiDocEditor(QTextEdit):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
self.hLight.setHandle(tHandle)
|
self.hLight.setHandle(tHandle)
|
||||||
|
|
||||||
|
# Check that the document is not too big for full, initial spell
|
||||||
|
# checking. If it is too big, we switch to only check as we type
|
||||||
|
self._checkDocSize(len(theDoc))
|
||||||
spTemp = self.hLight.spellCheck
|
spTemp = self.hLight.spellCheck
|
||||||
self.hLight.spellCheck = False
|
self.hLight.spellCheck = not self.bigDoc
|
||||||
|
|
||||||
bfTime = time()
|
bfTime = time()
|
||||||
self.setPlainText(theDoc)
|
self.setPlainText(theDoc)
|
||||||
@@ -696,9 +706,24 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.theParent.statusBar.setCounts(self.charCount,self.wordCount,self.paraCount)
|
self.theParent.statusBar.setCounts(self.charCount,self.wordCount,self.paraCount)
|
||||||
self.theParent.treeView.propagateCount(tHandle, self.wordCount)
|
self.theParent.treeView.propagateCount(tHandle, self.wordCount)
|
||||||
self.theParent.treeView.projectWordCount()
|
self.theParent.treeView.projectWordCount()
|
||||||
|
self._checkDocSize(self.charCount)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _checkDocSize(self, theSize):
|
||||||
|
"""Check if document size crosses the big document limit set in
|
||||||
|
config. If so, we will set the big document flag to True.
|
||||||
|
"""
|
||||||
|
if theSize > self.mainConf.bigDocLimit*1000:
|
||||||
|
logger.info(
|
||||||
|
"The document size is %d > %d, big doc mode is enabled" % (
|
||||||
|
theSize, self.mainConf.bigDocLimit*1000
|
||||||
|
))
|
||||||
|
self.bigDoc = True
|
||||||
|
else:
|
||||||
|
self.bigDoc = False
|
||||||
|
return
|
||||||
|
|
||||||
def _wrapSelection(self, tBefore, tAfter):
|
def _wrapSelection(self, tBefore, tAfter):
|
||||||
"""Wraps the selected text in whatever is in tBefore and tAfter.
|
"""Wraps the selected text in whatever is in tBefore and tAfter.
|
||||||
If there is no selection, the autoSelect setting decides the
|
If there is no selection, the autoSelect setting decides the
|
||||||
|
|||||||
Reference in New Issue
Block a user