aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2018-01-02 22:00:13 +0000
committerWeblate <noreply@weblate.org>2018-01-02 22:00:13 +0000
commit76f036e835d89572b92006c7f6d4918b7c799664 (patch)
treea80a82bda02e0fc740ea607767ad2409c8aeaa8d /src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp
parentTranslated using Weblate (Portuguese (Brazil)) (diff)
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-76f036e835d89572b92006c7f6d4918b7c799664.tar.gz
lumina-76f036e835d89572b92006c7f6d4918b7c799664.tar.bz2
lumina-76f036e835d89572b92006c7f6d4918b7c799664.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