provide syntax highlighting color schemes for light and dark themes

This commit is contained in:
Axel Kohlmeyer
2024-08-24 19:20:39 -04:00
parent baf1511f23
commit e19556263c
2 changed files with 53 additions and 21 deletions

View File

@ -12,6 +12,7 @@
------------------------------------------------------------------------- */
#include "highlighter.h"
#include "helpers.h"
Highlighter::Highlighter(QTextDocument *parent) :
QSyntaxHighlighter(parent),
@ -54,27 +55,54 @@ Highlighter::Highlighter(QTextDocument *parent) :
isTriple(QStringLiteral("[^\"]*\"\"\"[^\"]*")),
isString(QStringLiteral("(\".+?\"|'.+?'|\"\"\".*\"\"\")")), in_triple(false)
{
formatNumber.setForeground(Qt::blue);
formatString.setForeground(Qt::darkGreen);
formatString.setFontWeight(QFont::Normal);
formatComment.setForeground(Qt::red);
formatSpecial.setForeground(Qt::darkMagenta);
formatSpecial.setFontWeight(QFont::Bold);
formatParticle.setForeground(Qt::darkRed);
formatParticle.setFontWeight(QFont::Bold);
formatRun.setForeground(Qt::darkBlue);
formatRun.setFontWeight(QFont::Bold);
formatVariable.setForeground(Qt::darkGray);
formatVariable.setFontWeight(QFont::Bold);
if (is_light_theme()) {
// syntax colors for light themes
formatNumber.setForeground(Qt::blue);
formatString.setForeground(Qt::darkGreen);
formatString.setFontWeight(QFont::Normal);
formatComment.setForeground(Qt::red);
formatSpecial.setForeground(Qt::darkMagenta);
formatSpecial.setFontWeight(QFont::Bold);
formatParticle.setForeground(Qt::darkRed);
formatParticle.setFontWeight(QFont::Bold);
formatRun.setForeground(Qt::darkBlue);
formatRun.setFontWeight(QFont::Bold);
formatVariable.setForeground(Qt::darkGray);
formatVariable.setFontWeight(QFont::Bold);
formatOutput.setForeground(Qt::darkYellow);
formatOutput.setFontWeight(QFont::Bold);
formatRead.setForeground(Qt::magenta);
formatRead.setFontWeight(QFont::Bold);
formatLattice.setForeground(Qt::darkGreen);
formatLattice.setFontWeight(QFont::Bold);
formatSetup.setForeground(Qt::darkCyan);
formatSetup.setFontWeight(QFont::Bold);
formatOutput.setForeground(Qt::darkYellow);
formatOutput.setFontWeight(QFont::Bold);
formatRead.setForeground(Qt::magenta);
formatRead.setFontWeight(QFont::Bold);
formatLattice.setForeground(Qt::darkGreen);
formatLattice.setFontWeight(QFont::Bold);
formatSetup.setForeground(Qt::darkCyan);
formatSetup.setFontWeight(QFont::Bold);
} else {
// syntax colors for dark themes
formatNumber.setForeground(QColorConstants::Svg::dodgerblue);
formatString.setForeground(QColorConstants::Green);
formatString.setFontWeight(QFont::Normal);
formatComment.setForeground(QColorConstants::Red);
formatComment.setFontWeight(QFont::Bold);
formatSpecial.setForeground(QColorConstants::Magenta);
formatSpecial.setFontWeight(QFont::Bold);
formatParticle.setForeground(QColorConstants::Svg::indianred);
formatParticle.setFontWeight(QFont::Bold);
formatRun.setForeground(QColorConstants::Svg::lightskyblue);
formatRun.setFontWeight(QFont::Bold);
formatVariable.setForeground(QColorConstants::Svg::lightgray);
formatVariable.setFontWeight(QFont::Bold);
formatOutput.setForeground(QColorConstants::Yellow);
formatOutput.setFontWeight(QFont::Bold);
formatRead.setForeground(QColorConstants::Svg::lightcoral);
formatRead.setFontWeight(QFont::Bold);
formatLattice.setForeground(QColorConstants::Svg::lightgreen);
formatLattice.setFontWeight(QFont::Bold);
formatSetup.setForeground(QColorConstants::Cyan);
formatSetup.setFontWeight(QFont::Bold);
}
}
void Highlighter::highlightBlock(const QString &text)

View File

@ -1431,7 +1431,11 @@ void LammpsGui::setFont(const QFont &newfont)
void LammpsGui::about()
{
std::string version = "This is LAMMPS-GUI version " LAMMPS_GUI_VERSION;
version += " using Qt version " QT_VERSION_STR "\n";
version += " using Qt version " QT_VERSION_STR;
if (is_light_theme())
version += " using light theme\n";
else
version += " using dark theme\n";
if (lammps.has_plugin()) {
version += "LAMMPS library loaded as plugin";
if (!plugin_path.empty()) {