propagate url clicks back to client
This commit is contained in:
1 parent
1ee4c14474
commit
e12f413224
3 files changed
+28
-1
No files matched your search
@@ -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<String>,
|
||||
}
|
||||
|
||||
#[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,
|
||||
|
||||
+10
-1
@@ -540,7 +540,15 @@ impl<'a> term::TerminalHost for BufferedTerminalHost<'a> {
|
||||
}
|
||||
|
||||
fn click_link(&mut self, link: &Arc<term::cell::Hyperlink>) {
|
||||
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<Arc<Clipboard>> {
|
||||
@@ -799,6 +807,7 @@ impl<S: ReadAndWrite> ClientSession<S> {
|
||||
| Pdu::ListTabsResponse { .. }
|
||||
| Pdu::SendMouseEventResponse { .. }
|
||||
| Pdu::SetClipboard { .. }
|
||||
| Pdu::OpenURL { .. }
|
||||
| Pdu::SpawnResponse { .. }
|
||||
| Pdu::GetTabRenderChangesResponse { .. }
|
||||
| Pdu::UnitResponse { .. }
|
||||
|
||||
@@ -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(())
|
||||
|
||||
Reference in new issue
Block a user