ui: Extracted syntax highlighting rules for java and cpp to files

* pass file language from storage to code view
* load syntax highlighting rules files from install directory "syntax_highlighting_rules"
* files must be named <language_identifier>.rules to make syntax highlighting work
This commit is contained in:
Eberhard Graether
2018-12-16 22:59:07 +01:00
parent a45dcb8a01
commit 1dabbab599
22 changed files with 586 additions and 180 deletions
+1 -8
View File
@@ -87,14 +87,7 @@ QtCodeField::QtCodeField(
createAnnotations(locationFile);
FilePath path = locationFile->getFilePath();
LanguageType language = LANGUAGE_UNKNOWN;
if (!path.empty())
{
language = (path.extension() == L".java" ? LANGUAGE_JAVA : LANGUAGE_CPP);
}
m_highlighter = std::make_shared<QtHighlighter>(document(), language);
m_highlighter = std::make_shared<QtHighlighter>(document(), locationFile->getLanguage());
m_highlighter->highlightDocument();
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
+2 -2
View File
@@ -19,8 +19,8 @@ QtCodeSnippet* QtCodeSnippet::merged(
SourceLocationFile* aFile = a->m_codeArea->getSourceLocationFile().get();
SourceLocationFile* bFile = b->m_codeArea->getSourceLocationFile().get();
std::shared_ptr<SourceLocationFile> locationFile =
std::make_shared<SourceLocationFile>(aFile->getFilePath(), aFile->isWhole(), aFile->isComplete(), aFile->isIndexed());
std::shared_ptr<SourceLocationFile> locationFile = std::make_shared<SourceLocationFile>(
aFile->getFilePath(), aFile->getLanguage(), aFile->isWhole(), aFile->isComplete(), aFile->isIndexed());
aFile->forEachSourceLocation(
[&locationFile](SourceLocation* loc)
+5
View File
@@ -102,6 +102,11 @@ void QtNewsWidget::updateNews()
size_t itemNum = 0;
for (QJsonValueRef value : doc.array())
{
if (!value.isObject())
{
continue;
}
itemNum++;
QJsonObject newsItem = value.toObject();