diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit')
12 files changed, 181 insertions, 50 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index 9e4ce499..bdb9d29c 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -29,15 +29,26 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ fontbox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + QWidget *spacer2 = new QWidget(this); + spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + label_readonly = new QAction(tr("Read-Only File"), this); + label_readonly->setEnabled(false); //not an actual button + label_readonly->setToolTip(""); + QFont fnt = this->font(); + fnt.setItalic(true); + fnt.setBold(true); + label_readonly->setFont(fnt); fontSizes = new QSpinBox(this); fontSizes->setRange(5, 72); - fontSizes->setValue(9); + fontSizes->setValue(this->font().pointSize()); fontSizes->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); //For some reason, the FontComboBox is always 2 pixels taller than the SpinBox - manually fix that here - fontbox->setFixedHeight(30); - fontSizes->setFixedHeight(32); + fontbox->setFixedHeight(ui->toolBar->iconSize().height()-2); + fontSizes->setFixedHeight(ui->toolBar->iconSize().height()); ui->toolBar->addWidget(spacer); + ui->toolBar->addAction(label_readonly); + ui->toolBar->addWidget(spacer2); ui->toolBar->addWidget(fontbox); ui->toolBar->addWidget(fontSizes); //Load the special Drag and Drop QTabWidget @@ -72,6 +83,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ for(int i=0; i<smodes.length(); i++){ ui->menuSyntax_Highlighting->addAction(smodes[i]); } + + bool toolbarVisible = settings->value("showToolbar",true).toBool(); + ui->toolBar->setHidden(!toolbarVisible); + ui->actionShow_Toolbar->setChecked(toolbarVisible); ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() ); ui->actionWrap_Lines->setChecked( settings->value("wrapLines",true).toBool() ); ui->actionShow_Popups->setChecked( settings->value("showPopupWarnings",true).toBool() ); @@ -96,6 +111,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(tabWidget->dndTabBar(), SIGNAL(DetachTab(int)), this, SLOT(tabDetached(int)) ); connect(tabWidget->dndTabBar(), SIGNAL(DroppedIn(QStringList)), this, SLOT(LoadArguments(QStringList)) ); connect(tabWidget->dndTabBar(), SIGNAL(DraggedOut(int, Qt::DropAction)), this, SLOT(tabDraggedOut(int, Qt::DropAction)) ); + connect(ui->actionShow_Toolbar, SIGNAL(toggled(bool)), this, SLOT(showToolbar(bool)) ); connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) ); connect(ui->actionWrap_Lines, SIGNAL(toggled(bool)), this, SLOT(wrapLines(bool)) ); connect(ui->actionShow_Popups, SIGNAL(toggled(bool)), this, SLOT(showPopupWarnings(bool)) ); @@ -184,6 +200,17 @@ QString MainUI::currentFileDir(){ return dir; } +QStringList MainUI::unsavedFiles(){ + QStringList unsaved; + for(int i=0; i<tabWidget->count(); i++){ + PlainTextEditor *tmp = static_cast<PlainTextEditor*>(tabWidget->widget(i)); + if(tmp->hasChange()){ + unsaved << tmp->currentFile(); + } + } + return unsaved; +} + // ================= // PRIVATE SLOTS //================= @@ -234,16 +261,27 @@ void MainUI::CloseFile(){ if(index>=0){ tabClosed(index); } } -void MainUI::SaveFile(){ +bool MainUI::SaveFile(){ PlainTextEditor *cur = currentEditor(); - if(cur==0){ return; } - cur->SaveFile(); + if(cur==0){ return true; } //nothing to do + return cur->SaveFile(); } -void MainUI::SaveFileAs(){ +bool MainUI::SaveFileAs(){ PlainTextEditor *cur = currentEditor(); - if(cur==0){ return; } - cur->SaveFile(true); + if(cur==0){ return true; } //nothing to do + return cur->SaveFile(true); +} + +bool MainUI::SaveAllFiles(){ + bool ok = true; + for(int i=0; i<tabWidget->count() && ok; i++){ + PlainTextEditor *tmp = static_cast<PlainTextEditor*>(tabWidget->widget(i)); + if(tmp->hasChange()){ + ok = ok && tmp->SaveFile(); + } + } + return ok; } void MainUI::Print() { @@ -337,6 +375,11 @@ void MainUI::showPopupWarnings(bool show){ settings->setValue("showPopupWarnings",show); } +void MainUI::showToolbar(bool show){ + settings->setValue("showToolbar",show); + ui->toolBar->setHidden(!show); +} + void MainUI::updateTab(QString file){ PlainTextEditor *cur = 0; int index = -1; @@ -356,6 +399,7 @@ void MainUI::updateTab(QString file){ tabWidget->setTabWhatsThis(index, file); //needed for drag/drop functionality ui->actionSave_File->setEnabled(changes); this->setWindowTitle( (changes ? "*" : "") + file.section("/",-2) ); + label_readonly->setVisible( cur->readOnlyFile() ); } void MainUI::tabChanged(){ @@ -373,6 +417,7 @@ void MainUI::tabChanged(){ fontbox->setCurrentFont(font); fontSizes->setValue( font.pointSize() ); ui->actionWrap_Lines->setChecked( cur->lineWrapMode()==QPlainTextEdit::WidgetWidth ); + label_readonly->setVisible( cur->readOnlyFile() ); } void MainUI::tabClosed(int tab){ @@ -489,21 +534,31 @@ PlainTextEditor *cur = currentEditor(); //============= void MainUI::closeEvent(QCloseEvent *ev){ //See if any of the open editors have unsaved changes first - QStringList unsaved; - for(int i=0; i<tabWidget->count(); i++){ - PlainTextEditor *tmp = static_cast<PlainTextEditor*>(tabWidget->widget(i)); - if(tmp->hasChange()){ - unsaved << tmp->currentFile(); - } + QStringList unsaved = unsavedFiles(); + if(unsaved.isEmpty() || !ui->actionShow_Popups->isChecked()){ + QMainWindow::closeEvent(ev); + return; + } + + //Otherwise, ask the user what to do. + QMessageBox::StandardButton but = QMessageBox::question( + this, + tr("Save Changes before closing?"), + QString(tr("There are unsaved changes.\nDo you want save them before you close the editor?\n\n%1")).arg(unsaved.join("\n")), + QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, + QMessageBox::No); + + if(but == QMessageBox::Cancel){ + ev->ignore(); + return; } - if(unsaved.isEmpty()){ QMainWindow::closeEvent(ev); return; } - bool savenow = false; - if(!savenow && !ui->actionShow_Popups->isChecked()){ savenow = true; } - if(!savenow){ - QMessageBox::StandardButton but = QMessageBox::question(this, tr("Save Changes before closing?"), QString(tr("There are unsaved changes.\nDo you want save them before you close the editor?\n\n%1")).arg(unsaved.join("\n")), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No); - savenow = (but == QMessageBox::Yes); - if(but == QMessageBox::Cancel){ ev->ignore(); return; } + else if(but == QMessageBox::Yes){ + if( !SaveAllFiles() ){ + //cancelled by user + ev->ignore(); + return; } - if(savenow){ SaveFile(); } - QMainWindow::closeEvent(ev); + + } + QMainWindow::closeEvent(ev); } diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.h b/src-qt5/desktop-utils/lumina-textedit/MainUI.h index 6e5d2d23..464e7a52 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.h +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.h @@ -13,6 +13,8 @@ #include <QShortcut> #include <QFontComboBox> #include <QSpinBox> +#include <QAction> +#include <QApplication> #include "PlainTextEditor.h" #include "ColorDialog.h" @@ -40,18 +42,21 @@ private: QSettings *settings; QShortcut *closeFindS; QSpinBox *fontSizes; + QAction *label_readonly; //Simplification functions PlainTextEditor* currentEditor(); QString currentFileDir(); + QStringList unsavedFiles(); private slots: //Main Actions void NewFile(); void OpenFile(QString file = ""); void CloseFile(); //current file only - void SaveFile(); - void SaveFileAs(); + bool SaveFile(); + bool SaveFileAs(); + bool SaveAllFiles(); void Print(); void fontChanged(const QFont &font); void updateStatusTip(); @@ -60,6 +65,7 @@ private slots: //Other Menu Actions void UpdateHighlighting(QAction *act = 0); + void showToolbar(bool); void showLineNumbers(bool); void wrapLines(bool); void ModifyColors(); diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui index fec94a21..f88f3976 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui @@ -182,7 +182,7 @@ <x>0</x> <y>0</y> <width>505</width> - <height>28</height> + <height>24</height> </rect> </property> <property name="contextMenuPolicy"> @@ -190,7 +190,7 @@ </property> <widget class="QMenu" name="menuFile"> <property name="title"> - <string>File</string> + <string>&File</string> </property> <addaction name="actionNew_File"/> <addaction name="actionOpen_File"/> @@ -204,7 +204,7 @@ </widget> <widget class="QMenu" name="menuView"> <property name="title"> - <string>View</string> + <string>&View</string> </property> <widget class="QMenu" name="menuSyntax_Highlighting"> <property name="title"> @@ -224,6 +224,7 @@ </widget> <addaction name="menuSyntax_Highlighting"/> <addaction name="menuTabs_Location"/> + <addaction name="actionShow_Toolbar"/> <addaction name="actionLine_Numbers"/> <addaction name="actionWrap_Lines"/> <addaction name="actionShow_Popups"/> @@ -232,7 +233,7 @@ </widget> <widget class="QMenu" name="menuEdit"> <property name="title"> - <string>Edit</string> + <string>&Edit</string> </property> <addaction name="actionFind"/> <addaction name="actionReplace"/> @@ -436,6 +437,17 @@ <string>Ctrl+P</string> </property> </action> + <action name="actionShow_Toolbar"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Toolbar</string> + </property> + </action> </widget> <tabstops> <tabstop>line_find</tabstop> diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp index 653bd0e8..b1592cc3 100644 --- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp @@ -24,7 +24,7 @@ PlainTextEditor::PlainTextEditor(QSettings *set, QWidget *parent) : QPlainTextEd LNW = new LNWidget(this); showLNW = true; watcher = new QFileSystemWatcher(this); - hasChanges = false; + hasChanges = readonly = false; lastSaveContents.clear(); matchleft = matchright = -1; this->setTabStopWidth( 8 * this->fontMetrics().width(" ") ); //8 character spaces per tab (UNIX standard) @@ -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 @@ -99,18 +104,34 @@ void PlainTextEditor::LoadFile(QString filepath){ this->centerCursor(); //scroll until cursor is centered (if possible) } hasChanges = false; - if(QFile::exists(filepath)){ watcher->addPath(filepath); } + readonly = false; + if(QFile::exists(filepath)){ + readonly = !QFileInfo(filepath).isWritable(); + watcher->addPath(filepath); + }else if(filepath.startsWith("/")){ + //See if the containing directory is writable instead + readonly = !QFileInfo(filepath.section("/",0,-2)).isWritable(); + } emit FileLoaded(this->whatsThis()); } -void PlainTextEditor::SaveFile(bool newname){ +bool PlainTextEditor::SaveFile(bool newname){ + //NOTE: This returns true for proper behaviour, and false for a user-cancelled process //qDebug() << "Save File:" << this->whatsThis(); + //Quick check for a non-editable file + if(!newname && this->whatsThis().startsWith("/")){ + if(!QFileInfo(this->whatsThis()).isWritable()){ newname = true; } //cannot save the current file name/location + } if( !this->whatsThis().startsWith("/") || newname ){ //prompt for a filename/path QString file = QFileDialog::getSaveFileName(this, tr("Save File"), this->whatsThis(), tr("Text File (*)")); - if(file.isEmpty()){ return; } + 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(); } if( !watcher->files().isEmpty() ){ watcher->removePaths(watcher->files()); } @@ -118,6 +139,8 @@ void PlainTextEditor::SaveFile(bool newname){ 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; } @@ -129,6 +152,11 @@ bool PlainTextEditor::hasChange(){ return hasChanges; } +bool PlainTextEditor::readOnlyFile(){ + //qDebug() << "Read Only File:" << readonly << this->whatsThis(); + return readonly; +} + //Functions for managing the line number widget int PlainTextEditor::LNWWidth(){ //Get the number of chars we need for line numbers diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.h b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.h index 0c83b7ce..b0a6cbc7 100644 --- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.h +++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.h @@ -21,7 +21,7 @@ class PlainTextEditor : public QPlainTextEdit{ public: PlainTextEditor(QSettings *set, QWidget *parent = 0); ~PlainTextEditor(); - + //Functions for setting up the editor void showLineNumbers(bool show = true); void LoadSyntaxRule(QString type); @@ -29,18 +29,19 @@ public: //File loading/setting options void LoadFile(QString filepath); - void SaveFile(bool newname = false); + bool SaveFile(bool newname = false); QString currentFile(); bool hasChange(); + bool readOnlyFile(); //Functions for managing the line number widget (internal - do not need to run directly) int LNWWidth(); //replacing the LNW size hint detection void paintLNW(QPaintEvent *ev); //forwarded from the LNW paint event - void updateLNW(); + void updateLNW(); QFontMetrics *metrics; - + private: QWidget *LNW; //Line Number Widget bool showLNW; @@ -55,8 +56,9 @@ private: void clearMatchData(); void highlightMatch(QChar ch, bool forward, int fromPos, QChar startch); - //Flags to keep track of changes - bool hasChanges; + //Flags to keep track of changes/status + bool hasChanges, readonly; + private slots: //Functions for managing the line number widget void LNW_updateWidth(); // Tied to the QPlainTextEdit::blockCountChanged() signal @@ -68,7 +70,7 @@ private slots: void textChanged(); void cursorMoved(); //Function for prompting the user if the file changed externally - void fileChanged(); + void fileChanged(); protected: void resizeEvent(QResizeEvent *ev); diff --git a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro index a9c16a0c..77cd8798 100644 --- a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro +++ b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro @@ -91,7 +91,7 @@ TRANSLATIONS = i18n/l-te_af.ts \ i18n/l-te_zu.ts dotrans.path=$${L_SHAREDIR}/lumina-desktop/i18n/ -dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$${L_SHAREDIR}/lumina-desktop/i18n/ +dotrans.extra=cd $$PWD/i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$${L_SHAREDIR}/lumina-desktop/i18n/ desktop.files=lumina-textedit.desktop desktop.path=$${L_SHAREDIR}/applications/ @@ -103,7 +103,7 @@ syntax.path=$${L_SHAREDIR}/lumina-desktop/syntax_rules syntax.files=syntax_rules/* manpage.path=$${L_MANDIR}/man1/ -manpage.extra="$${MAN_ZIP} lumina-textedit.1 > $(INSTALL_ROOT)$${L_MANDIR}/man1/lumina-textedit.1.gz" +manpage.extra="$${MAN_ZIP} $$PWD/lumina-textedit.1 > $(INSTALL_ROOT)$${L_MANDIR}/man1/lumina-textedit.1.gz" INSTALLS += target desktop link syntax manpage 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); 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); } } } 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 fa00b557..04190672 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md @@ -9,9 +9,11 @@ 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. If this syntax file is to be automatically applied to particular file type, then one of the following options must be set: + 2. If this syntax file is to be automatically applied to particular file type, then at least 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. + 3. "first_line_match" : *(only used if no filename rules matched)* Exact match for the first line of text in the file (Example: "#!/bin/sh") + 4. "first_line_regex" : *(only used if no filename rules matched)* Regular expression to use when find a match for the first line of text in the file 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. diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/json.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/json.syntax index ab67d384..1982e599 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/json.syntax +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/json.syntax @@ -8,7 +8,8 @@ { "meta": { "name": "JSON", - "file_suffix": ["json", "syntax"] + "file_suffix": ["json", "syntax"], + "first_line_match":["{"] }, "format": { "line_wrap": false, diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax index 6690d98c..2145beec 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax @@ -8,7 +8,8 @@ { "meta": { "name": "Python", - "file_suffix": ["py", "pyc"] + "file_suffix": ["py", "pyc"], + "first_line_regex" : "(#!).+(python)" }, "format": { "line_wrap": false, diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax index 5f38cadc..f2256731 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax @@ -8,7 +8,8 @@ { "meta": { "name": "Shell", - "file_suffix": ["sh"] + "file_suffix": ["sh"], + "first_line_match":["#!/bin/sh", "#!/sbin/openrc-run"] }, "format": { "line_wrap": false, |