PMsrHighlighter tweak for Dark Color Schemes. Likely more work needs to be done (dynamic switching, etc.).

This commit is contained in:
2026-07-15 10:25:19 +02:00
parent f03e103844
commit 358fc8ec6d
+67 -21
View File
@@ -30,6 +30,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QGuiApplication>
#include <QStyleHints>
#include <QMessageBox> //as35
#include "PMsrHighlighter.h"
/**
@@ -82,27 +86,69 @@ PMsrHighlighter::PMsrHighlighter(QTextDocument *parent)
// =========================================================================
// Define the colour/styling for each keyword type.
blockFormat.setForeground(tabOlive); // BLOCK keywords
theoryFormat.setForeground(tabGreen); // THEORY keywords
functionsFormat.setForeground(tabRed); // FUNCTION keywords
parFormat.setForeground(tabPink); // parX keywords
mapFormat.setForeground(tabOrange); // mapX keywords
funFormat.setForeground(tabPurple); // funX keywords
runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords
commandsFormat.setForeground(tabGreen); // COMMANDS keywords
fourierFormat.setForeground(tabGreen); // FOURIER keywords
plotFormat.setForeground(tabGreen); // PLOT keywords
optionsFormat.setForeground(tabRed); // keywords input options
infoFormat.setForeground(tabGray); // auto-printed information
boolFormat.setForeground(tabRed); // boolean strings
nullFormat.setForeground(tabRed); // null strings
dateFormat.setForeground(tabPink); // date & time strings
numberFormat.setForeground(tabBlue); // integer & float strings
commentFormat.setForeground(tabGray); // comments
commentFormat.setFontItalic(true);
titleFormat.setForeground(Qt::black); // title
// titleFormat.setBackground(tabGrayLight);
Qt::ColorScheme scheme = QGuiApplication::styleHints()->colorScheme();
if (scheme == Qt::ColorScheme::Light) {
blockFormat.setForeground(tabOlive); // BLOCK keywords
theoryFormat.setForeground(tabGreen); // THEORY keywords
functionsFormat.setForeground(tabRed); // FUNCTION keywords
parFormat.setForeground(tabPink); // parX keywords
mapFormat.setForeground(tabOrange); // mapX keywords
funFormat.setForeground(tabPurple); // funX keywords
runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords
commandsFormat.setForeground(tabGreen); // COMMANDS keywords
fourierFormat.setForeground(tabGreen); // FOURIER keywords
plotFormat.setForeground(tabGreen); // PLOT keywords
optionsFormat.setForeground(tabRed); // keywords input options
infoFormat.setForeground(tabGray); // auto-printed information
boolFormat.setForeground(tabRed); // boolean strings
nullFormat.setForeground(tabRed); // null strings
dateFormat.setForeground(tabPink); // date & time strings
numberFormat.setForeground(tabBlue); // integer & float strings
commentFormat.setForeground(tabGray); // comments
commentFormat.setFontItalic(true);
titleFormat.setForeground(Qt::black); // title
} else if (scheme == Qt::ColorScheme::Dark) {
blockFormat.setForeground(tabOlive); // BLOCK keywords
theoryFormat.setForeground(tabGreen); // THEORY keywords
functionsFormat.setForeground(tabRed); // FUNCTION keywords
parFormat.setForeground(tabPink); // parX keywords
mapFormat.setForeground(tabOrange); // mapX keywords
funFormat.setForeground(tabPurple); // funX keywords
runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords
commandsFormat.setForeground(tabGreen); // COMMANDS keywords
fourierFormat.setForeground(tabGreen); // FOURIER keywords
plotFormat.setForeground(tabGreen); // PLOT keywords
optionsFormat.setForeground(tabRed); // keywords input options
infoFormat.setForeground(tabGray); // auto-printed information
boolFormat.setForeground(tabRed); // boolean strings
nullFormat.setForeground(tabRed); // null strings
dateFormat.setForeground(tabPink); // date & time strings
numberFormat.setForeground(tabBlueLight); // integer & float strings
commentFormat.setForeground(tabGray); // comments
commentFormat.setFontItalic(true);
titleFormat.setForeground(Qt::white); // title
} else { // set it to Light for now
blockFormat.setForeground(tabOlive); // BLOCK keywords
theoryFormat.setForeground(tabGreen); // THEORY keywords
functionsFormat.setForeground(tabRed); // FUNCTION keywords
parFormat.setForeground(tabPink); // parX keywords
mapFormat.setForeground(tabOrange); // mapX keywords
funFormat.setForeground(tabPurple); // funX keywords
runFormat.setForeground(tabGreen); // RUN/GLOBAL keywords
commandsFormat.setForeground(tabGreen); // COMMANDS keywords
fourierFormat.setForeground(tabGreen); // FOURIER keywords
plotFormat.setForeground(tabGreen); // PLOT keywords
optionsFormat.setForeground(tabRed); // keywords input options
infoFormat.setForeground(tabGray); // auto-printed information
boolFormat.setForeground(tabRed); // boolean strings
nullFormat.setForeground(tabRed); // null strings
dateFormat.setForeground(tabPink); // date & time strings
numberFormat.setForeground(tabBlue); // integer & float strings
commentFormat.setForeground(tabGray); // comments
commentFormat.setFontItalic(true);
titleFormat.setForeground(Qt::black); // title
}
// =========================================================================
// BLOCK HEADERS