Skip to content

Commit

Permalink
Move UI Comm sender ownership to RMain (#583)
Browse files Browse the repository at this point in the history
* Move UI Comm ownership to `RMain`

* Lots of reworking

* Tweak message a little

* Add name to error message

* Use consistent naming everywhere
  • Loading branch information
DavisVaughan authored Oct 15, 2024
1 parent 564e419 commit 67ff702
Show file tree
Hide file tree
Showing 13 changed files with 336 additions and 324 deletions.
10 changes: 9 additions & 1 deletion crates/ark/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ unsafe fn ps_browse_url_impl(url: SEXP) -> anyhow::Result<SEXP> {
log::trace!("Help is not handling URL");
}

// TODO: What is the right thing to do outside of Positron when
// `options(browser =)` is called? Right now we error.

// For all other URLs, create a ShowUrl event and send it to the main
// thread; Positron will handle it.
let params = ShowUrlParams { url };
let event = UiFrontendEvent::ShowUrl(params);

RMain::with(|main| main.send_frontend_event(event));
let main = RMain::get();
let ui_comm_tx = main
.get_ui_comm_tx()
.ok_or_else(|| anyhow::anyhow!("UI comm not connected."))?;

ui_comm_tx.send_event(event);

Ok(Rf_ScalarLogical(1))
}
Loading

0 comments on commit 67ff702

Please sign in to comment.