From 123f0cb39e9670e9e89a2f62e2d5657c3e74aaa7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sun, 11 Jun 2017 05:17:35 -0400 Subject: Add support for a new "file_regex" flag in the JSON syntax manifests that can be used when looking for matching file type support. --- src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp') diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index 87592e6c..e5286e7b 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -77,10 +77,12 @@ void SyntaxFile::SetupDocument(QPlainTextEdit* editor){ bool SyntaxFile::supportsFile(QString file){ if(metaObj.contains("file_suffix")){ return metaObj.value("file_suffix").toArray().contains( file.section("/",-1).section(".",-1) ); + }else if(metaObj.contains("file_regex")){ + return (QRegExp( metaObj.value("file_regex").toString() ).indexIn(file.section("/",-1) ) >=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 @@ -108,7 +110,7 @@ bool SyntaxFile::LoadFile(QString file, QSettings *settings){ //First load the rule //qDebug() << "Load Rule:" << rule.keys(); if(rule.contains("words")){} //valid option - handled at the end though - else if(rule.contains("regex")){ + else if(rule.contains("regex")){ tmp.pattern = QRegExp(rule.value("regex").toString()); }else if(rule.contains("regex_start") && rule.contains("regex_end")){ tmp.startPattern = QRegExp(rule.value("regex_start").toString()); -- cgit