Example #1
0
    def dispatch_custom_completer(self, text):
        # print "Custom! '%s' %s" % (text, self.custom_completers) # dbg
        line = self.full_lbuf
        if not line.strip():
            return None

        event = Struct()
        event.line = line
        event.symbol = text
        cmd = line.split(None, 1)[0]
        event.command = cmd
        #print "\ncustom:{%s]\n" % event # dbg

        # for foo etc, try also to find completer for %foo
        if not cmd.startswith(self.magic_escape):
            try_magic = self.custom_completers.s_matches(self.magic_escape +
                                                         cmd)
        else:
            try_magic = []

        for c in itertools.chain(
                self.custom_completers.s_matches(cmd), try_magic,
                self.custom_completers.flat_matches(self.lbuf)):
            # print "try",c # dbg
            try:
                res = c(event)
                return [r for r in res if r.lower().startswith(text.lower())]
            except ipapi.TryNext:
                pass

        return None
Example #2
0
    def dispatch_custom_completer(self,text):
        #print "Custom! '%s' %s" % (text, self.custom_completers) # dbg
        line = self.full_lbuf        
        if not line.strip():
            return None

        event = Struct()
        event.line = line
        event.symbol = text
        cmd = line.split(None,1)[0]
        event.command = cmd
        #print "\ncustom:{%s]\n" % event # dbg
        
        # for foo etc, try also to find completer for %foo
        if not cmd.startswith(self.magic_escape):
            try_magic = self.custom_completers.s_matches(
              self.magic_escape + cmd)            
        else:
            try_magic = []
        
        
        for c in itertools.chain(
                                 self.custom_completers.s_matches(cmd),
                                 try_magic,
                                 self.custom_completers.flat_matches(self.lbuf)):
            #print "try",c # dbg
            try:
                res = c(event)
                # first, try case sensitive match
                withcase = [r for r in res if r.startswith(text)]
                if withcase:
                    return withcase
                # if none, then case insensitive ones are ok too
                return [r for r in res if r.lower().startswith(text.lower())]
            except ipapi.TryNext:
                pass
            
        return None