def complete(self,event): c = self.c cpl = self.completer p = c.p w = self.w # A leoQTextEditWidget head, tail = self.get_current_line(w) m = self.get_attr_target_python(head) if m: obj = m.group(1) prefix = m.group(3) klasses = self.guess_class(c,p, obj) else: klasses = [] if klasses: hits = self.lookup_methods(klasses, prefix) else: s = self.get_word() hits = self.lookup(s) model = QtGui.QStringListModel(hits) cpl.setModel(model) cpl.setCompletionPrefix(prefix) cpl.complete()
def complete(self,event): c = self.c ; cpl = self.completer tc = self.body.textCursor() tc.select(tc.WordUnderCursor) prefix = tc.selectedText() # g.trace(prefix) hits = self.lookup(prefix) model = QtGui.QStringListModel(hits) cpl.setModel(model) cpl.setCompletionPrefix(prefix) cpl.complete()
def suggest(self, event=None, pattern=''): trace = True c, w = self.c, self.w p = c.p if not pattern: pattern, tail = self.get_current_line(w) m = self.get_attr_target_python(pattern) if m: obj = m.group(1) prefix = m.group(3) klasses = self.guess_class(c, p, obj) else: if trace: g.trace('no attr for %s' % (pattern)) prefix = pattern klasses = [] if klasses: if trace: g.trace('klasses: %s' % (klasses)) hits = self.lookup_methods(klasses, prefix) hits = [h for h in hits if h.startswith(prefix)] else: # s = self.get_word() if trace: g.trace('prefix: %s' % (prefix)) hits = self.lookup(prefix) if 0: cpl = self.completer model = QtGui.QStringListModel(hits) cpl.setModel(model) cpl.setCompletionPrefix(prefix) cpl.complete() else: print("%s Completions for %s:" % (len(hits), prefix)) for h in hits[:20]: print(h)