Ejemplo n.º 1
0
def can_convert(view):
    """
    Determines if there are any regions, where symbol can be converted
    Used not to call command when it will not convert anything, because such call
    modified edit, which lead to call of on_modified recursively
    Some times (is it sublime bug?) on_modified called twice on every change, which makes
    hard to detect whether this on_modified was called as result of previous call of command
    """
    for r in view.sel():
        if r.a == r.b:
            p = get_unicode_prefix(view, r.a)
            if p:
                rep = symbol_by_name(p[0])
                if rep:
                    return True
                (pre, list_chars) = get_list_prefix(p[0])
                if get_settings().get('convert_list',
                                      True) and pre is not None:
                    if all([symbol_by_name(pre + ch) for ch in list_chars]):
                        return True
                if get_settings().get('convert_sub_super', True) and is_script(
                        p[0]):
                    (script_char, chars) = get_script(p[0])
                    if all([symbol_by_name(script_char + ch) for ch in chars]):
                        return True
                if get_settings().get('convert_codes', True):
                    rep = symbol_by_code(p[0])
                    if rep:
                        return True
    return False
def can_convert(view):
    """
    Determines if there are any regions, where symbol can be converted
    Used not to call command when it will not convert anything, because such call
    modified edit, which lead to call of on_modified recursively
    Some times (is it sublime bug?) on_modified called twice on every change, which makes
    hard to detect whether this on_modified was called as result of previous call of command
    """
    for r in view.sel():
        if r.a == r.b:
            p = get_unicode_prefix(view, r.a)
            if p:
                rep = symbol_by_name(p[0])
                if rep:
                    return True
                (pre, list_chars) = get_list_prefix(p[0])
                if get_settings().get('convert_list', True) and pre is not None:
                    if all([symbol_by_name(pre + ch) for ch in list_chars]):
                        return True
                if get_settings().get('convert_sub_super', True) and is_script(p[0]):
                    (script_char, chars) = get_script(p[0])
                    if all([symbol_by_name(script_char + ch) for ch in chars]):
                        return True
                if get_settings().get('convert_codes', True):
                    rep = symbol_by_code(p[0])
                    if rep:
                        return True
    return False
def syntax_allowed(view):
    """
    Returns whether syntax in view is not in ignore list
    """
    syntax_in_view = SYNTAX_RE.match(view.settings().get('syntax'))
    if syntax_in_view and syntax_in_view.group('name').lower() in get_settings().get('ignore_syntax', []):
        return False
    return True
Ejemplo n.º 4
0
def syntax_allowed(view):
    """
    Returns whether syntax in view is not in ignore list
    """
    syntax_in_view = SYNTAX_RE.match(view.settings().get('syntax'))
    if syntax_in_view and syntax_in_view.group(
            'name').lower() in get_settings().get('ignore_syntax', []):
        return False
    return True