Add alternative dialog style

This commit is contained in:
Veronica Berglyd Olsen
2024-05-13 18:11:44 +02:00
parent 7e35b4c675
commit b5def640ed
3 changed files with 76 additions and 29 deletions
+14 -4
View File
@@ -150,13 +150,13 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self._cmnRules.append((rxRule, hlRule))
# Dialogue
if CONFIG.dialogueStyle > 0:
if CONFIG.dialogStyle > 0:
symO = ""
symC = ""
if CONFIG.dialogueStyle in (1, 3):
if CONFIG.dialogStyle in (1, 3):
symO += CONFIG.fmtSQuoteOpen
symC += CONFIG.fmtSQuoteClose
if CONFIG.dialogueStyle in (2, 3):
if CONFIG.dialogStyle in (2, 3):
symO += CONFIG.fmtDQuoteOpen
symC += CONFIG.fmtDQuoteClose
@@ -168,7 +168,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
}
self._txtRules.append((rxRule, hlRule))
if sym := CONFIG.dialogueLine:
if sym := CONFIG.dialogLine:
rxRule = QRegularExpression(f"^{sym}.*?$")
rxRule.setPatternOptions(QRegExUnicode)
hlRule = {
@@ -184,6 +184,16 @@ class GuiDocHighlighter(QSyntaxHighlighter):
}
self._txtRules.append((rxRule, hlRule))
if CONFIG.altDialogOpen and CONFIG.altDialogClose:
symO = QRegularExpression.escape(CONFIG.altDialogOpen)
symC = QRegularExpression.escape(CONFIG.altDialogClose)
rxRule = QRegularExpression(f"\\B{symO}.*?{symC}\\B")
rxRule.setPatternOptions(QRegExUnicode)
hlRule = {
0: self._hStyles["altdialog"],
}
self._txtRules.append((rxRule, hlRule))
# Markdown Italic
rxRule = QRegularExpression(nwRegEx.FMT_EI)
rxRule.setPatternOptions(QRegExUnicode)