Add "Copy link" to context menu
This commit is contained in:
parent
a9c9d5684d
commit
a6522c4816
4 changed files with 32 additions and 1 deletions
|
|
@ -119,6 +119,7 @@ clear-scrollback = Clear scrollback
|
|||
|
||||
## Open
|
||||
open-link = Open Link
|
||||
copy-link = Copy Link
|
||||
|
||||
## View
|
||||
view = View
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ add-password = Ajouter un mot de passe
|
|||
password-input = Mot de passe
|
||||
password-input-description = Description
|
||||
open-link = Ouvrir le lien
|
||||
copy-link = Copier le lien
|
||||
add-another-keybinding = Ajouter un autre raccourci clavier
|
||||
cancel = Annuler
|
||||
close-window = Fermer la fenêtre
|
||||
|
|
|
|||
25
src/main.rs
25
src/main.rs
|
|
@ -233,6 +233,7 @@ pub enum Action {
|
|||
ClearScrollback,
|
||||
ColorSchemes(ColorSchemeKind),
|
||||
Copy,
|
||||
CopyUrlByMenu,
|
||||
CopyOrSigint,
|
||||
CopyPrimary,
|
||||
Find,
|
||||
|
|
@ -285,6 +286,7 @@ impl Action {
|
|||
Message::ToggleContextPage(ContextPage::ColorSchemes(*color_scheme_kind))
|
||||
}
|
||||
Self::Copy => Message::Copy(entity_opt),
|
||||
Self::CopyUrlByMenu => Message::CopyUrlByMenu,
|
||||
Self::CopyOrSigint => Message::CopyOrSigint(entity_opt),
|
||||
Self::CopyPrimary => Message::CopyPrimary(entity_opt),
|
||||
Self::Find => Message::Find(true),
|
||||
|
|
@ -357,6 +359,7 @@ pub enum Message {
|
|||
Copy(Option<segmented_button::Entity>),
|
||||
CopyOrSigint(Option<segmented_button::Entity>),
|
||||
CopyPrimary(Option<segmented_button::Entity>),
|
||||
CopyUrlByMenu,
|
||||
DefaultBoldFontWeight(usize),
|
||||
DefaultDimFontWeight(usize),
|
||||
DefaultFont(usize),
|
||||
|
|
@ -2409,6 +2412,23 @@ impl Application for App {
|
|||
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 => {
|
||||
if let Some(tab_model) = self.pane_model.active() {
|
||||
let entity = tab_model.active();
|
||||
|
|
@ -2782,6 +2802,11 @@ impl Application for App {
|
|||
context_menu.position = None;
|
||||
}
|
||||
}
|
||||
Action::CopyUrlByMenu => {
|
||||
if let Some(context_menu) = terminal.context_menu.as_mut() {
|
||||
context_menu.position = None;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
terminal.context_menu = None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,11 @@ pub fn context_menu<'a>(
|
|||
0,
|
||||
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);
|
||||
widget::container(content)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue