aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.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/PlainTextEditor.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/PlainTextEditor.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
index 8626b2b4..b1592cc3 100644
--- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
+++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
@@ -76,17 +76,22 @@ void PlainTextEditor::LoadFile(QString filepath){
bool diffFile = (filepath != this->whatsThis());
this->setWhatsThis(filepath);
this->clear();
- QList<SyntaxFile> files = SyntaxFile::availableFiles(settings);
+ /*QList<SyntaxFile> files = SyntaxFile::availableFiles(settings);
for(int i=0; i<files.length(); i++){
if(files[i].supportsFile(filepath) ){
files[i].SetupDocument(this);
SYNTAX->loadRules(files[i]);
break;
}
- }
+ }*/
//SYNTAX->loadRules( Custom_Syntax::ruleForFile(filepath.section("/",-1), settings) );
lastSaveContents = LUtils::readFile(filepath).join("\n");
if(diffFile){
+ SYNTAX->loadRules( Custom_Syntax::ruleForFile(this->whatsThis().section("/",-1), settings) );
+ if(SYNTAX->loadedRules().isEmpty()){
+ SYNTAX->loadRules( Custom_Syntax::ruleForFirstLine( lastSaveContents.section("\n",0,0,QString::SectionSkipEmpty) , settings) );
+ }
+ SYNTAX->setupDocument(this);
this->setPlainText( lastSaveContents );
}else{
//Try to keep the mouse cursor/scroll in the same position
@@ -123,14 +128,18 @@ bool PlainTextEditor::SaveFile(bool newname){
if(file.isEmpty()){ return false; } //cancelled
this->setWhatsThis(file);
SYNTAX->loadRules( Custom_Syntax::ruleForFile(this->whatsThis().section("/",-1), settings) );
+ if(SYNTAX->loadedRules().isEmpty()){
+ SYNTAX->loadRules( Custom_Syntax::ruleForFirstLine( this->toPlainText().section("\n",0,0,QString::SectionSkipEmpty) , settings) );
+ }
+ SYNTAX->setupDocument(this);
SYNTAX->rehighlight();
- readonly = !QFileInfo(this->whatsThis()).isWritable(); //update this flag
}
if( !watcher->files().isEmpty() ){ watcher->removePaths(watcher->files()); }
bool ok = LUtils::writeFile(this->whatsThis(), this->toPlainText().split("\n"), true);
hasChanges = !ok;
if(ok){ lastSaveContents = this->toPlainText(); emit FileLoaded(this->whatsThis()); }
watcher->addPath(currentFile());
+ readonly = !QFileInfo(this->whatsThis()).isWritable(); //update this flag
return true;
//qDebug() << " - Success:" << ok << hasChanges;
}
bgstack15