Separate tags and value colours

This commit is contained in:
Veronica Berglyd Olsen
2024-04-28 22:43:46 +02:00
parent 22a34be21a
commit 1d438d5d76
8 changed files with 98 additions and 85 deletions
+9 -5
View File
@@ -465,7 +465,7 @@ class ToHtml(Tokenizer):
styles.append("a {color: rgb(66, 113, 174);}")
styles.append("mark {background: rgb(255, 255, 166);}")
styles.append(".tags {color: rgb(245, 135, 31); font-weight: bold;}")
styles.append(".keyword {color: rgb(245, 135, 31); font-weight: bold;}")
styles.append(".break {text-align: left;}")
styles.append(".synopsis {font-style: italic;}")
styles.append(".comment {font-style: italic; color: rgb(100, 100, 100);}")
@@ -518,18 +518,22 @@ class ToHtml(Tokenizer):
if not valid or not bits or bits[0] not in nwLabels.KEY_NAME:
return "", ""
result = f"<span class='tags'>{self._localLookup(nwLabels.KEY_NAME[bits[0]])}:</span> "
result = f"<span class='keyword'>{self._localLookup(nwLabels.KEY_NAME[bits[0]])}:</span> "
if len(bits) > 1:
if bits[0] == nwKeyWords.TAG_KEY:
one, two = self._project.index.parseValue(bits[1])
result += f"<a name='tag_{one}'>{one}</a>"
result += f"<a class='tag' name='tag_{one}'>{one}</a>"
if two:
result += f" | <span class='optional'>{two}</a>"
else:
if self._genMode == self.M_PREVIEW:
result += ", ".join(f"<a href='#{bits[0][1:]}={t}'>{t}</a>" for t in bits[1:])
result += ", ".join(
f"<a class='tag' href='#{bits[0][1:]}={t}'>{t}</a>" for t in bits[1:]
)
else:
result += ", ".join(f"<a href='#tag_{t}'>{t}</a>" for t in bits[1:])
result += ", ".join(
f"<a class='tag' href='#tag_{t}'>{t}</a>" for t in bits[1:]
)
return bits[0][1:], result
+2 -1
View File
@@ -116,6 +116,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self._addCharFormat("note", SHARED.theme.colNote)
self._addCharFormat("code", SHARED.theme.colCode)
self._addCharFormat("keyword", SHARED.theme.colKey)
self._addCharFormat("tag", SHARED.theme.colTag)
self._addCharFormat("modifier", SHARED.theme.colMod)
self._addCharFormat("value", SHARED.theme.colVal)
self._addCharFormat("optional", SHARED.theme.colOpt)
@@ -315,7 +316,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.setFormat(xPos, xLen, self._hStyles["keyword"])
elif isGood[n] and not self._isInactive:
one, two = index.parseValue(bit)
self.setFormat(xPos, len(one), self._hStyles["value"])
self.setFormat(xPos, len(one), self._hStyles["tag"])
if two:
yPos = xPos + len(bit) - len(two)
self.setFormat(yPos, len(two), self._hStyles["optional"])
+8 -8
View File
@@ -472,21 +472,21 @@ class GuiDocViewer(QTextBrowser):
"""Generate an appropriate style sheet for the document viewer,
based on the current syntax highlighter theme.
"""
colText = cssCol(SHARED.theme.colText)
colHead = cssCol(SHARED.theme.colHead)
colVals = cssCol(SHARED.theme.colVal)
colMark = cssCol(SHARED.theme.colMark)
colKeys = cssCol(SHARED.theme.colKey)
colOpts = cssCol(SHARED.theme.colOpt)
colHide = cssCol(SHARED.theme.colHidden)
colNote = cssCol(SHARED.theme.colNote)
colKeys = cssCol(SHARED.theme.colKey)
colMark = cssCol(SHARED.theme.colMark)
colMods = cssCol(SHARED.theme.colMod)
colNote = cssCol(SHARED.theme.colNote)
colOpts = cssCol(SHARED.theme.colOpt)
colTags = cssCol(SHARED.theme.colTag)
colText = cssCol(SHARED.theme.colText)
self.document().setDefaultStyleSheet(
f"body {{color: {colText};}}\n"
f"h1, h2, h3, h4 {{color: {colHead};}}\n"
f"a {{color: {colVals};}}\n"
f"mark {{background-color: {colMark};}}\n"
f".tags {{color: {colKeys};}}\n"
f".keyword {{color: {colKeys};}}\n"
f".tag {{color: {colTags};}}\n"
f".optional {{color: {colOpts};}}\n"
f".comment {{color: {colHide};}}\n"
f".note {{color: {colNote};}}\n"
+2
View File
@@ -103,6 +103,7 @@ class GuiTheme:
self.colNote = QColor(0, 0, 0)
self.colCode = QColor(0, 0, 0)
self.colKey = QColor(0, 0, 0)
self.colTag = QColor(0, 0, 0)
self.colVal = QColor(0, 0, 0)
self.colOpt = QColor(0, 0, 0)
self.colSpell = QColor(0, 0, 0)
@@ -345,6 +346,7 @@ class GuiTheme:
self.colNote = self._parseColour(confParser, cnfSec, "note")
self.colCode = self._parseColour(confParser, cnfSec, "shortcode")
self.colKey = self._parseColour(confParser, cnfSec, "keyword")
self.colTag = self._parseColour(confParser, cnfSec, "tag")
self.colVal = self._parseColour(confParser, cnfSec, "value")
self.colOpt = self._parseColour(confParser, cnfSec, "optional")
self.colSpell = self._parseColour(confParser, cnfSec, "spellcheckline")