mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-16 06:13:09 +00:00
fixed issue of text color changing for code blocks in light mode (#1299)
This commit is contained in:
parent
55f96aacc6
commit
3d2db76070
@ -23,6 +23,8 @@ enum Language {
|
|||||||
Php
|
Php
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static QColor defaultColor = "#d1d5db"; // white
|
||||||
static QColor keywordColor = "#2e95d3"; // blue
|
static QColor keywordColor = "#2e95d3"; // blue
|
||||||
static QColor functionColor = "#f22c3d"; // red
|
static QColor functionColor = "#f22c3d"; // red
|
||||||
static QColor functionCallColor = "#e9950c"; // orange
|
static QColor functionCallColor = "#e9950c"; // orange
|
||||||
@ -91,6 +93,12 @@ static QVector<HighlightingRule> pythonHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -151,6 +159,12 @@ static QVector<HighlightingRule> csharpHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
// Function call highlighting
|
// Function call highlighting
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
@ -219,6 +233,12 @@ static QVector<HighlightingRule> cppHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -297,6 +317,12 @@ static QVector<HighlightingRule> typescriptHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -381,6 +407,12 @@ static QVector<HighlightingRule> javaHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -450,6 +482,12 @@ static QVector<HighlightingRule> goHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -515,6 +553,12 @@ static QVector<HighlightingRule> bashHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat commandFormat;
|
QTextCharFormat commandFormat;
|
||||||
commandFormat.setForeground(commandColor);
|
commandFormat.setForeground(commandColor);
|
||||||
QStringList commandPatterns = {
|
QStringList commandPatterns = {
|
||||||
@ -582,6 +626,12 @@ static QVector<HighlightingRule> latexHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat commandFormat;
|
QTextCharFormat commandFormat;
|
||||||
commandFormat.setForeground(commandColor); // commandColor needs to be set to your liking
|
commandFormat.setForeground(commandColor); // commandColor needs to be set to your liking
|
||||||
rule.pattern = QRegularExpression("\\\\[A-Za-z]+"); // Pattern for LaTeX commands
|
rule.pattern = QRegularExpression("\\\\[A-Za-z]+"); // Pattern for LaTeX commands
|
||||||
@ -604,6 +654,12 @@ static QVector<HighlightingRule> htmlHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat attributeNameFormat;
|
QTextCharFormat attributeNameFormat;
|
||||||
attributeNameFormat.setForeground(attributeNameColor);
|
attributeNameFormat.setForeground(attributeNameColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*=");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*=");
|
||||||
@ -644,6 +700,12 @@ static QVector<HighlightingRule> phpHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
QTextCharFormat functionCallFormat;
|
QTextCharFormat functionCallFormat;
|
||||||
functionCallFormat.setForeground(functionCallColor);
|
functionCallFormat.setForeground(functionCallColor);
|
||||||
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
rule.pattern = QRegularExpression("\\b(\\w+)\\s*(?=\\()");
|
||||||
@ -711,6 +773,12 @@ static QVector<HighlightingRule> jsonHighlightingRules()
|
|||||||
|
|
||||||
HighlightingRule rule;
|
HighlightingRule rule;
|
||||||
|
|
||||||
|
QTextCharFormat defaultFormat;
|
||||||
|
defaultFormat.setForeground(defaultColor);
|
||||||
|
rule.pattern = QRegularExpression(".*");
|
||||||
|
rule.format = defaultFormat;
|
||||||
|
highlightingRules.append(rule);
|
||||||
|
|
||||||
// Key string rule
|
// Key string rule
|
||||||
QTextCharFormat keyFormat;
|
QTextCharFormat keyFormat;
|
||||||
keyFormat.setForeground(keyColor); // Assuming keyColor is defined
|
keyFormat.setForeground(keyColor); // Assuming keyColor is defined
|
||||||
|
Loading…
Reference in New Issue
Block a user