コード例 #1
0
    def on_query_completions(self, view, prefix, locations):
        p = get_unicode_prefix(view, locations[0])
        if not p:
            return

        log(p[0])

        (pre, list_chars) = get_list_prefix(p[0])
        # returns completions
        if pre is not None:

            def drop_prefix(pr, s):
                return s[len(pr):]

            pref = '\\\\' + pre + '\\' + ''.join(list_chars)
            completions = [(pref + drop_prefix(pre, k) + '\t' + maths[k],
                            '\\' + pref + drop_prefix(pre, k))
                           for k in maths.keys() if k.startswith(pre)]
            completions.extend([
                (pref + drop_prefix(pre, k) + '\t' + maths[synonyms[k]],
                 '\\' + pref + drop_prefix(pre, k)) for k in synonyms.keys()
                if k.startswith(pre)
            ])
        else:
            completions = [('\\' + k + '\t' + maths[k], maths[k])
                           for k in maths.keys() if k.startswith(p[0])]
            completions.extend([('\\' + k + '\t' + maths[synonyms[k]],
                                 maths[synonyms[k]]) for k in synonyms.keys()
                                if k.startswith(p[0])])
        return completions
コード例 #2
0
    def on_query_completions(self, view, prefix, locations):
        # is prefix starts with '\\'
        if not is_unicode_prefix(view, locations[0]):
            return

        # returns completions
        return [(k, k + " ") for k in filter(lambda s: s.startswith(prefix), maths.keys())]
コード例 #3
0
    def on_query_completions(self, view, prefix, locations):
        p = get_unicode_prefix(view, locations[0])
        if not p:
            return

        log(p[0])

        (pre, list_chars) = get_list_prefix(p[0])
        # returns completions
        if pre is not None:
            def drop_prefix(pr, s):
                return s[len(pr):]
            pref = '\\\\' + pre + '\\' + ''.join(list_chars)
            completions = [(pref + drop_prefix(pre, k) + '\t' + maths[k], '\\' + pref + drop_prefix(pre, k)) for k in maths.keys() if k.startswith(pre)]
            completions.extend([(pref + drop_prefix(pre, k) + '\t' + maths[synonyms[k]], '\\' + pref + drop_prefix(pre, k)) for k in synonyms.keys() if k.startswith(pre)])
        else:
            completions = [('\\' + k + '\t' + maths[k], maths[k]) for k in maths.keys() if k.startswith(p[0])]
            completions.extend([('\\' + k + '\t' + maths[synonyms[k]], maths[synonyms[k]]) for k in synonyms.keys() if k.startswith(p[0])])
        return completions