Added copying
This commit is contained in:
parent
240f3d8754
commit
4e3c32c277
3 changed files with 15 additions and 2 deletions
|
@ -417,7 +417,8 @@
|
||||||
"up": "terminal::Up",
|
"up": "terminal::Up",
|
||||||
"down": "terminal::Down",
|
"down": "terminal::Down",
|
||||||
"tab": "terminal::Tab",
|
"tab": "terminal::Tab",
|
||||||
"cmd-v": "terminal::Paste"
|
"cmd-v": "terminal::Paste",
|
||||||
|
"cmd-c": "terminal::Copy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -52,7 +52,7 @@ pub struct ScrollTerminal(pub i32);
|
||||||
|
|
||||||
actions!(
|
actions!(
|
||||||
terminal,
|
terminal,
|
||||||
[Sigint, Escape, Del, Return, Left, Right, Up, Down, Tab, Clear, Paste, Deploy, Quit]
|
[Sigint, Escape, Del, Return, Left, Right, Up, Down, Tab, Clear, Copy, Paste, Deploy, Quit]
|
||||||
);
|
);
|
||||||
impl_internal_actions!(terminal, [Input, ScrollTerminal]);
|
impl_internal_actions!(terminal, [Input, ScrollTerminal]);
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(Terminal::up);
|
cx.add_action(Terminal::up);
|
||||||
cx.add_action(Terminal::down);
|
cx.add_action(Terminal::down);
|
||||||
cx.add_action(Terminal::tab);
|
cx.add_action(Terminal::tab);
|
||||||
|
cx.add_action(Terminal::copy);
|
||||||
cx.add_action(Terminal::paste);
|
cx.add_action(Terminal::paste);
|
||||||
cx.add_action(Terminal::scroll_terminal);
|
cx.add_action(Terminal::scroll_terminal);
|
||||||
}
|
}
|
||||||
|
@ -272,6 +273,16 @@ impl Terminal {
|
||||||
cx.emit(Event::CloseTerminal);
|
cx.emit(Event::CloseTerminal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Attempt to paste the clipboard into the terminal
|
||||||
|
fn copy(&mut self, _: &Copy, cx: &mut ViewContext<Self>) {
|
||||||
|
let term = self.term.lock();
|
||||||
|
let copy_text = term.selection_to_string();
|
||||||
|
match copy_text {
|
||||||
|
Some(s) => cx.write_to_clipboard(ClipboardItem::new(s)),
|
||||||
|
None => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///Attempt to paste the clipboard into the terminal
|
///Attempt to paste the clipboard into the terminal
|
||||||
fn paste(&mut self, _: &Paste, cx: &mut ViewContext<Self>) {
|
fn paste(&mut self, _: &Paste, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(item) = cx.read_from_clipboard() {
|
if let Some(item) = cx.read_from_clipboard() {
|
||||||
|
|
1
pbcpoy
Normal file
1
pbcpoy
Normal file
|
@ -0,0 +1 @@
|
||||||
|
A
|
Loading…
Add table
Add a link
Reference in a new issue