Clean up a few bits in the editor code, fix margins, and fix issue in spell checker

This commit is contained in:
Veronica Berglyd Olsen
2023-10-17 20:25:17 +02:00
parent f8bff62754
commit 9dd8f65795
2 changed files with 3 additions and 13 deletions
+2 -12
View File
@@ -95,8 +95,6 @@ class GuiDocEditor(QPlainTextEdit):
self._docChanged = False # Flag for changed status of document self._docChanged = False # Flag for changed status of document
self._docHandle = None # The handle of the open document self._docHandle = None # The handle of the open document
self._nonWord = "\"'" # Characters to not include in spell checking
self._vpMargin = 0 # The editor viewport margin, set during init self._vpMargin = 0 # The editor viewport margin, set during init
# Document Variables # Document Variables
@@ -271,13 +269,6 @@ class GuiDocEditor(QPlainTextEdit):
settings. This function is both called when the editor is settings. This function is both called when the editor is
created, and when the user changes the main editor preferences. created, and when the user changes the main editor preferences.
""" """
# Some Constants
self._nonWord = (
"\"'"
f"{CONFIG.fmtSQuoteOpen}{CONFIG.fmtSQuoteClose}"
f"{CONFIG.fmtDQuoteOpen}{CONFIG.fmtDQuoteClose}"
)
# Typography # Typography
if CONFIG.fmtPadThin: if CONFIG.fmtPadThin:
self._typPadChar = nwUnicode.U_THNBSP self._typPadChar = nwUnicode.U_THNBSP
@@ -307,9 +298,8 @@ class GuiDocEditor(QPlainTextEdit):
# Set default text margins # Set default text margins
# Due to cursor visibility, a part of the margin must be # Due to cursor visibility, a part of the margin must be
# allocated to the document itself. See issue #1112. # allocated to the document itself. See issue #1112.
cW = 2*self.cursorWidth() self._qDocument.setDocumentMargin(4)
self._qDocument.setDocumentMargin(cW) self._vpMargin = max(CONFIG.getTextMargin() - 4, 0)
self._vpMargin = max(CONFIG.getTextMargin() - cW, 0)
self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin) self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)
# Also set the document text options for the document text flow # Also set the document text options for the document text flow
+1 -1
View File
@@ -452,7 +452,7 @@ class TextBlockData(QTextBlockUserData):
while rxSpell.hasNext(): while rxSpell.hasNext():
rxMatch = rxSpell.next() rxMatch = rxSpell.next()
if not SHARED.spelling.checkWord(rxMatch.captured(0)): if not SHARED.spelling.checkWord(rxMatch.captured(0)):
if rxMatch.captured(0).isalpha() and not rxMatch.captured(0).isupper(): if not rxMatch.captured(0).isnumeric() and not rxMatch.captured(0).isupper():
self._spellErrors.append((rxMatch.capturedStart(0), rxMatch.capturedLength(0))) self._spellErrors.append((rxMatch.capturedStart(0), rxMatch.capturedLength(0)))
return self._spellErrors return self._spellErrors