Merge pull request #733 from chrisglass/add-copy-url
Add "Copy link" to context menu
This commit is contained in:
commit
546ccfaa6b
4 changed files with 32 additions and 1 deletions
|
|
@ -119,6 +119,7 @@ clear-scrollback = Clear scrollback
|
||||||
|
|
||||||
## Open
|
## Open
|
||||||
open-link = Open Link
|
open-link = Open Link
|
||||||
|
copy-link = Copy Link
|
||||||
|
|
||||||
## View
|
## View
|
||||||
view = View
|
view = View
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ add-password = Ajouter un mot de passe
|
||||||
password-input = Mot de passe
|
password-input = Mot de passe
|
||||||
password-input-description = Description
|
password-input-description = Description
|
||||||
open-link = Ouvrir le lien
|
open-link = Ouvrir le lien
|
||||||
|
copy-link = Copier le lien
|
||||||
add-another-keybinding = Ajouter un autre raccourci clavier
|
add-another-keybinding = Ajouter un autre raccourci clavier
|
||||||
cancel = Annuler
|
cancel = Annuler
|
||||||
close-window = Fermer la fenêtre
|
close-window = Fermer la fenêtre
|
||||||
|
|
|
||||||
25
src/main.rs
25
src/main.rs
|
|
@ -233,6 +233,7 @@ pub enum Action {
|
||||||
ClearScrollback,
|
ClearScrollback,
|
||||||
ColorSchemes(ColorSchemeKind),
|
ColorSchemes(ColorSchemeKind),
|
||||||
Copy,
|
Copy,
|
||||||
|
CopyUrlByMenu,
|
||||||
CopyOrSigint,
|
CopyOrSigint,
|
||||||
CopyPrimary,
|
CopyPrimary,
|
||||||
Find,
|
Find,
|
||||||
|
|
@ -285,6 +286,7 @@ impl 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::CopyUrlByMenu => Message::CopyUrlByMenu,
|
||||||
Self::CopyOrSigint => Message::CopyOrSigint(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),
|
||||||
|
|
@ -357,6 +359,7 @@ pub enum Message {
|
||||||
Copy(Option<segmented_button::Entity>),
|
Copy(Option<segmented_button::Entity>),
|
||||||
CopyOrSigint(Option<segmented_button::Entity>),
|
CopyOrSigint(Option<segmented_button::Entity>),
|
||||||
CopyPrimary(Option<segmented_button::Entity>),
|
CopyPrimary(Option<segmented_button::Entity>),
|
||||||
|
CopyUrlByMenu,
|
||||||
DefaultBoldFontWeight(usize),
|
DefaultBoldFontWeight(usize),
|
||||||
DefaultDimFontWeight(usize),
|
DefaultDimFontWeight(usize),
|
||||||
DefaultFont(usize),
|
DefaultFont(usize),
|
||||||
|
|
@ -2409,6 +2412,23 @@ impl Application for App {
|
||||||
log::warn!("failed to open {:?}: {}", url, err);
|
log::warn!("failed to open {:?}: {}", url, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::CopyUrlByMenu => {
|
||||||
|
if let Some(tab_model) = self.pane_model.active() {
|
||||||
|
let entity = tab_model.active();
|
||||||
|
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||||
|
// Update context menu position
|
||||||
|
let terminal = terminal.lock().unwrap();
|
||||||
|
if let Some(url) =
|
||||||
|
terminal.context_menu.as_ref().and_then(|m| m.link.as_ref())
|
||||||
|
{
|
||||||
|
return Task::batch([
|
||||||
|
clipboard::write(url.to_owned()),
|
||||||
|
self.update_focus(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::LaunchUrlByMenu => {
|
Message::LaunchUrlByMenu => {
|
||||||
if let Some(tab_model) = self.pane_model.active() {
|
if let Some(tab_model) = self.pane_model.active() {
|
||||||
let entity = tab_model.active();
|
let entity = tab_model.active();
|
||||||
|
|
@ -2782,6 +2802,11 @@ impl Application for App {
|
||||||
context_menu.position = None;
|
context_menu.position = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Action::CopyUrlByMenu => {
|
||||||
|
if let Some(context_menu) = terminal.context_menu.as_mut() {
|
||||||
|
context_menu.position = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
terminal.context_menu = None;
|
terminal.context_menu = None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,11 @@ pub fn context_menu<'a>(
|
||||||
0,
|
0,
|
||||||
Element::from(menu_item(fl!("open-link"), Action::LaunchUrlByMenu)),
|
Element::from(menu_item(fl!("open-link"), Action::LaunchUrlByMenu)),
|
||||||
);
|
);
|
||||||
rows.insert(1, Element::from(divider::horizontal::light()));
|
rows.insert(
|
||||||
|
1,
|
||||||
|
Element::from(menu_item(fl!("copy-link"), Action::CopyUrlByMenu)),
|
||||||
|
);
|
||||||
|
rows.insert(2, Element::from(divider::horizontal::light()));
|
||||||
}
|
}
|
||||||
let content = Column::with_children(rows);
|
let content = Column::with_children(rows);
|
||||||
widget::container(content)
|
widget::container(content)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue