From 69a99fc97f78dc28b1864bc785101f06821a0004 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:53:09 +0200 Subject: [PATCH] Add a syntax colour for special notes --- docs/source/more_customise.rst | 4 ++++ novelwriter/gui/dochighlight.py | 7 ++++--- novelwriter/gui/theme.py | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/source/more_customise.rst b/docs/source/more_customise.rst index 6e6c09da..1a619274 100644 --- a/docs/source/more_customise.rst +++ b/docs/source/more_customise.rst @@ -171,6 +171,7 @@ A syntax theme ``.conf`` file consists of the following settings: straightquotes = 0, 0, 0 doublequotes = 0, 0, 0 singlequotes = 0, 0, 0 + note = 0, 0, 0 hidden = 0, 0, 0 shortcode = 0, 0, 0 keyword = 0, 0, 0 @@ -197,3 +198,6 @@ Omitted syntax colours default to black, except ``background`` which defaults to .. versionadded:: 2.4 The ``texthighlight`` syntax colour entry was added. + +.. versionadded:: 2.5 + The ``note`` syntax colour entry was added. diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 643f339b..1a2bec97 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -113,6 +113,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): self._addCharFormat("replace", SHARED.theme.colRepTag) self._addCharFormat("hidden", SHARED.theme.colHidden) self._addCharFormat("markup", SHARED.theme.colHidden) + self._addCharFormat("note", SHARED.theme.colNote) self._addCharFormat("code", SHARED.theme.colCode) self._addCharFormat("keyword", SHARED.theme.colKey) self._addCharFormat("modifier", SHARED.theme.colMod) @@ -370,11 +371,11 @@ class GuiDocHighlighter(QSyntaxHighlighter): return # No more processing for these elif cMod: self.setFormat(0, cDot, self._hStyles["modifier"]) - self.setFormat(cDot, cPos - cDot, self._hStyles["optional"]) - self.setFormat(cPos, cLen, self._hStyles["hidden"]) + self.setFormat(cDot, cPos - cDot, self._hStyles["value"]) + self.setFormat(cPos, cLen, self._hStyles["note"]) else: self.setFormat(0, cPos, self._hStyles["modifier"]) - self.setFormat(cPos, cLen, self._hStyles["hidden"]) + self.setFormat(cPos, cLen, self._hStyles["note"]) elif text.startswith("["): # Special Command self.setCurrentBlockState(BLOCK_TEXT) diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index c13283f4..e1ef1690 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -30,9 +30,7 @@ from math import ceil from pathlib import Path from PyQt5.QtCore import QSize, Qt -from PyQt5.QtGui import ( - QPalette, QColor, QIcon, QFont, QFontMetrics, QFontDatabase, QPixmap -) +from PyQt5.QtGui import QColor, QFont, QFontDatabase, QFontMetrics, QIcon, QPalette, QPixmap from PyQt5.QtWidgets import QApplication from novelwriter import CONFIG @@ -102,6 +100,7 @@ class GuiTheme: self.colDialD = QColor(0, 0, 0) self.colDialS = QColor(0, 0, 0) self.colHidden = QColor(0, 0, 0) + self.colNote = QColor(0, 0, 0) self.colCode = QColor(0, 0, 0) self.colKey = QColor(0, 0, 0) self.colVal = QColor(0, 0, 0) @@ -343,6 +342,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.colNote = self._parseColour(confParser, cnfSec, "note") self.colCode = self._parseColour(confParser, cnfSec, "shortcode") self.colKey = self._parseColour(confParser, cnfSec, "keyword") self.colVal = self._parseColour(confParser, cnfSec, "value")