linux: Primary clipboard (#10534)
Implements copying from and pasting to the primary selection. Release Notes: - N/A
This commit is contained in:
parent
98db7fa61e
commit
b31df39ab0
13 changed files with 173 additions and 16 deletions
|
@ -502,6 +502,34 @@ impl EditorElement {
|
|||
cx.stop_propagation();
|
||||
}
|
||||
|
||||
fn mouse_middle_down(
|
||||
editor: &mut Editor,
|
||||
event: &MouseDownEvent,
|
||||
position_map: &PositionMap,
|
||||
text_hitbox: &Hitbox,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
if !text_hitbox.is_hovered(cx) || editor.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(item) = cx.read_from_primary() {
|
||||
let point_for_position =
|
||||
position_map.point_for_position(text_hitbox.bounds, event.position);
|
||||
let position = point_for_position.previous_valid;
|
||||
|
||||
editor.select(
|
||||
SelectPhase::Begin {
|
||||
position,
|
||||
add: false,
|
||||
click_count: 1,
|
||||
},
|
||||
cx,
|
||||
);
|
||||
editor.insert(item.text(), cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_up(
|
||||
editor: &mut Editor,
|
||||
event: &MouseUpEvent,
|
||||
|
@ -2903,6 +2931,9 @@ impl EditorElement {
|
|||
MouseButton::Right => editor.update(cx, |editor, cx| {
|
||||
Self::mouse_right_down(editor, event, &position_map, &text_hitbox, cx);
|
||||
}),
|
||||
MouseButton::Middle => editor.update(cx, |editor, cx| {
|
||||
Self::mouse_middle_down(editor, event, &position_map, &text_hitbox, cx);
|
||||
}),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue