Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/Syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,40 @@ void Syntax::loadSyntaxRules(const YAML::Node &config)
// Iterate through each rule in the category
for (const auto &rule : rules)
{
QString regex = QString::fromStdString(rule["regex"].as<std::string>());
QColor color(QString::fromStdString(rule["color"].as<std::string>()));

QString regex;
try
{
std::string regexStr = rule["regex"].as<std::string>(); //will throw exception if the key does not exist
regex = QString::fromStdString(regexStr);
}
catch(const YAML::Exception e)
{
qWarning() << " YAML exception when parsion the regex in syntax file" << e.what();
continue;
}

qDebug() << "regex: " << regex;

QColor color;
try
{
std::string colorStr = rule["color"].as<std::string>();
color = QColor(QString::fromStdString(colorStr));
}
catch(const YAML::Exception e)
{
qWarning() << " YAML exception when parsion the color in syntax file" << e.what();
continue;
}

//checks if the color is a valid color
if(!color.isValid())
{
qWarning() << "Invalid COlor : Skipping...";
continue;
}

// Create a QTextCharFormat for the rule
QTextCharFormat format;
format.setForeground(color);
Expand Down
Loading