QScintilla/Editor.py

changeset 6247
5c677a7f7d51
parent 6210
f5b392aac28e
child 6273
0daf79d65080
child 6278
13fd8759f981
equal deleted inserted replaced
6246:fe07a9f16f23 6247:5c677a7f7d51
3397 cs = Qt.CaseSensitive 3397 cs = Qt.CaseSensitive
3398 else: 3398 else:
3399 cs = Qt.CaseInsensitive 3399 cs = Qt.CaseInsensitive
3400 wc = self.wordCharacters() 3400 wc = self.wordCharacters()
3401 if wc is None or not useWordChars: 3401 if wc is None or not useWordChars:
3402 regExp = QRegExp('[^\w_]', cs) 3402 regExp = QRegExp(r'[^\w_]', cs)
3403 else: 3403 else:
3404 wc = re.sub('\w', "", wc) 3404 wc = re.sub(r'\w', "", wc)
3405 regExp = QRegExp('[^\w{0}]'.format(re.escape(wc)), cs) 3405 regExp = QRegExp(r'[^\w{0}]'.format(re.escape(wc)), cs)
3406 start = regExp.lastIndexIn(text, index) + 1 3406 start = regExp.lastIndexIn(text, index) + 1
3407 end = regExp.indexIn(text, index) 3407 end = regExp.indexIn(text, index)
3408 if start == end + 1 and index > 0: 3408 if start == end + 1 and index > 0:
3409 # we are on a word boundary, try again 3409 # we are on a word boundary, try again
3410 start = regExp.lastIndexIn(text, index - 1) + 1 3410 start = regExp.lastIndexIn(text, index - 1) + 1
4689 4689
4690 ################################################################# 4690 #################################################################
4691 ## auto-completion hook interfaces 4691 ## auto-completion hook interfaces
4692 ################################################################# 4692 #################################################################
4693 4693
4694 def addCompletionListHook(self, key, func, async=False): 4694 def addCompletionListHook(self, key, func, asynchroneous=False):
4695 """ 4695 """
4696 Public method to set an auto-completion list provider. 4696 Public method to set an auto-completion list provider.
4697 4697
4698 @param key name of the provider 4698 @param key name of the provider
4699 @type str 4699 @type str
4702 a boolean indicating to complete a context. It should return 4702 a boolean indicating to complete a context. It should return
4703 the possible completions as a list of strings. 4703 the possible completions as a list of strings.
4704 @type function(editor, bool) -> list of str in case async is False 4704 @type function(editor, bool) -> list of str in case async is False
4705 and function(editor, bool, str) returning nothing in case async 4705 and function(editor, bool, str) returning nothing in case async
4706 is True 4706 is True
4707 @param async flag indicating an asynchroneous function 4707 @param asynchroneous flag indicating an asynchroneous function
4708 @type bool 4708 @type bool
4709 """ 4709 """
4710 if key in self.__completionListHookFunctions or \ 4710 if key in self.__completionListHookFunctions or \
4711 key in self.__completionListAsyncHookFunctions: 4711 key in self.__completionListAsyncHookFunctions:
4712 # it was already registered 4712 # it was already registered
4723 if self.autoCompletionThreshold() > 0: 4723 if self.autoCompletionThreshold() > 0:
4724 self.setAutoCompletionThreshold(0) 4724 self.setAutoCompletionThreshold(0)
4725 self.SCN_CHARADDED.connect(self.__charAdded) 4725 self.SCN_CHARADDED.connect(self.__charAdded)
4726 self.SCN_AUTOCCANCELLED.connect(self.__autocompletionCancelled) 4726 self.SCN_AUTOCCANCELLED.connect(self.__autocompletionCancelled)
4727 4727
4728 if async: 4728 if asynchroneous:
4729 self.__completionListAsyncHookFunctions[key] = func 4729 self.__completionListAsyncHookFunctions[key] = func
4730 else: 4730 else:
4731 self.__completionListHookFunctions[key] = func 4731 self.__completionListHookFunctions[key] = func
4732 4732
4733 def removeCompletionListHook(self, key): 4733 def removeCompletionListHook(self, key):

eric ide

mercurial