Esempio n. 1
0
def delete_text_movement(movement, graphics_state, local_state, global_state):
    """
    Delete a text in a given range. I.e 'dw' or 'd}'
    Performs this operation by:
        1. Getting current location
        2. Mutating page state with movement argument
        3. Getting location after page manipulation
        4. Mutating local line buffer to remove desired range

    TODO: This is not optimal,
    Calling COMMAND_MAP[movement](graphics_state, local_state, global_state)
    messes with graphics state unnecessarily
    """
    px, py, pt = local_state.get_page_state()
    COMMAND_MAP[movement](graphics_state, local_state, global_state)
    nx, ny, nt = local_state.get_page_state()

    text_logic.delete_text_range(px, py, pt, nx, ny, nt, local_state)
    render_page([], [], graphics_state, local_state, global_state)
Esempio n. 2
0
def delete_text_highlight(graphics_state, local_state, global_state):
    """
    Delete text under highlight.
    Cursor corresponds to a highlight over a single character
    i.e Calling delete_text_highlight without visual mode on corresponds to
    deleting a single character or x in vim
    TODO: In the visual mode case this adds the deleted text to the copy buffer
    This should be mirrored in the non visual mode case
    """
    if global_state.curr_state == 'Visual':
        px, py, pt = local_state.get_visual_anchors()
        nx, ny, nt = local_state.get_page_state()
        txt = text_logic.get_text_range(px, py, pt, nx, ny, nt, local_state)
        global_state.add_copy_buffer(txt)
        text_logic.delete_text_range(px, py, pt, nx, ny, nt, local_state)
        global_state.curr_state = 'Default'
    else:
        text_logic.delete_text_highlight(local_state)

    render_page([], [], graphics_state, local_state, global_state)