From ec6937beebf14b0e437a30a010a4048eddcd1c95 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Tue, 4 Jun 2019 21:28:39 +0200 Subject: [PATCH] Added highlighting for replace tags --- nw/gui/dochighlight.py | 8 ++++++++ nw/theme.py | 2 ++ nw/themes/default/theme.conf | 1 + 3 files changed, 11 insertions(+) diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index c99fa3ba..20af5d01 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -45,6 +45,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self.colVal = QColor(*self.theTheme.colVal) self.colSpell = QColor(*self.theTheme.colSpell) self.colTagErr = QColor(*self.theTheme.colTagErr) + self.colRepTag = QColor(*self.theTheme.colRepTag) self.hStyles = { "header1" : self._makeFormat(self.colHead, "bold",1.8), @@ -62,6 +63,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): "dialogue1" : self._makeFormat(self.colDialN), "dialogue2" : self._makeFormat(self.colDialD), "dialogue3" : self._makeFormat(self.colDialS), + "replace" : self._makeFormat(self.colRepTag), "hidden" : self._makeFormat(self.colComm), "keyword" : self._makeFormat(self.colKey), "value" : self._makeFormat(self.colVal), @@ -148,6 +150,12 @@ class GuiDocHighlighter(QSyntaxHighlighter): } )) + self.hRules.append(( + "<(.+?)>", { + 0 : self.hStyles["replace"], + } + )) + # Build a QRegExp for each pattern and for the spell checker self.rules = [(QRegularExpression(a),b) for (a,b) in self.hRules] self.spellRx = QRegularExpression(r"\b[^\s]+\b") diff --git a/nw/theme.py b/nw/theme.py index a34a2895..88fe121d 100644 --- a/nw/theme.py +++ b/nw/theme.py @@ -38,6 +38,7 @@ class Theme: self.colVal = [0,0,0] self.colSpell = [0,0,0] self.colTagErr = [0,0,0] + self.colRepTag = [0,0,0] # Changeable Settings self.guiTheme = None @@ -96,6 +97,7 @@ class Theme: self.colVal = self._loadColour(confParser,cnfSec,"value") self.colSpell = self._loadColour(confParser,cnfSec,"spellcheckline") self.colTagErr = self._loadColour(confParser,cnfSec,"tagerror") + self.colRepTag = self._loadColour(confParser,cnfSec,"replacetag") return True diff --git a/nw/themes/default/theme.conf b/nw/themes/default/theme.conf index bac88942..b230f3a5 100644 --- a/nw/themes/default/theme.conf +++ b/nw/themes/default/theme.conf @@ -10,3 +10,4 @@ keyword = 200, 46, 0 value = 184, 200, 0 spellcheckline = 200, 46, 0 tagerror = 46, 200, 0 +replacetag = 0, 184, 46