aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-12-28 10:17:02 -0500
committerKen Moore <ken@ixsystems.com>2017-12-28 10:17:02 -0500
commit16e6402abdc43b64467682c370237eb60f031af0 (patch)
tree00f1e95f7a79040f92ee65d04c9de146350b8962 /src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
parentMerge remote-tracking branch 'origin/master' (diff)
downloadlumina-16e6402abdc43b64467682c370237eb60f031af0.tar.gz
lumina-16e6402abdc43b64467682c370237eb60f031af0.tar.bz2
lumina-16e6402abdc43b64467682c370237eb60f031af0.zip
Quick update to lumina-textedit:
1. Add a new syntax highlighting "meta" option for auto-selecting a ruleset based on the first line of text in the file, and add rules for shell, json, and python to support first-line matches. 2. Fix up the detection of "read-only" property on newly-saved files.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
index bffbfd1a..9949a90c 100644
--- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
+++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.h
@@ -46,6 +46,7 @@ public:
void SetupDocument(QPlainTextEdit *editor);
bool supportsFile(QString file); //does this syntax set support the file?
+ bool supportsFirstLine(QString line); //is the type of file defined by the first line of the file? ("#!/bin/<something>" for instance)
//Main Loading routine (run this before other functions)
bool LoadFile(QString file, QSettings *settings);
@@ -66,10 +67,13 @@ public:
}
~Custom_Syntax(){}
+ QString loadedRules(){ return syntax.name(); }
+
static QStringList availableRules(QSettings *settings);
static QStringList knownColors();
static void SetupDefaultColors(QSettings *settings);
static QString ruleForFile(QString filename, QSettings *settings);
+ static QString ruleForFirstLine(QString line, QSettings *settings);
void loadRules(QString type);
void loadRules(SyntaxFile sfile);
@@ -77,6 +81,8 @@ public:
loadRules( syntax.name() );
}
+ void setupDocument(QPlainTextEdit *edit){ syntax.SetupDocument(edit); } //simple redirect for the function in the currently-loaded rules
+
protected:
void highlightBlock(const QString &text){
//qDebug() << "Highlight Block:" << text;
@@ -159,7 +165,7 @@ protected:
int last = text.length()-1;
while(last>=0 && (text[last]==' ' || text[last]=='\t' ) ){ last--; }
if(last < text.length()-1){
- setFormat(last+1, text.length()-1-last, fmt);
+ setFormat(last+1, text.length()-1-last, fmt);
}
}
}
bgstack15