66 Module function to get a dictionary of supported lexer languages. |
70 Module function to get a dictionary of supported lexer languages. |
67 |
71 |
68 @return dictionary of supported lexer languages. The keys are the |
72 @return dictionary of supported lexer languages. The keys are the |
69 internal language names. The items are lists of two entries. |
73 internal language names. The items are lists of two entries. |
70 The first is the display string for the language, the second |
74 The first is the display string for the language, the second |
71 is a dummy file name, which can be used to derive the lexer. |
75 is a dummy file name, which can be used to derive the lexer, and |
72 (string, string) |
76 the third is the name of an icon file. |
|
77 (string, string, string) |
73 """ |
78 """ |
74 supportedLanguages = { |
79 supportedLanguages = { |
75 "Bash": [QApplication.translate('Lexers', "Bash"), 'dummy.sh'], |
80 "Bash": [QApplication.translate('Lexers', "Bash"), 'dummy.sh', |
76 "Batch": [QApplication.translate('Lexers', "Batch"), 'dummy.bat'], |
81 "lexerBash.png"], |
77 "C++": [QApplication.translate('Lexers', "C/C++"), 'dummy.cpp'], |
82 "Batch": [QApplication.translate('Lexers', "Batch"), 'dummy.bat', |
78 "C#": [QApplication.translate('Lexers', "C#"), 'dummy.cs'], |
83 "lexerBatch.png"], |
79 "CMake": [QApplication.translate('Lexers', "CMake"), 'dummy.cmake'], |
84 "C++": [QApplication.translate('Lexers', "C/C++"), 'dummy.cpp', |
80 "CSS": [QApplication.translate('Lexers', "CSS"), 'dummy.css'], |
85 "lexerCPP.png"], |
81 "D": [QApplication.translate('Lexers', "D"), 'dummy.d'], |
86 "C#": [QApplication.translate('Lexers', "C#"), 'dummy.cs', |
82 "Diff": [QApplication.translate('Lexers', "Diff"), 'dummy.diff'], |
87 "lexerCsharp.png"], |
83 "Fortran": [QApplication.translate('Lexers', "Fortran"), 'dummy.f95'], |
88 "CMake": [QApplication.translate('Lexers', "CMake"), 'dummy.cmake', |
84 "Fortran77": [QApplication.translate('Lexers', "Fortran77"), 'dummy.f'], |
89 "lexerCMake.png"], |
85 "HTML": [QApplication.translate('Lexers', "HTML/PHP/XML"), 'dummy.html'], |
90 "CSS": [QApplication.translate('Lexers', "CSS"), 'dummy.css', |
86 "IDL": [QApplication.translate('Lexers', "IDL"), 'dummy.idl'], |
91 "lexerCSS.png"], |
87 "Java": [QApplication.translate('Lexers', "Java"), 'dummy.java'], |
92 "D": [QApplication.translate('Lexers', "D"), 'dummy.d', |
88 "JavaScript": [QApplication.translate('Lexers', "JavaScript"), 'dummy.js'], |
93 "lexerD.png"], |
89 "Lua": [QApplication.translate('Lexers', "Lua"), 'dummy.lua'], |
94 "Diff": [QApplication.translate('Lexers', "Diff"), 'dummy.diff', |
90 "Makefile": [QApplication.translate('Lexers', "Makefile"), 'dummy.mak'], |
95 "lexerDiff.png"], |
91 "Pascal": [QApplication.translate('Lexers', "Pascal"), 'dummy.pas'], |
96 "Fortran": [QApplication.translate('Lexers', "Fortran"), 'dummy.f95', |
92 "Perl": [QApplication.translate('Lexers', "Perl"), 'dummy.pl'], |
97 "lexerFortran.png"], |
93 "PostScript": [QApplication.translate('Lexers', "PostScript"), 'dummy.ps'], |
98 "Fortran77": [QApplication.translate('Lexers', "Fortran77"), 'dummy.f', |
94 "Povray": [QApplication.translate('Lexers', "Povray"), 'dummy.pov'], |
99 "lexerFortran.png"], |
95 "Properties": [QApplication.translate('Lexers', "Properties"), 'dummy.ini'], |
100 "HTML": [QApplication.translate('Lexers', "HTML/PHP/XML"), 'dummy.html', |
96 "Python2": [QApplication.translate('Lexers', "Python2"), 'dummy.py'], |
101 "lexerHTML.png"], |
97 "Python3": [QApplication.translate('Lexers', "Python3"), 'dummy.py'], |
102 "IDL": [QApplication.translate('Lexers', "IDL"), 'dummy.idl', |
98 "Ruby": [QApplication.translate('Lexers', "Ruby"), 'dummy.rb'], |
103 "lexerIDL.png"], |
99 "SQL": [QApplication.translate('Lexers', "SQL"), 'dummy.sql'], |
104 "Java": [QApplication.translate('Lexers', "Java"), 'dummy.java', |
100 "TCL": [QApplication.translate('Lexers', "TCL"), 'dummy.tcl'], |
105 "lexerJava.png"], |
101 "TeX": [QApplication.translate('Lexers', "TeX"), 'dummy.tex'], |
106 "JavaScript": [QApplication.translate('Lexers', "JavaScript"), 'dummy.js', |
102 "VHDL": [QApplication.translate('Lexers', "VHDL"), 'dummy.vhd'], |
107 "lexerJavaScript.png"], |
103 "XML": [QApplication.translate('Lexers', "XML"), 'dummy.xml'], |
108 "Lua": [QApplication.translate('Lexers', "Lua"), 'dummy.lua', |
104 "YAML": [QApplication.translate('Lexers', "YAML"), 'dummy.yml'], |
109 "lexerLua.png"], |
|
110 "Makefile": [QApplication.translate('Lexers', "Makefile"), 'dummy.mak', |
|
111 "lexerMakefile.png"], |
|
112 "Pascal": [QApplication.translate('Lexers', "Pascal"), 'dummy.pas', |
|
113 "lexerPascal.png"], |
|
114 "Perl": [QApplication.translate('Lexers', "Perl"), 'dummy.pl', |
|
115 "lexerPerl.png"], |
|
116 "PostScript": [QApplication.translate('Lexers', "PostScript"), 'dummy.ps', |
|
117 "lexerPostscript.png"], |
|
118 "Povray": [QApplication.translate('Lexers', "Povray"), 'dummy.pov', |
|
119 "lexerPOV.png"], |
|
120 "Properties": [QApplication.translate('Lexers', "Properties"), 'dummy.ini', |
|
121 "lexerProperties.png"], |
|
122 "Python2": [QApplication.translate('Lexers', "Python2"), 'dummy.py', |
|
123 "lexerPython.png"], |
|
124 "Python3": [QApplication.translate('Lexers', "Python3"), 'dummy.py', |
|
125 "lexerPython.png"], |
|
126 "Ruby": [QApplication.translate('Lexers', "Ruby"), 'dummy.rb', |
|
127 "lexerRuby.png"], |
|
128 "SQL": [QApplication.translate('Lexers', "SQL"), 'dummy.sql', |
|
129 "lexerSQL.png"], |
|
130 "TCL": [QApplication.translate('Lexers', "TCL"), 'dummy.tcl', |
|
131 "lexerTCL.png"], |
|
132 "TeX": [QApplication.translate('Lexers', "TeX"), 'dummy.tex', |
|
133 "lexerTeX.png"], |
|
134 "VHDL": [QApplication.translate('Lexers', "VHDL"), 'dummy.vhd', |
|
135 "lexerVHDL.png"], |
|
136 "XML": [QApplication.translate('Lexers', "XML"), 'dummy.xml', |
|
137 "lexerXML.png"], |
|
138 "YAML": [QApplication.translate('Lexers', "YAML"), 'dummy.yml', |
|
139 "lexerYAML.png"], |
105 } |
140 } |
106 |
141 |
107 if QSCINTILLA_VERSION() >= 0x020501: |
142 if QSCINTILLA_VERSION() >= 0x020501: |
108 supportedLanguages.update({ |
143 supportedLanguages.update({ |
109 "Matlab": [QApplication.translate('Lexers', "Matlab"), 'dummy.m.matlab'], |
144 "Matlab": [QApplication.translate('Lexers', "Matlab"), 'dummy.m.matlab', |
110 "Octave": [QApplication.translate('Lexers', "Octave"), 'dummy.m.octave'], |
145 "lexerMatlab.png"], |
|
146 "Octave": [QApplication.translate('Lexers', "Octave"), 'dummy.m.octave', |
|
147 "lexerOctave.png"], |
111 }) |
148 }) |
112 |
149 |
113 for name in LexerRegistry: |
150 for name in LexerRegistry: |
114 supportedLanguages[name] = LexerRegistry[name][:2] |
151 supportedLanguages[name] = LexerRegistry[name][:2] + [LexerRegistry[name][6]] |
115 |
152 |
116 supportedLanguages["Guessed"] = \ |
153 supportedLanguages["Guessed"] = \ |
117 [QApplication.translate('Lexers', "Pygments"), 'dummy.pygments'] |
154 [QApplication.translate('Lexers', "Pygments"), 'dummy.pygments', ""] |
118 |
155 |
119 return supportedLanguages |
156 return supportedLanguages |
|
157 |
|
158 |
|
159 def getLanguageIcon(language, pixmap): |
|
160 """ |
|
161 Module function to get an icon for a language. |
|
162 |
|
163 @param language language of the lexer (string) |
|
164 @param pixmap flag indicating to return a pixmap (boolean) |
|
165 @return icon for the language (QPixmap or QIcon) |
|
166 """ |
|
167 supportedLanguages = getSupportedLanguages() |
|
168 if language in supportedLanguages: |
|
169 iconFileName = supportedLanguages[language][2] |
|
170 else: |
|
171 iconFileName = "" |
|
172 if pixmap: |
|
173 return UI.PixmapCache.getPixmap(iconFileName) |
|
174 else: |
|
175 return UI.PixmapCache.getIcon(iconFileName) |
120 |
176 |
121 |
177 |
122 def getLexer(language, parent=None, pyname=""): |
178 def getLexer(language, parent=None, pyname=""): |
123 """ |
179 """ |
124 Module function to instantiate a lexer object for a given language. |
180 Module function to instantiate a lexer object for a given language. |