Пример #1
0
def delete_text_char(local_state):
    """
    Delete single character in line
    Have to watch out for deleteing a
    character at the beginning of a line
    """
    x, y, curr_top = local_state.get_page_state()
    curr_line = local_state.get_line(y + curr_top)

    if x > 0:
        local_state.set_line(curr_top + y, curr_line[:x - 1] + curr_line[x:])
        local_state.set_cursor(x - 1, y)
    elif y > 0 or curr_top > 0:
        if curr_line == '\n':
            local_state.remove_line(curr_top + y)
            local_state.set_cursor(0, y - 1)
            cursor_logic.move_cursor_end_line(local_state)
        else:
            prev_line = local_state.get_line(y + curr_top - 1)
            local_state.remove_line(curr_top + y)
            local_state.set_line(
                curr_top + y - 1,
                prev_line[:-1] + curr_line
            )  # slice off new line + last character
            local_state.set_cursor(len(prev_line) - 1, y - 1)
Пример #2
0
def move_end_line(graphics_state, local_state, global_state):
    """
    Functionality corresponding to $ in vim
    """
    cursor_logic.move_cursor_end_line(local_state)
    render_page([], [], graphics_state, local_state, global_state)