Implement #14
allow paste from PRIMARY by middle mouse button allow paste to command box paste from toolbar now paste CLIPBOARD
This commit is contained in:
parent
7065fbe2c7
commit
3714817604
29
src/shell.rs
29
src/shell.rs
@ -328,6 +328,20 @@ impl State {
|
|||||||
window.resize(request_width + h_border, request_height + v_border);
|
window.resize(request_width + h_border, request_height + v_border);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn edit_paste(&self, clipboard: &str) {
|
||||||
|
let nvim = self.nvim();
|
||||||
|
if let Some(mut nvim) = nvim {
|
||||||
|
let paste_code = if self.mode.is(&mode::NvimMode::Normal) {
|
||||||
|
format!("\"{}p", clipboard)
|
||||||
|
} else {
|
||||||
|
format!("<C-r>{}", clipboard)
|
||||||
|
};
|
||||||
|
|
||||||
|
nvim.input(&paste_code).report_err(&mut *nvim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UiState {
|
pub struct UiState {
|
||||||
@ -543,17 +557,7 @@ impl Shell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit_paste(&self) {
|
pub fn edit_paste(&self) {
|
||||||
let state = self.state.borrow();
|
self.state.borrow().edit_paste("+");
|
||||||
let paste_command = if state.mode.is(&mode::NvimMode::Normal) {
|
|
||||||
"\"*p"
|
|
||||||
} else {
|
|
||||||
"<Esc>\"*pa"
|
|
||||||
};
|
|
||||||
|
|
||||||
let nvim = state.nvim();
|
|
||||||
if let Some(mut nvim) = nvim {
|
|
||||||
nvim.input(paste_command).report_err(&mut *nvim);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit_save_all(&self) {
|
pub fn edit_save_all(&self) {
|
||||||
@ -633,6 +637,9 @@ fn gtk_button_press(shell: &mut State, ui_state: &mut UiState, ev: &EventButton)
|
|||||||
ui_state.mouse_pressed = true;
|
ui_state.mouse_pressed = true;
|
||||||
|
|
||||||
mouse_input(shell, "LeftMouse", ev.get_state(), ev.get_position());
|
mouse_input(shell, "LeftMouse", ev.get_state(), ev.get_position());
|
||||||
|
if ev.get_button() == 2 {
|
||||||
|
shell.edit_paste("*");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user