Editor: added support for TOML files.

Sat, 03 Oct 2020 16:54:16 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 03 Oct 2020 16:54:16 +0200
changeset 7743
817a81a2e6aa
parent 7742
38ad1351688c
child 7744
19b701493dc6

Editor: added support for TOML files.

docs/changelog file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py file | annotate | diff | comparison | revisions
eric6/QScintilla/Lexers/__init__.py file | annotate | diff | comparison | revisions
--- a/docs/changelog	Sat Oct 03 16:52:11 2020 +0200
+++ b/docs/changelog	Sat Oct 03 16:54:16 2020 +0200
@@ -2,6 +2,8 @@
 ----------
 Version 20.11:
 - bug fixes
+- Editor
+  -- added support for TOML files
 
 Version 20.10:
 - bug fixes
--- a/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Sat Oct 03 16:52:11 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Sat Oct 03 16:54:16 2020 +0200
@@ -612,20 +612,23 @@
         @rtype list of int and tuple of (int, int)
         """
         itm = self.styleElementList.currentItem()
-        parent = itm.parent()
-        if parent is None:
-            currentData = (
-                None, self.styleElementList.indexOfTopLevelItem(itm))
+        if itm:
+            parent = itm.parent()
+            if parent is None:
+                currentData = (
+                    None, self.styleElementList.indexOfTopLevelItem(itm))
+            else:
+                currentData = (
+                    self.styleElementList.indexOfTopLevelItem(parent),
+                    parent.indexOfChild(itm)
+                )
+            
+            savedState = [
+                self.lexerLanguageComboBox.currentIndex(),
+                currentData,
+            ]
         else:
-            currentData = (
-                self.styleElementList.indexOfTopLevelItem(parent),
-                parent.indexOfChild(itm)
-            )
-        
-        savedState = [
-            self.lexerLanguageComboBox.currentIndex(),
-            currentData,
-        ]
+            savedState = []
         return savedState
     
     def setState(self, state):
@@ -634,17 +637,18 @@
         
         @param state state data generated by saveState
         """
-        self.lexerLanguageComboBox.setCurrentIndex(state[0])
-        self.on_lexerLanguageComboBox_activated(
-            self.lexerLanguageComboBox.currentText())
-        
-        parentIndex, index = state[1]
-        if parentIndex is None:
-            itm = self.styleElementList.topLevelItem(index)
-        else:
-            parent = self.styleElementList.topLevelItem(parentIndex)
-            itm = parent.child(index)
-        self.styleElementList.setCurrentItem(itm)
+        if state:
+            self.lexerLanguageComboBox.setCurrentIndex(state[0])
+            self.on_lexerLanguageComboBox_activated(
+                self.lexerLanguageComboBox.currentText())
+            
+            parentIndex, index = state[1]
+            if parentIndex is None:
+                itm = self.styleElementList.topLevelItem(index)
+            else:
+                parent = self.styleElementList.topLevelItem(parentIndex)
+                itm = parent.child(index)
+            self.styleElementList.setCurrentItem(itm)
     
     #######################################################################
     ## Methods to add, delete and edit sub-styles and their definitions
--- a/eric6/QScintilla/Lexers/__init__.py	Sat Oct 03 16:52:11 2020 +0200
+++ b/eric6/QScintilla/Lexers/__init__.py	Sat Oct 03 16:54:16 2020 +0200
@@ -501,6 +501,9 @@
             'YAML Files (*.yaml *.yml)'),
         QCoreApplication.translate(
             'Lexers',
+            'TOML Files (*.toml)'),
+        QCoreApplication.translate(
+            'Lexers',
             'Matlab Files (*.m *.m.matlab)'),
         QCoreApplication.translate(
             'Lexers',
@@ -709,6 +712,9 @@
             'YAML Files (*.yml)'),
         QCoreApplication.translate(
             'Lexers',
+            'TOML Files (*.toml)'),
+        QCoreApplication.translate(
+            'Lexers',
             'Matlab Files (*.m)'),
         QCoreApplication.translate(
             'Lexers',
@@ -883,6 +889,10 @@
         '*.proto': "Protocol",
         '*.po': "Gettext",
         '*.coffee': "CoffeeScript",
+        
+        '*.toml': "Pygments|TOML",
+        'Pipfile': "Pygments|TOML",
+        'poetry.lock': "Pygments|TOML",
     }
     
     if QSCINTILLA_VERSION() >= 0x020a00:

eric ide

mercurial