diff --git a/src/server/codec.rs b/src/server/codec.rs index bedcadb50..52e061949 100644 --- a/src/server/codec.rs +++ b/src/server/codec.rs @@ -230,6 +230,7 @@ pdu! { GetTabRenderChanges: 18, GetTabRenderChangesResponse: 19, SetClipboard: 20, + OpenURL: 21, } impl Pdu { @@ -301,6 +302,7 @@ impl Pdu { Some(*tab_id) } Pdu::SetClipboard(SetClipboard { tab_id, .. }) => Some(*tab_id), + Pdu::OpenURL(OpenURL { tab_id, .. }) => Some(*tab_id), _ => None, } } @@ -385,6 +387,12 @@ pub struct SetClipboard { pub clipboard: Option, } +#[derive(Deserialize, Serialize, PartialEq, Debug)] +pub struct OpenURL { + pub tab_id: TabId, + pub url: String, +} + #[derive(Deserialize, Serialize, PartialEq, Debug)] pub struct Resize { pub tab_id: TabId, diff --git a/src/server/listener.rs b/src/server/listener.rs index 0d6401a60..f5104f4d9 100644 --- a/src/server/listener.rs +++ b/src/server/listener.rs @@ -540,7 +540,15 @@ impl<'a> term::TerminalHost for BufferedTerminalHost<'a> { } fn click_link(&mut self, link: &Arc) { - error!("ignoring url open of {:?}", link.uri()); + self.sender + .send(DecodedPdu { + serial: 0, + pdu: Pdu::OpenURL(OpenURL { + tab_id: self.tab_id, + url: link.uri().to_string(), + }), + }) + .ok(); } fn get_clipboard(&mut self) -> Fallible> { @@ -799,6 +807,7 @@ impl ClientSession { | Pdu::ListTabsResponse { .. } | Pdu::SendMouseEventResponse { .. } | Pdu::SetClipboard { .. } + | Pdu::OpenURL { .. } | Pdu::SpawnResponse { .. } | Pdu::GetTabRenderChangesResponse { .. } | Pdu::UnitResponse { .. } diff --git a/src/server/tab.rs b/src/server/tab.rs index 78c7b4aca..7465e5c27 100644 --- a/src/server/tab.rs +++ b/src/server/tab.rs @@ -191,6 +191,16 @@ impl ClientTab { Pdu::SetClipboard(SetClipboard { clipboard, .. }) => { self.clipboard.set_contents(clipboard)?; } + Pdu::OpenURL(OpenURL { url, .. }) => { + // FIXME: ideally we'd have a provider that we can + // capture (like the clipboard) so that we can propagate + // the click back to the ultimate client, but for now + // we just do a single stage + match open::that(&url) { + Ok(_) => {} + Err(err) => error!("failed to open {}: {:?}", url, err), + } + } _ => bail!("unhandled unilateral pdu: {:?}", pdu), }; Ok(())