Fixed an issue where selecting a Pygments Python lexer disabled auto completion.

Wed, 05 Jan 2011 17:15:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 05 Jan 2011 17:15:09 +0100
changeset 812
240adf04a50e
parent 811
2ed99614dbf4
child 813
5a5c3352f4ae

Fixed an issue where selecting a Pygments Python lexer disabled auto completion.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric5.QScintilla.Editor.html file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Wed Jan 05 16:13:10 2011 +0100
+++ b/APIs/Python3/eric5.api	Wed Jan 05 17:15:09 2011 +0100
@@ -4896,7 +4896,7 @@
 eric5.QScintilla.Editor.Editor.getFlakesWarnings?4()
 eric5.QScintilla.Editor.Editor.getFolds?4()
 eric5.QScintilla.Editor.Editor.getHighlightPosition?4()
-eric5.QScintilla.Editor.Editor.getLanguage?4()
+eric5.QScintilla.Editor.Editor.getLanguage?4(normalized = True)
 eric5.QScintilla.Editor.Editor.getLexer?4()
 eric5.QScintilla.Editor.Editor.getMenu?4(menuName)
 eric5.QScintilla.Editor.Editor.getNoName?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric5.QScintilla.Editor.html	Wed Jan 05 16:13:10 2011 +0100
+++ b/Documentation/Source/eric5.QScintilla.Editor.html	Wed Jan 05 17:15:09 2011 +0100
@@ -2426,10 +2426,16 @@
 </dd>
 </dl><a NAME="Editor.getLanguage" ID="Editor.getLanguage"></a>
 <h4>Editor.getLanguage</h4>
-<b>getLanguage</b>(<i></i>)
+<b>getLanguage</b>(<i>normalized = True</i>)
 <p>
         Public method to retrieve the language of the editor.
 </p><dl>
+<dt><i>normalized=</i></dt>
+<dd>
+flag indicating to normalize some Pygments
+            lexer names (boolean)
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 language of the editor (string)
--- a/QScintilla/Editor.py	Wed Jan 05 16:13:10 2011 +0100
+++ b/QScintilla/Editor.py	Wed Jan 05 17:15:09 2011 +0100
@@ -1102,7 +1102,8 @@
         """
         if self.apiLanguage.startswith("Pygments|"):
             self.pygmentsSelAct.setText(
-                self.trUtf8("Alternatives ({0})").format(self.getLanguage()))
+                self.trUtf8("Alternatives ({0})").format(
+                    self.getLanguage(normalized = False)))
         else:
             self.pygmentsSelAct.setText(self.trUtf8("Alternatives"))
         self.showMenu.emit("Languages", self.languagesMenu,  self)
@@ -1116,7 +1117,7 @@
         from pygments.lexers import get_all_lexers
         lexerList = sorted([l[0] for l in get_all_lexers()])
         try:
-            lexerSel = lexerList.index(self.getLanguage())
+            lexerSel = lexerList.index(self.getLanguage(normalized = False))
         except ValueError:
             lexerSel = 0
         lexerName, ok = QInputDialog.getItem(
@@ -1424,14 +1425,23 @@
         """
         return self.lexer_
         
-    def getLanguage(self):
+    def getLanguage(self, normalized = True):
         """
         Public method to retrieve the language of the editor.
         
+        @keyparam normalized flag indicating to normalize some Pygments 
+            lexer names (boolean)
         @return language of the editor (string)
         """
         if self.apiLanguage == "Guessed" or self.apiLanguage.startswith("Pygments|"):
-            return self.lexer_.name()
+            lang = self.lexer_.name()
+            if normalized:
+                # adjust some Pygments lexer names
+                if lang == "Python":
+                    lang = "Python2"
+                elif lang == "Python 3":
+                    lang = "Python3"
+            return lang
         else:
             return self.apiLanguage
         

eric ide

mercurial