aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2018-01-02 20:53:45 +0000
committerWeblate <noreply@weblate.org>2018-01-02 20:53:45 +0000
commit42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f (patch)
treea92f81f73b37b7de76cc5238f1ec393ae5a18ecd /src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
parentTranslated using Weblate (Dutch) (diff)
parentUpdated project files for plugin system (diff)
downloadlumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.tar.gz
lumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.tar.bz2
lumina-42e4f35c9a2ea2689b62ef8c5461b14a2b820e4f.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
index 53f51f4e..a80d4149 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
+++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
@@ -83,6 +83,16 @@ bool SyntaxFile::supportsFile(QString file){
return false;
}
+bool SyntaxFile::supportsFirstLine(QString line){
+ line = line.simplified();
+ if(metaObj.contains("first_line_match")){
+ return metaObj.value("first_line_match").toArray().contains(line);
+ }else if(metaObj.contains("first_line_regex")){
+ return (QRegExp( metaObj.value("first_line_regex").toString() ).indexIn(line) >=0 );
+ }
+ return false;
+}
+
bool SyntaxFile::LoadFile(QString file, QSettings *settings){
QStringList contents = LUtils::readFile(file);
//Now trim the extra non-JSON off the beginning of the file
@@ -209,6 +219,13 @@ QString Custom_Syntax::ruleForFile(QString filename, QSettings *settings){
return "";
}
+QString Custom_Syntax::ruleForFirstLine(QString line, QSettings *settings){
+ QList<SyntaxFile> files = SyntaxFile::availableFiles(settings);
+ for(int i=0; i<files.length(); i++){
+ if(files[i].supportsFirstLine(line)){ return files[i].name(); }
+ }
+ return "";
+}
void Custom_Syntax::loadRules(QString type){
QList<SyntaxFile> files = SyntaxFile::availableFiles(settings);
bgstack15