Added some smart filters for quote settings

This commit is contained in:
Veronica K. B. Olsen
2021-01-20 00:08:49 +01:00
parent 0a9749726f
commit 96bc88d045
3 changed files with 48 additions and 12 deletions
+17 -12
View File
@@ -147,24 +147,29 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Quoted Strings
if self.mainConf.highlightQuotes:
fmtDO = self.mainConf.fmtDoubleQuotes[0]
fmtDC = self.mainConf.fmtDoubleQuotes[1]
fmtSO = self.mainConf.fmtSingleQuotes[0]
fmtSC = self.mainConf.fmtSingleQuotes[1]
fmtDbl = self.mainConf.fmtDoubleQuotes
fmtSng = self.mainConf.fmtSingleQuotes
# Straight Quotes
if fmtDbl != ["\"", "\""]:
self.hRules.append((
"(\\B\")(.*?)(\"\\B)", {
0 : self.hStyles["dialogue1"],
}
))
# Double Quotes
dblEnd = "|$" if self.mainConf.allowOpenDQuote else ""
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
self.hRules.append((
"\\B\"(.*?)\"\\B", {
0 : self.hStyles["dialogue1"],
}
))
self.hRules.append((
f"(\\B{fmtDO})(.*?)({fmtDC}\\B{dblEnd})", {
f"(\\B{fmtDbl[0]})(.*?)({fmtDbl[1]}\\B{dblEnd})", {
0 : self.hStyles["dialogue2"],
}
))
# Single Quotes
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
self.hRules.append((
f"(\\B{fmtSO})(.*?)({fmtSC}\\B{sngEnd})", {
f"(\\B{fmtSng[0]})(.*?)({fmtSng[1]}\\B{sngEnd})", {
0 : self.hStyles["dialogue3"],
}
))