Skip to content

Support proper text selection and editing #7

@cbrewster

Description

@cbrewster

Right now text insertion does not take into account text selection. I am not entirely sure what I want the text editing API to look like yet, but here is my idea for a first cut:

There should be a API which allows for a "span" of text to be replaced with a new span of text. Something like:

fn apply_edit(&mut self, span: Span, edit: &str) -> Location;

A span is two (row, col) pairs where the first pair precedes the second pair (in terms of location in the text buffer). The span can be empty, but represents a location. This is represented by the start and end pairs having the same value. The edit is a new string which replaces the text in the span. The function would return a the location of the start of the edit so that the cursor location can be updated.

One thing I want to do with this editor is experiment with different text editing approaches. I really like vim's modal approach but I think there is some room to create a more streamlined modal editor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions