Added back in strikethrough support
This commit is contained in:
+3
-1
@@ -982,7 +982,9 @@ class GuiBuildNovelDocView(QTextBrowser):
|
||||
"""
|
||||
if isinstance(theText, list):
|
||||
theText = "".join(theText)
|
||||
theText = theText.replace(" "," "*4)
|
||||
theText = theText.replace(" ", " "*4)
|
||||
theText = theText.replace("<del>", "<span style='text-decoration: line-through;'>")
|
||||
theText = theText.replace("</del>", "</span>")
|
||||
self.setHtml(theText)
|
||||
return
|
||||
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -160,6 +160,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
3 : self.hStyles["hidden"],
|
||||
}
|
||||
))
|
||||
self.hRules.append((
|
||||
nwRegEx.FMT_ST, {
|
||||
1 : self.hStyles["hidden"],
|
||||
2 : self.hStyles["strike"],
|
||||
3 : self.hStyles["hidden"],
|
||||
}
|
||||
))
|
||||
|
||||
# Quoted Strings
|
||||
if self.mainConf.highlightQuotes:
|
||||
|
||||
@@ -536,6 +536,13 @@ class GuiMainMenu(QMenuBar):
|
||||
self.aFmtBoldIt.triggered.connect(lambda: self._docAction(nwDocAction.BOLDITALIC))
|
||||
self.fmtMenu.addAction(self.aFmtBoldIt)
|
||||
|
||||
# Format > Strikethrough
|
||||
self.aFmtStrike = QAction("Strikethrough Text", self)
|
||||
self.aFmtStrike.setStatusTip("Strikethrough selected text")
|
||||
self.aFmtStrike.setShortcut("Ctrl+-")
|
||||
self.aFmtStrike.triggered.connect(lambda: self._docAction(nwDocAction.STRIKE))
|
||||
self.fmtMenu.addAction(self.aFmtStrike)
|
||||
|
||||
# Edit > Separator
|
||||
self.fmtMenu.addSeparator()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user