forked from 1b-agent/opencadstudio-upstream
feat(plugins): expose document path to plugins via HostApi
OpenCADStudio/plugins#901 (comment) - Add HostApi::document_path(tab_id) returning Option<PathBuf>. - Add PluginRequest::DocumentPath and PluginResponse::DocumentPath for out-of-process plugins. - Implement the request in the IPC server and in both V3/V4 plugin-side HostApi proxies. - Implement HostSession::document_path by looking up the tab by id and returning its current_path.
This commit is contained in:
1 parent
3024869de0
commit
09ba67bfd1
6 files changed
+58
No files matched your search
@@ -35,6 +35,14 @@ impl<'a> HostSession<'a> {
|
||||
self.app.tabs[self.tab].id
|
||||
}
|
||||
|
||||
pub fn document_path(&self, tab_id: u64) -> Option<std::path::PathBuf> {
|
||||
self.app
|
||||
.tabs
|
||||
.iter()
|
||||
.find(|t| t.id == tab_id)
|
||||
.and_then(|t| t.current_path.clone())
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn document_view_v4(&mut self, tab_id: u64) -> Option<ocs_plugin_api::shm::DocumentViewInfo> {
|
||||
if tab_id != self.tab_id() {
|
||||
@@ -341,6 +349,9 @@ impl HostApi for HostSession<'_> {
|
||||
fn tab_id(&self) -> u64 {
|
||||
self.tab_id()
|
||||
}
|
||||
fn document_path(&self, tab_id: u64) -> Option<std::path::PathBuf> {
|
||||
self.document_path(tab_id)
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn document_view_v4(&mut self, tab_id: u64) -> Option<ocs_plugin_api::shm::DocumentViewInfo> {
|
||||
self.document_view_v4(tab_id)
|
||||
|
||||
Reference in new issue
Block a user