Add syntax highlighting for open-ended quotes

This commit is contained in:
Veronica K. B. Olsen
2021-01-19 18:36:47 +01:00
parent debca0a82d
commit 4934ec2ea1
2 changed files with 14 additions and 2 deletions
+10
View File
@@ -142,6 +142,8 @@ class Config:
self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes
self.highlightQuotes = True # Highlight text in quotes
self.allowOpenSQuote = False # Allow open-ended single quotes
self.allowOpenDQuote = True # Allow open-ended double quotes
self.highlightEmph = True # Add colour to text emphasis
## User-Selected Symbols
@@ -514,6 +516,12 @@ class Config:
self.highlightQuotes = self._parseLine(
cnfParse, cnfSec, "highlightquotes", self.CNF_BOOL, self.highlightQuotes
)
self.allowOpenSQuote = self._parseLine(
cnfParse, cnfSec, "allowopensquote", self.CNF_BOOL, self.allowOpenSQuote
)
self.allowOpenDQuote = self._parseLine(
cnfParse, cnfSec, "allowopendquote", self.CNF_BOOL, self.allowOpenDQuote
)
self.highlightEmph = self._parseLine(
cnfParse, cnfSec, "highlightemph", self.CNF_BOOL, self.highlightEmph
)
@@ -645,6 +653,8 @@ class Config:
cnfParse.set(cnfSec, "bigdoclimit", str(self.bigDocLimit))
cnfParse.set(cnfSec, "showfullpath", str(self.showFullPath))
cnfParse.set(cnfSec, "highlightquotes", str(self.highlightQuotes))
cnfParse.set(cnfSec, "allowopensquote", str(self.allowOpenSQuote))
cnfParse.set(cnfSec, "allowopendquote", str(self.allowOpenDQuote))
cnfParse.set(cnfSec, "highlightemph", str(self.highlightEmph))
## Backup
+4 -2
View File
@@ -151,18 +151,20 @@ class GuiDocHighlighter(QSyntaxHighlighter):
fmtDC = self.mainConf.fmtDoubleQuotes[1]
fmtSO = self.mainConf.fmtSingleQuotes[0]
fmtSC = self.mainConf.fmtSingleQuotes[1]
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:s}(.*?){fmtDC:s}\\B", {
f"(\\B{fmtDO})(.*?)({fmtDC}\\B{dblEnd})", {
0 : self.hStyles["dialogue2"],
}
))
self.hRules.append((
f"\\B{fmtSO:s}(.*?){fmtSC:s}\\B", {
f"(\\B{fmtSO})(.*?)({fmtSC}\\B{sngEnd})", {
0 : self.hStyles["dialogue3"],
}
))