--- a/QScintilla/Lexers/__init__.py Sun Apr 17 19:07:20 2011 +0200 +++ b/QScintilla/Lexers/__init__.py Sun Apr 17 19:57:43 2011 +0200 @@ -9,6 +9,8 @@ from PyQt4.QtGui import QApplication +from QScintilla.QsciScintillaCompat import QSCINTILLA_VERSION + import Preferences # The lexer registry @@ -102,6 +104,12 @@ "YAML": [QApplication.translate('Lexers', "YAML"), 'dummy.yml'], } + if QSCINTILLA_VERSION() >= 0x020501: + supportedLanguages.update({ + "Matlab": [QApplication.translate('Lexers', "Matlab"), 'dummy.m.matlab'], + "Octave": [QApplication.translate('Lexers', "Octave"), 'dummy.m.octave'], + }) + for name in LexerRegistry: supportedLanguages[name] = LexerRegistry[name][:2] @@ -210,6 +218,12 @@ elif language == "YAML": from .LexerYAML import LexerYAML return LexerYAML(parent) + elif language == "Matlab": + from .LexerMatlab import LexerMatlab + return LexerMatlab(parent) + elif language == "Octave": + from .LexerOctave import LexerOctave + return LexerOctave(parent) elif language in LexerRegistry: return LexerRegistry[language][2](parent) @@ -327,6 +341,14 @@ 'YAML Files (*.yaml *.yml)'), ] + if QSCINTILLA_VERSION() >= 0x020501: + openFileFiltersList.extend([ + QApplication.translate('Lexers', + 'Matlab Files (*.m *.m.matlab)'), + QApplication.translate('Lexers', + 'Octave Files (*.m *.m.matlab)'), + ]) + for name in LexerRegistry: openFileFiltersList.append(LexerRegistry[name][3]) @@ -456,6 +478,14 @@ 'YAML Files (*.yml)'), ] + if QSCINTILLA_VERSION() >= 0x020501: + saveFileFiltersList.extend([ + QApplication.translate('Lexers', + 'Matlab Files (*.m)'), + QApplication.translate('Lexers', + 'Octave Files (*.m.octave)'), + ]) + for name in LexerRegistry: saveFileFiltersList.append(LexerRegistry[name][4]) @@ -474,6 +504,11 @@ def getDefaultLexerAssociations(): + """ + Module function to get a dictionary with the default associations. + + @return dictionary with the default lexer associations + """ assocs = { '*.sh': "Bash", '*.bash': "Bash", @@ -596,6 +631,13 @@ '*.e5t': "XML", } + if QSCINTILLA_VERSION() >= 0x020501: + assocs.update({ + '*.m': "Matlab", + '*.m.matlab': "Matlab", + '*.m.octave': "Octave", + }) + for name in LexerRegistry: for pattern in LexerRegistry[name][5]: assocs[pattern] = name