Skip to content

Commit

Permalink
Added selecting and dragging line selection
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Oct 11, 2024
1 parent c7eec0c commit c07671e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kaolinite/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ impl Document {
/// Select a line at a location
pub fn select_line_at(&mut self, y: usize) {
self.move_to(&Loc { x: 0, y });
self.select_to(&Loc { x: self.line(y).unwrap_or_default().chars().count(), y });
self.select_to(&Loc { x: 0, y: y + 1 });
}

/// Brings the cursor into the viewport so it can be seen
Expand Down
7 changes: 7 additions & 0 deletions src/editor/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ impl Editor {
}
MouseLocation::Tabs(_) | MouseLocation::Out => (),
},
MouseEventKind::Drag(MouseButton::Right) => match self.find_mouse_location(event) {
MouseLocation::File(mut loc) => {
loc.x = self.doc_mut().character_idx(&loc);
self.doc_mut().select_to_y(loc.y);
}
MouseLocation::Tabs(_) | MouseLocation::Out => (),
},
// Mouse scroll behaviour
MouseEventKind::ScrollDown | MouseEventKind::ScrollUp => {
if let MouseLocation::File(_) = self.find_mouse_location(event) {
Expand Down

0 comments on commit c07671e

Please sign in to comment.