Example #1
0
def expand(string, start, end):
    expand_stack = []

    expand_stack.append("subword")

    result = expand_to_subword.expand_to_subword(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("word")

    result = expand_to_word.expand_to_word(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("quotes")

    result = expand_to_quotes.expand_to_quotes(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("xml_node")

    result = expand_to_xml_node.expand_to_xml_node(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result
def expand_against_surrounding_command(string, start, end):
    if chart_at(string, start) in ["{", "["] and\
            chart_at(string, end - 1) in ["}", "]"]:
        # span backwards over [..] and {..}
        while True:
            try:
                start = _stretch_over_previous_semantic_unit(string, start)
            except NoSemanticUnit:
                break
        # span forwards over [..]  and [..]
        while True:
            try:
                end = _stretch_over_next_semantic_unit(string, end)
            except NoSemanticUnit:
                break

        # span over the previous \command or \command*
        if chart_at(string, start - 1) == "*":
            start -= 1
        result = expand_to_word.expand_to_word(string, start, start)
        if result is None:
            return None
        start = result["start"] - 1
        if chart_at(string, start) == "\\":
            return utils.create_return_obj(start, end, string,
                                           "latex_command_surround")
Example #3
0
def expand(string, start, end):
    expand_stack = []

    expand_stack.append("subword")

    result = expand_to_subword.expand_to_subword(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("word")

    result = expand_to_word.expand_to_word(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("quotes")

    result = expand_to_quotes.expand_to_quotes(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("xml_node")

    result = expand_to_xml_node.expand_to_xml_node(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result
def expand_agains_line(string, start, end):
    expand_stack = []

    expand_stack.append("word")

    result = expand_to_word.expand_to_word(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("quotes")

    result = expand_to_quotes.expand_to_quotes(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("semantic_unit")

    result = expand_to_semantic_unit.expand_to_semantic_unit(
        string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("symbols")

    result = expand_to_symbols.expand_to_symbols(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result
Example #5
0
def expand(string, start, end):
  expand_stack = []

  expand_stack.append("word")

  result = expand_to_word.expand_to_word(string, start, end)
  if result:
    result["expand_stack"] = expand_stack
    return result

  expand_stack.append("quotes")

  result = expand_to_quotes.expand_to_quotes(string, start, end)
  if result:

    # Check if there is space in quotes
    space_in_quotes_result = expand_to_space_in_quotes.expand_to_space_in_quotes(result, string, start, end)
    if space_in_quotes_result:
      expand_stack.append("quotes_and_space")
      return space_in_quotes_result

    result["expand_stack"] = expand_stack
    return result

  expand_stack.append("xml_node")

  result = expand_to_xml_node.expand_to_xml_node(string, start, end)
  if result:
    result["expand_stack"] = expand_stack
    return result
def expand(string, start, end):
    expand_stack = []

    expand_stack.append("word")

    result = expand_to_word.expand_to_word(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("latex_command_base")

    result = expand_agains_base_command(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack = ["latex_command_arg"]

    result = expand_against_command_args(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("latex_command_surround")

    result = expand_against_surrounding_command(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("latex_environment_matching")

    result = expand_against_matching_env(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    env_result = expand_against_env(string, start, end)

    # there might be a {} inside the environment
    sym_result = expand_to_symbols.expand_to_symbols(string, start, end)
    result = _closest_result(env_result, sym_result)
    if result == env_result:
        expand_stack.append("latex_environment")
    else:
        expand_stack.append("symbols")

    if result:
        result["expand_stack"] = expand_stack
        return result
Example #7
0
def expand(string, start, end):
  expand_stack = []

  expand_stack.append("word")

  result = expand_to_word.expand_to_word(string, start, end)
  if result:
    result["expand_stack"] = expand_stack
    return result

  expand_stack.append("expand_to_css_selector")

  if utils.selection_contain_linebreaks(string, start, end) == False:
    result = expand_to_css_selector.expand_to_css_selector(string, start, end)

    if result:
      result["expand_stack"] = expand_stack
      return result
Example #8
0
def expand_agains_line(string, start, end):
    expand_stack = []

    expand_stack.append("subword")

    result = expand_to_subword.expand_to_subword(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("word")

    result = expand_to_word.expand_to_word(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("quotes")

    result = expand_to_quotes.expand_to_quotes(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("semantic_unit")

    result = expand_to_semantic_unit.expand_to_semantic_unit(
        string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result

    expand_stack.append("symbols")

    result = expand_to_symbols.expand_to_symbols(string, start, end)
    if result:
        result["expand_stack"] = expand_stack
        return result