コード例 #1
0
 def choose_lexer(filename):
     fs = FileSystem()
     filetype = fs.getFileType(filename)
     if filetype == 'py':
         TextEditor.lex = PythonLexer()
     elif filetype == 'java':
         TextEditor.lex = JavaLexer()
     elif filetype == 'cpp':
         TextEditor.lex = CppLexer()
     TextEditor.codeinput.lexer = TextEditor.lex
コード例 #2
0
 def choose_lexer(self):
     fs = FileSystem()
     if TextEditor.filepath != None:
         ext = fs.getFileType(TextEditor.filepath)
         if ext == 'py':
             TextEditor.lex = PythonLexer()
         elif ext == 'java':
             TextEditor.lex = JavaLexer()
         elif ext == 'cpp':
             TextEditor.lex = CppLexer()
     else:
         # No extension
         TextEditor.lex = PythonLexer()