Add syntax theme entry for shortcodes
This commit is contained in:
@@ -159,6 +159,7 @@ A syntax theme ``.conf`` file consists of the follwing settings:
|
||||
doublequotes = 0, 0, 0
|
||||
singlequotes = 0, 0, 0
|
||||
hidden = 0, 0, 0
|
||||
shortcode = 0, 0, 0
|
||||
keyword = 0, 0, 0
|
||||
value = 0, 0, 0
|
||||
spellcheckline = 0, 0, 0
|
||||
@@ -169,3 +170,7 @@ A syntax theme ``.conf`` file consists of the follwing settings:
|
||||
In the Main section, you must define at least the ``name`` setting. The Syntax colour values are
|
||||
RGB numbers on the format ``r, g, b`` where each is an integer from to 255. Omitted values default
|
||||
to black, except ``background`` which defaults to white,
|
||||
|
||||
.. versionadded:: 2.2
|
||||
The `shortcode` syntax colour entry was added, so you need to update your custom themes if you
|
||||
made any before version 2.2.
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 200, 46, 0
|
||||
doublequotes = 184, 200, 0
|
||||
singlequotes = 136, 200, 0
|
||||
hidden = 150, 150, 150
|
||||
shortcode = 0, 155, 200
|
||||
keyword = 200, 46, 0
|
||||
value = 184, 200, 0
|
||||
spellcheckline = 200, 46, 0
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 200, 0, 0
|
||||
doublequotes = 0, 0, 200
|
||||
singlequotes = 0, 0, 200
|
||||
hidden = 100, 100, 100
|
||||
shortcode = 0, 100, 0
|
||||
keyword = 200, 50, 50
|
||||
value = 50, 150, 50
|
||||
spellcheckline = 200, 0, 0
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 200, 200, 200
|
||||
doublequotes = 200, 200, 200
|
||||
singlequotes = 200, 200, 200
|
||||
hidden = 150, 150, 150
|
||||
shortcode = 225, 225, 225
|
||||
keyword = 225, 225, 225
|
||||
value = 200, 200, 200
|
||||
spellcheckline = 200, 46, 0
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 20, 20, 20
|
||||
doublequotes = 20, 20, 20
|
||||
singlequotes = 20, 20, 20
|
||||
hidden = 100, 100, 100
|
||||
shortcode = 0, 0, 0
|
||||
keyword = 0, 0, 0
|
||||
value = 20, 20, 20
|
||||
spellcheckline = 200, 0, 0
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 222, 61, 58
|
||||
doublequotes = 8, 145, 106
|
||||
singlequotes = 255, 235, 149
|
||||
hidden = 152, 159, 177
|
||||
shortcode = 40, 142, 215
|
||||
keyword = 222, 61, 58
|
||||
value = 150, 74, 193
|
||||
spellcheckline = 222, 61, 58
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 247, 140, 108
|
||||
doublequotes = 173, 219, 103
|
||||
singlequotes = 255, 235, 149
|
||||
hidden = 99, 119, 119
|
||||
shortcode = 130, 170, 255
|
||||
keyword = 247, 140, 108
|
||||
value = 199, 146, 234
|
||||
spellcheckline = 247, 140, 108
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 211, 54, 130
|
||||
doublequotes = 42, 161, 152
|
||||
singlequotes = 42, 161, 152
|
||||
hidden = 147, 161, 161
|
||||
shortcode = 147, 161, 161
|
||||
keyword = 133, 153, 0
|
||||
value = 203, 75, 22
|
||||
spellcheckline = 203, 75, 22
|
||||
|
||||
@@ -17,6 +17,7 @@ straightquotes = 211, 54, 130
|
||||
doublequotes = 42, 161, 152
|
||||
singlequotes = 42, 161, 152
|
||||
hidden = 88, 110, 117
|
||||
shortcode = 88, 110, 117
|
||||
keyword = 133, 153, 0
|
||||
value = 203, 75, 22
|
||||
spellcheckline = 203, 75, 22
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 240, 40, 41
|
||||
doublequotes = 113, 140, 0
|
||||
singlequotes = 234, 183, 0
|
||||
hidden = 142, 144, 140
|
||||
shortcode = 66, 113, 174
|
||||
keyword = 240, 40, 41
|
||||
value = 137, 89, 168
|
||||
spellcheckline = 240, 40, 41
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 204, 102, 102
|
||||
doublequotes = 181, 189, 104
|
||||
singlequotes = 240, 198, 116
|
||||
hidden = 150, 152, 150
|
||||
shortcode = 129, 162, 190
|
||||
keyword = 204, 102, 102
|
||||
value = 178, 148, 187
|
||||
spellcheckline = 204, 102, 102
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 255, 157, 164
|
||||
doublequotes = 209, 241, 169
|
||||
singlequotes = 255, 238, 173
|
||||
hidden = 114, 133, 183
|
||||
shortcode = 187, 218, 255
|
||||
keyword = 255, 157, 164
|
||||
value = 235, 187, 255
|
||||
spellcheckline = 255, 157, 164
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 213, 78, 83
|
||||
doublequotes = 185, 202, 74
|
||||
singlequotes = 231, 197, 71
|
||||
hidden = 150, 152, 150
|
||||
shortcode = 122, 166, 218
|
||||
keyword = 213, 78, 83
|
||||
value = 195, 151, 216
|
||||
spellcheckline = 213, 78, 83
|
||||
|
||||
@@ -37,6 +37,7 @@ straightquotes = 242, 119, 122
|
||||
doublequotes = 153, 204, 153
|
||||
singlequotes = 255, 204, 102
|
||||
hidden = 153, 153, 153
|
||||
shortcode = 102, 153, 204
|
||||
keyword = 242, 119, 122
|
||||
value = 204, 153, 204
|
||||
spellcheckline = 242, 119, 122
|
||||
|
||||
@@ -39,7 +39,7 @@ from novelwriter.constants import nwRegEx, nwUnicode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
SPELLRX = QRegularExpression(r"\b[^\s\-\+\/–—\[\]]+\b")
|
||||
SPELLRX = QRegularExpression(r"\b[^\s\-\+\/–—\[\]:]+\b")
|
||||
SPELLRX.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self._colDialD = QColor(0, 0, 0)
|
||||
self._colDialS = QColor(0, 0, 0)
|
||||
self._colHidden = QColor(0, 0, 0)
|
||||
self._colCode = QColor(0, 0, 0)
|
||||
self._colKey = QColor(0, 0, 0)
|
||||
self._colVal = QColor(0, 0, 0)
|
||||
self._colSpell = QColor(0, 0, 0)
|
||||
@@ -95,6 +96,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self._colDialD = QColor(*SHARED.theme.colDialD)
|
||||
self._colDialS = QColor(*SHARED.theme.colDialS)
|
||||
self._colHidden = QColor(*SHARED.theme.colHidden)
|
||||
self._colCode = QColor(*SHARED.theme.colCode)
|
||||
self._colKey = QColor(*SHARED.theme.colKey)
|
||||
self._colVal = QColor(*SHARED.theme.colVal)
|
||||
self._colSpell = QColor(*SHARED.theme.colSpell)
|
||||
@@ -127,6 +129,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
"dialogue3": self._makeFormat(self._colDialS),
|
||||
"replace": self._makeFormat(self._colRepTag),
|
||||
"hidden": self._makeFormat(self._colHidden),
|
||||
"code": self._makeFormat(self._colCode),
|
||||
"keyword": self._makeFormat(self._colKey),
|
||||
"modifier": self._makeFormat(self._colMod),
|
||||
"value": self._makeFormat(self._colVal, "underline"),
|
||||
@@ -205,14 +208,19 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
}
|
||||
))
|
||||
|
||||
# In-Text Command
|
||||
# Shortcodes
|
||||
self._hRules.append((
|
||||
nwRegEx.FMT_IN, {
|
||||
1: self._hStyles["keyword"],
|
||||
2: self._hStyles["keyword"],
|
||||
3: self._hStyles["keyword"],
|
||||
4: self._hStyles["codevalue"],
|
||||
5: self._hStyles["keyword"],
|
||||
nwRegEx.FMT_SC, {
|
||||
1: self._hStyles["code"],
|
||||
}
|
||||
))
|
||||
|
||||
# Shortcodes w/Value
|
||||
self._hRules.append((
|
||||
nwRegEx.FMT_SV, {
|
||||
1: self._hStyles["code"],
|
||||
2: self._hStyles["codevalue"],
|
||||
3: self._hStyles["code"],
|
||||
}
|
||||
))
|
||||
|
||||
@@ -358,17 +366,17 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
else: # Text Paragraph
|
||||
|
||||
if text.startswith("["): # Special Command
|
||||
sText = text.rstrip()
|
||||
if sText in ("[NEWPAGE]", "[NEW PAGE]", "[VSPACE]"):
|
||||
self.setFormat(0, len(text), self._hStyles["keyword"])
|
||||
sText = text.rstrip().lower()
|
||||
if sText in ("[newpage]", "[new page]", "[vspace]"):
|
||||
self.setFormat(0, len(text), self._hStyles["code"])
|
||||
return
|
||||
elif sText.startswith("[VSPACE:") and sText.endswith("]"):
|
||||
elif sText.startswith("[vspace:") and sText.endswith("]"):
|
||||
tLen = len(sText)
|
||||
tVal = checkInt(sText[8:-1], 0)
|
||||
cVal = "codevalue" if tVal > 0 else "codeinval"
|
||||
self.setFormat(0, 8, self._hStyles["keyword"])
|
||||
self.setFormat(0, 8, self._hStyles["code"])
|
||||
self.setFormat(8, tLen-9, self._hStyles[cVal])
|
||||
self.setFormat(tLen-1, tLen, self._hStyles["keyword"])
|
||||
self.setFormat(tLen-1, tLen, self._hStyles["code"])
|
||||
return
|
||||
|
||||
# Regular Text
|
||||
|
||||
@@ -97,6 +97,7 @@ class GuiTheme:
|
||||
self.colDialD = [0, 0, 0]
|
||||
self.colDialS = [0, 0, 0]
|
||||
self.colHidden = [0, 0, 0]
|
||||
self.colCode = [0, 0, 0]
|
||||
self.colKey = [0, 0, 0]
|
||||
self.colVal = [0, 0, 0]
|
||||
self.colSpell = [0, 0, 0]
|
||||
@@ -316,6 +317,7 @@ class GuiTheme:
|
||||
self.colDialD = self._parseColour(confParser, cnfSec, "doublequotes")
|
||||
self.colDialS = self._parseColour(confParser, cnfSec, "singlequotes")
|
||||
self.colHidden = self._parseColour(confParser, cnfSec, "hidden")
|
||||
self.colCode = self._parseColour(confParser, cnfSec, "shortcode")
|
||||
self.colKey = self._parseColour(confParser, cnfSec, "keyword")
|
||||
self.colVal = self._parseColour(confParser, cnfSec, "value")
|
||||
self.colSpell = self._parseColour(confParser, cnfSec, "spellcheckline")
|
||||
|
||||
Reference in New Issue
Block a user