Ejemplo n.º 1
0
def identifier_before_dot():
    if 'TM_CURRENT_WORD' not in os.environ:
        os.environ['TM_CURRENT_WORD'] = os.environ.get('TM_CURRENT_LINE')
    
    word = current_word(r"^[\.A-Za-z_0-9]*", direction='left')
    if word:
        return word[:-1]
    return ""
Ejemplo n.º 2
0
def identifier_before_dot():
    if 'TM_CURRENT_WORD' not in os.environ:
        os.environ['TM_CURRENT_WORD'] = os.environ.get('TM_CURRENT_LINE')

    word = current_word(r"^[\.A-Za-z_0-9]*", direction='left')
    if word:
        return word[:-1]
    return ""
Ejemplo n.º 3
0
def complete(choices, options={}):

    if '2' not in pytm.DIALOG:
        raise 'Dialog2 not found.'

    if 'initial_filter' not in options:
        characters = 'a-zA-Z0-9'
        if 'extra_chars' in options:
            characters += re.escape(options['extra_chars'])

        options['initial_filter'] = current_word(characters, "left")

    command = [pytm.DIALOG, "popup", "--returnChoice"]
    if "initial_filter" in options and options['initial_filter']:
        command.append("--alreadyTyped %s" %
                       sh_escape(options["initial_filter"]))
    if "static_prefix" in options and options['static_prefix']:
        command.append("--staticPrefix %s" %
                       sh_escape(options["static_prefix"]))
    if "extra_chars" in options and options['extra_chars']:
        command.append("--additionalWordCharacters %s" %
                       sh_escape(options['extra_chars']))
    if "case_insensitive" in options and options['case_insensitive']:
        command.append("--caseInsensitive")

    def formalize(choice):
        try:
            choice['display']
            return choice
        except (KeyError, IndexError, TypeError):
            return {'display': choice}

    choices = [formalize(choice) for choice in choices]

    plist = {'suggestions': choices}

    try:
        f = tempfile.NamedTemporaryFile()
        plistlib.writePlist(plist, f)
        f.seek(0)

        command = ' '.join(command).strip()

        process = subprocess.Popen(command,
                                   stdin=subprocess.PIPE,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT,
                                   shell=True)
        process.stdin.write(f.read())
        process.stdin.close()
        f.close()

    except Exception as e:
        pytm.textmate.exit_show_tool_tip('ERROR: %s' % e)
    finally:
        f.close()
Ejemplo n.º 4
0
def current_identifier():
    return current_word(r"[A-Za-z_0-9]*")
Ejemplo n.º 5
0
def current_identifier():
    return current_word(r"[A-Za-z_0-9]*")