Add a syntax theme colour entry for text highlighting

This commit is contained in:
Veronica Berglyd Olsen
2024-02-25 16:55:17 +01:00
parent 0566fc38af
commit 23bd5dfc41
16 changed files with 31 additions and 8 deletions
+11 -6
View File
@@ -179,15 +179,20 @@ A syntax theme ``.conf`` file consists of the following settings:
errorline = 0, 0, 0 errorline = 0, 0, 0
replacetag = 0, 0, 0 replacetag = 0, 0, 0
modifier = 0, 0, 0 modifier = 0, 0, 0
texthighlight = 255, 255, 255, 128
In the Main section, you must define at least the ``name`` setting. The Syntax colour values are In the Main section, you must define at least the ``name`` setting. The Syntax colour values are
RGB numbers of the format ``r, g, b`` where each is an integer from to 255. Omitted values default RGB(A) numbers of the format ``r, g, b, a`` where each is an integer from to 255. The fourth value
to black, except ``background`` which defaults to white, is the alpha channel, which can be omitted.
Omitted syntax colours default to black, except ``background`` which defaults to white, and
``texthighlight`` which defaults to grey.
.. versionadded:: 2.2 .. versionadded:: 2.2
The `shortcode` syntax colour entry was added, so you need to update your custom themes if you The `shortcode` syntax colour entry was added.
made any before version 2.2.
.. versionadded:: 2.3 .. versionadded:: 2.3
The `optional` syntax colour entry was added, so you need to update your custom themes if you The `optional` syntax colour entry was added.
made any before version 2.3.
.. versionadded:: 2.4
The `texthighlight` syntax colour entry was added.
@@ -25,3 +25,4 @@ spellcheckline = 200, 46, 0
errorline = 46, 200, 0 errorline = 46, 200, 0
replacetag = 0, 184, 46 replacetag = 0, 184, 46
modifier = 200, 120, 0 modifier = 200, 120, 0
texthighlight = 136, 200, 0, 96
@@ -25,3 +25,4 @@ spellcheckline = 200, 0, 0
errorline = 0, 150, 0 errorline = 0, 150, 0
replacetag = 0, 150, 0 replacetag = 0, 150, 0
modifier = 150, 110, 30 modifier = 150, 110, 30
texthighlight = 150, 150, 0, 96
+1
View File
@@ -25,3 +25,4 @@ spellcheckline = 200, 46, 0
errorline = 46, 200, 0 errorline = 46, 200, 0
replacetag = 225, 225, 225 replacetag = 225, 225, 225
modifier = 225, 225, 225 modifier = 225, 225, 225
texthighlight = 255, 255, 255, 64
@@ -25,3 +25,4 @@ spellcheckline = 200, 0, 0
errorline = 0, 150, 0 errorline = 0, 150, 0
replacetag = 0, 0, 0 replacetag = 0, 0, 0
modifier = 0, 0, 0 modifier = 0, 0, 0
texthighlight = 0, 0, 0, 64
+1
View File
@@ -45,3 +45,4 @@ spellcheckline = 222, 61, 58
errorline = 8, 145, 106 errorline = 8, 145, 106
replacetag = 42, 162, 152 replacetag = 42, 162, 152
modifier = 224, 175, 5 modifier = 224, 175, 5
texthighlight = 218, 170, 1, 96
+1
View File
@@ -45,3 +45,4 @@ spellcheckline = 247, 140, 108
errorline = 173, 219, 103 errorline = 173, 219, 103
replacetag = 127, 219, 202 replacetag = 127, 219, 202
modifier = 236, 196, 141 modifier = 236, 196, 141
texthighlight = 255, 235, 149, 96
@@ -25,3 +25,4 @@ spellcheckline = 203, 75, 22
errorline = 220, 50, 47 errorline = 220, 50, 47
replacetag = 133, 153, 0 replacetag = 133, 153, 0
modifier = 181, 137, 0 modifier = 181, 137, 0
texthighlight = 181, 137, 0, 96
@@ -25,3 +25,4 @@ spellcheckline = 203, 75, 22
errorline = 220, 50, 47 errorline = 220, 50, 47
replacetag = 133, 153, 0 replacetag = 133, 153, 0
modifier = 181, 137, 0 modifier = 181, 137, 0
texthighlight = 181, 137, 0, 96
+1
View File
@@ -45,3 +45,4 @@ spellcheckline = 240, 40, 41
errorline = 113, 140, 0 errorline = 113, 140, 0
replacetag = 62, 153, 159 replacetag = 62, 153, 159
modifier = 245, 135, 31 modifier = 245, 135, 31
texthighlight = 234, 183, 0, 96
@@ -45,3 +45,4 @@ spellcheckline = 204, 102, 102
errorline = 181, 189, 104 errorline = 181, 189, 104
replacetag = 138, 190, 183 replacetag = 138, 190, 183
modifier = 222, 147, 95 modifier = 222, 147, 95
texthighlight = 240, 198, 116, 96
@@ -45,3 +45,4 @@ spellcheckline = 255, 157, 164
errorline = 209, 241, 169 errorline = 209, 241, 169
replacetag = 153, 255, 255 replacetag = 153, 255, 255
modifier = 255, 197, 143 modifier = 255, 197, 143
texthighlight = 255, 238, 173, 96
@@ -45,3 +45,4 @@ spellcheckline = 213, 78, 83
errorline = 185, 202, 74 errorline = 185, 202, 74
replacetag = 112, 192, 177 replacetag = 112, 192, 177
modifier = 231, 140, 69 modifier = 231, 140, 69
texthighlight = 231, 197, 71, 128
@@ -45,3 +45,4 @@ spellcheckline = 242, 119, 122
errorline = 153, 204, 153 errorline = 153, 204, 153
replacetag = 102, 204, 204 replacetag = 102, 204, 204
modifier = 249, 145, 57 modifier = 249, 145, 57
texthighlight = 255, 204, 102, 96
+5 -2
View File
@@ -29,7 +29,9 @@ import logging
from time import time from time import time
from pathlib import Path from pathlib import Path
from novelwriter import CONFIG from PyQt5.QtGui import QColor
from novelwriter import CONFIG, SHARED
from novelwriter.common import formatTimeStamp from novelwriter.common import formatTimeStamp
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwHtmlUnicode from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwHtmlUnicode
from novelwriter.core.project import NWProject from novelwriter.core.project import NWProject
@@ -124,6 +126,7 @@ class ToHtml(Tokenizer):
def doConvert(self) -> None: def doConvert(self) -> None:
"""Convert the list of text tokens into an HTML document.""" """Convert the list of text tokens into an HTML document."""
if self._genMode == self.M_PREVIEW: if self._genMode == self.M_PREVIEW:
colMark = SHARED.theme.colMark.name(QColor.NameFormat.HexArgb)
htmlTags = { # HTML4 + CSS2 (for Qt) htmlTags = { # HTML4 + CSS2 (for Qt)
self.FMT_B_B: "<b>", self.FMT_B_B: "<b>",
self.FMT_B_E: "</b>", self.FMT_B_E: "</b>",
@@ -133,7 +136,7 @@ class ToHtml(Tokenizer):
self.FMT_D_E: "</span>", self.FMT_D_E: "</span>",
self.FMT_U_B: "<u>", self.FMT_U_B: "<u>",
self.FMT_U_E: "</u>", self.FMT_U_E: "</u>",
self.FMT_M_B: "<span style='background-color: yellow;'>", self.FMT_M_B: f"<span style='background-color: {colMark};'>",
self.FMT_M_E: "</span>", self.FMT_M_E: "</span>",
} }
else: else:
+2
View File
@@ -106,6 +106,7 @@ class GuiTheme:
self.colError = QColor(0, 0, 0) self.colError = QColor(0, 0, 0)
self.colRepTag = QColor(0, 0, 0) self.colRepTag = QColor(0, 0, 0)
self.colMod = QColor(0, 0, 0) self.colMod = QColor(0, 0, 0)
self.colMark = QColor(255, 255, 255, 128)
# Class Setup # Class Setup
# =========== # ===========
@@ -329,6 +330,7 @@ class GuiTheme:
self.colError = self._parseColour(confParser, cnfSec, "errorline") self.colError = self._parseColour(confParser, cnfSec, "errorline")
self.colRepTag = self._parseColour(confParser, cnfSec, "replacetag") self.colRepTag = self._parseColour(confParser, cnfSec, "replacetag")
self.colMod = self._parseColour(confParser, cnfSec, "modifier") self.colMod = self._parseColour(confParser, cnfSec, "modifier")
self.colMark = self._parseColour(confParser, cnfSec, "texthighlight")
return True return True