Skip to content

Add support for multiple cursors #24

@lhecker

Description

@lhecker

We should add support for multiple cursors because they're widely used and useful. Default shortcuts should be:

  • Ctrl+Alt+Up/Down for duplicating the cursor above/below
  • Ctrl+D for finding the next occurrence of the current selection and adding a cursor there

This requires:

  • Extending the history entry:

    edit/src/buffer/mod.rs

    Lines 84 to 101 in b008570

    /// An undo/redo entry.
    struct HistoryEntry {
    /// [`TextBuffer::cursor`] position before the change was made.
    cursor_before: Point,
    /// [`TextBuffer::selection`] before the change was made.
    selection_before: Option<TextBufferSelection>,
    /// [`TextBuffer::stats`] before the change was made.
    stats_before: TextBufferStatistics,
    /// [`GapBuffer::generation`] before the change was made.
    generation_before: u32,
    /// Logical cursor position where the change took place.
    /// The position is at the start of the changed range.
    cursor: Point,
    /// Text that was deleted from the buffer.
    deleted: Vec<u8>,
    /// Text that was added to the buffer.
    added: Vec<u8>,
    }
  • Splitting the singular cursor into a main cursor and a secondary cursor list (which could also include the main cursor?):
    cursor: Cursor,
  • Centralizing / abstracting the various cursor movement functions within the same file
  • ...and making all cursors move when the main cursor moves
  • Updating write(), delete() and unindent() accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedWe encourage you to jump in on these!I-featureFeature requests and any other major tasks. Requires major work in the 1000s of LOC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions