Added back in strikethrough support

This commit is contained in:
Veronica K. B. Olsen
2020-06-13 10:27:02 +02:00
parent 31ca1718a0
commit d2b1b8b57e
10 changed files with 106 additions and 38 deletions
+32
View File
@@ -515,6 +515,8 @@ class GuiDocEditor(QTextEdit):
self._toggleEmph(2)
elif theAction == nwDocAction.BOLDITALIC:
self._toggleEmph(3)
elif theAction == nwDocAction.STRIKE:
self._toggleStrike()
elif theAction == nwDocAction.S_QUOTE:
self._wrapSelection(self.typSQOpen, self.typSQClose)
elif theAction == nwDocAction.D_QUOTE:
@@ -1000,6 +1002,36 @@ class GuiDocEditor(QTextEdit):
return
def _toggleStrike(self):
"""Toggle strikethrough text.
"""
theCursor = self._autoSelect()
if theCursor.hasSelection():
posS = theCursor.selectionStart()
posE = theCursor.selectionEnd()
numB = 0
for n in range(2):
if self.qDocument.characterAt(posS-n-1) == "~":
numB += 1
else:
break
numA = 0
for n in range(2):
if self.qDocument.characterAt(posE+n) == "~":
numA += 1
else:
break
cLevel = min(numB, numA)
if cLevel == 2:
self._clearSurrounding(theCursor, 2)
else:
self._wrapSelection("~~")
return
def _formatBlock(self, docAction):
"""Changes the block format of the block under the cursor.
"""