aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-11 05:17:35 -0400
committerKen Moore <ken@ixsystems.com>2017-06-11 05:17:35 -0400
commit123f0cb39e9670e9e89a2f62e2d5657c3e74aaa7 (patch)
treef59e5c1975ad6455e3bba569602002d23127ecd2 /src-qt5/desktop-utils/lumina-textedit
parentDarken up the emblem icons in the "-dark" theme a bit more, there still was n... (diff)
downloadlumina-123f0cb39e9670e9e89a2f62e2d5657c3e74aaa7.tar.gz
lumina-123f0cb39e9670e9e89a2f62e2d5657c3e74aaa7.tar.bz2
lumina-123f0cb39e9670e9e89a2f62e2d5657c3e74aaa7.zip
Add support for a new "file_regex" flag in the JSON syntax manifests that can be used when looking for matching file type support.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp6
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h8
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md4
3 files changed, 11 insertions, 7 deletions
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());
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
index fde68f84..d168b70f 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
+++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
@@ -46,7 +46,7 @@ public:
QString name();
int char_limit();
- bool highlight_excess_whitespace();
+ bool highlight_excess_whitespace();
int tab_length();
void SetupDocument(QPlainTextEdit *editor);
@@ -73,14 +73,14 @@ public:
settings = set;
}
~Custom_Syntax(){}
-
+
static QStringList availableRules(QSettings *settings);
static QStringList knownColors();
static void SetupDefaultColors(QSettings *settings);
static QString ruleForFile(QString filename, QSettings *settings);
void loadRules(QString type);
void loadRules(SyntaxFile sfile);
-
+
void reloadRules(){
loadRules( syntax.name() );
}
@@ -92,7 +92,7 @@ protected:
int start = 0;
int splitactive = previousBlockState();
if(splitactive>syntax.rules.length()-1){ splitactive = -1; } //just in case
-
+
while(start>=0 && start<=text.length()-1){
//qDebug() << "split check:" << start << splitactive;
if(splitactive>=0){
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md
index c2629e7c..fa00b557 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md
+++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md
@@ -9,7 +9,9 @@ A small comment section may be placed at the top of the file where every line st
# Requirements
1. A "meta" object containing the following variables (meta information about the rules):
1. "name" : The name that will be shown to the user for this set of syntax rules.
- 2. "file_suffix" : An array of suffixes for identifying which files this rule set supports.
+ 2. If this syntax file is to be automatically applied to particular file type, then one of the following options must be set:
+ 1. "file_suffix" : An array of file extensions which are supported by this syntax rule set (Example: temp.foo will be matched by "file_suffix"=["foo"] )
+ 2. "file_regex" : A regular expression which should be used to find if the filename matches this rule set.
2. A "format" object containing the following variables (file-wide formatting):
1. "columns_per_line" : (integer, optional) For file formats with line-length restrictions, this will automatically highlight/flag any "overage" of the designated limit.
2. "highlight_whitespace_eol" : (boolian, optional) Highlight any excess whitespace at the end of a line.
bgstack15