QScintilla/Editor.py

changeset 1002
1151d1ea562a
parent 994
8ed60a191a3a
child 1063
a0afd409c566
equal deleted inserted replaced
1000:c9f094c33a1d 1002:1151d1ea562a
5522 """ 5522 """
5523 if cmd == QsciScintilla.SCI_TAB: 5523 if cmd == QsciScintilla.SCI_TAB:
5524 line, index = self.getCursorPosition() 5524 line, index = self.getCursorPosition()
5525 tmplName = self.getWordLeft(line, index) 5525 tmplName = self.getWordLeft(line, index)
5526 if tmplName: 5526 if tmplName:
5527 if e5App().getObject("TemplateViewer").hasTemplate(tmplName): 5527 if e5App().getObject("TemplateViewer").hasTemplate(
5528 tmplName, self.getLanguage()):
5528 self.__applyTemplate(tmplName) 5529 self.__applyTemplate(tmplName)
5529 return 5530 return
5530 else: 5531 else:
5531 templateNames = \ 5532 templateNames = \
5532 e5App().getObject("TemplateViewer").getTemplateNames(tmplName) 5533 e5App().getObject("TemplateViewer").getTemplateNames(
5534 tmplName, self.getLanguage())
5533 if len(templateNames) == 1: 5535 if len(templateNames) == 1:
5534 self.__applyTemplate(templateNames[0]) 5536 self.__applyTemplate(templateNames[0], self.getLanguage())
5535 return 5537 return
5536 elif len(templateNames) > 1: 5538 elif len(templateNames) > 1:
5537 self.showUserList(TemplateCompletionListID, 5539 self.showUserList(TemplateCompletionListID,
5538 ["{0}?{1:d}".format(t, self.TemplateImageID) \ 5540 ["{0}?{1:d}".format(t, self.TemplateImageID) \
5539 for t in templateNames]) 5541 for t in templateNames])
5547 5549
5548 @param id the ID of the user list (should be 1) (integer) 5550 @param id the ID of the user list (should be 1) (integer)
5549 @param txt the selected text (string) 5551 @param txt the selected text (string)
5550 """ 5552 """
5551 if id == TemplateCompletionListID: 5553 if id == TemplateCompletionListID:
5552 self.__applyTemplate(txt) 5554 self.__applyTemplate(txt, self.getLanguage())
5553 5555
5554 def __applyTemplate(self, templateName): 5556 def __applyTemplate(self, templateName, language):
5555 """ 5557 """
5556 Private method to apply a template by name. 5558 Private method to apply a template by name.
5557 5559
5558 @param templateName name of the template to apply (string) 5560 @param templateName name of the template to apply (string)
5559 """ 5561 @param language name of the language (group) to get the template
5560 if e5App().getObject("TemplateViewer").hasTemplate(templateName): 5562 from (string)
5563 """
5564 if e5App().getObject("TemplateViewer").hasTemplate(
5565 templateName, self.getLanguage()):
5561 self.extendSelectionWordLeft() 5566 self.extendSelectionWordLeft()
5562 e5App().getObject("TemplateViewer").applyNamedTemplate(templateName) 5567 e5App().getObject("TemplateViewer").applyNamedTemplate(
5568 templateName, self.getLanguage())
5563 5569
5564 ####################################################################### 5570 #######################################################################
5565 ## Project related methods 5571 ## Project related methods
5566 ####################################################################### 5572 #######################################################################
5567 5573

eric ide

mercurial