Add CopyOrSigint shortcut for Ctrl+C
This commit is contained in:
parent
ec58819a68
commit
b7b3e942fa
2 changed files with 24 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
|
||||||
// Standard key bindings
|
// Standard key bindings
|
||||||
bind!([Ctrl, Shift], Key::Character("A".into()), SelectAll);
|
bind!([Ctrl, Shift], Key::Character("A".into()), SelectAll);
|
||||||
bind!([Ctrl, Shift], Key::Character("C".into()), Copy);
|
bind!([Ctrl, Shift], Key::Character("C".into()), Copy);
|
||||||
|
bind!([Ctrl], Key::Character("c".into()), CopyOrSigint);
|
||||||
bind!([Ctrl, Shift], Key::Character("F".into()), Find);
|
bind!([Ctrl, Shift], Key::Character("F".into()), Find);
|
||||||
bind!([Ctrl, Shift], Key::Character("N".into()), WindowNew);
|
bind!([Ctrl, Shift], Key::Character("N".into()), WindowNew);
|
||||||
bind!([Ctrl, Shift], Key::Character("Q".into()), WindowClose);
|
bind!([Ctrl, Shift], Key::Character("Q".into()), WindowClose);
|
||||||
|
|
|
||||||
23
src/main.rs
23
src/main.rs
|
|
@ -168,6 +168,7 @@ pub enum Action {
|
||||||
About,
|
About,
|
||||||
ColorSchemes(ColorSchemeKind),
|
ColorSchemes(ColorSchemeKind),
|
||||||
Copy,
|
Copy,
|
||||||
|
CopyOrSigint,
|
||||||
CopyPrimary,
|
CopyPrimary,
|
||||||
Find,
|
Find,
|
||||||
PaneFocusDown,
|
PaneFocusDown,
|
||||||
|
|
@ -214,6 +215,7 @@ impl MenuAction for Action {
|
||||||
Message::ToggleContextPage(ContextPage::ColorSchemes(*color_scheme_kind))
|
Message::ToggleContextPage(ContextPage::ColorSchemes(*color_scheme_kind))
|
||||||
}
|
}
|
||||||
Self::Copy => Message::Copy(entity_opt),
|
Self::Copy => Message::Copy(entity_opt),
|
||||||
|
Self::CopyOrSigint => Message::CopyOrSigint(entity_opt),
|
||||||
Self::CopyPrimary => Message::CopyPrimary(entity_opt),
|
Self::CopyPrimary => Message::CopyPrimary(entity_opt),
|
||||||
Self::Find => Message::Find(true),
|
Self::Find => Message::Find(true),
|
||||||
Self::PaneFocusDown => Message::PaneFocusAdjacent(pane_grid::Direction::Down),
|
Self::PaneFocusDown => Message::PaneFocusAdjacent(pane_grid::Direction::Down),
|
||||||
|
|
@ -268,6 +270,7 @@ pub enum Message {
|
||||||
ColorSchemeTabActivate(widget::segmented_button::Entity),
|
ColorSchemeTabActivate(widget::segmented_button::Entity),
|
||||||
Config(Config),
|
Config(Config),
|
||||||
Copy(Option<segmented_button::Entity>),
|
Copy(Option<segmented_button::Entity>),
|
||||||
|
CopyOrSigint(Option<segmented_button::Entity>),
|
||||||
CopyPrimary(Option<segmented_button::Entity>),
|
CopyPrimary(Option<segmented_button::Entity>),
|
||||||
DefaultBoldFontWeight(usize),
|
DefaultBoldFontWeight(usize),
|
||||||
DefaultDimFontWeight(usize),
|
DefaultDimFontWeight(usize),
|
||||||
|
|
@ -1676,6 +1679,26 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
return self.update_focus();
|
return self.update_focus();
|
||||||
}
|
}
|
||||||
|
Message::CopyOrSigint(entity_opt) => {
|
||||||
|
if let Some(tab_model) = self.pane_model.active() {
|
||||||
|
let entity = entity_opt.unwrap_or_else(|| tab_model.active());
|
||||||
|
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||||
|
let terminal = terminal.lock().unwrap();
|
||||||
|
let term = terminal.term.lock();
|
||||||
|
if let Some(text) = term.selection_to_string() {
|
||||||
|
return Command::batch([clipboard::write(text), self.update_focus()]);
|
||||||
|
} else {
|
||||||
|
// Drop the lock for term so that input_scroll doesn't block forever
|
||||||
|
drop(term);
|
||||||
|
// 0x03 is ^C
|
||||||
|
terminal.input_scroll(&[0x03]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::warn!("Failed to get focused pane");
|
||||||
|
}
|
||||||
|
return self.update_focus();
|
||||||
|
}
|
||||||
Message::CopyPrimary(entity_opt) => {
|
Message::CopyPrimary(entity_opt) => {
|
||||||
if let Some(tab_model) = self.pane_model.active() {
|
if let Some(tab_model) = self.pane_model.active() {
|
||||||
let entity = entity_opt.unwrap_or_else(|| tab_model.active());
|
let entity = entity_opt.unwrap_or_else(|| tab_model.active());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue