feat(plugin): AutoCAD-compatible PAUSE, ENTER keyword, and command streaming

This commit is contained in:
yztink committed 2026-09-20 21:03:12 -07:00
1 parent fd2062bdec
commit fbedb3736e
8 files changed
+250 -3

No files matched your search

+6
View File
@@ -568,6 +568,12 @@ pub trait HostApi {
let _ = config;
false
}
/// Run a command on the active document tab's command line (AutoLISP style).
fn execute_command(&mut self, cmd: &str) -> bool {
let _ = cmd;
false
}
}
/// Configuration properties for creating or modifying a layer.
+14
View File
@@ -444,6 +444,20 @@ impl HostApi for PluginHostApi {
}
}
}
fn execute_command(&mut self, cmd: &str) -> bool {
match self.client.request(PluginRequest::ExecuteCommand(cmd.to_string())) {
Ok(PluginResponse::Bool(b)) => b,
Ok(other) => {
eprintln!("[plugin] unexpected ExecuteCommand response: {other:?}");
false
}
Err(e) => {
eprintln!("[plugin] ExecuteCommand request failed: {e}");
false
}
}
}
}
/// Sentinel reader used when the shared-memory view could not be initialized.
@@ -142,6 +142,8 @@ pub enum PluginRequest {
AddLayer(crate::host::LayerConfig),
/// Modify specified properties of an existing layer in the active document.
ModifyLayer(crate::host::LayerConfig),
/// Run a command on the active document tab's command line (AutoLISP style).
ExecuteCommand(String),
}
/// Responses the host sends back for `PluginRequest`.
+1
View File
@@ -79,5 +79,6 @@ pub fn handle_plugin_request(
),
AddLayer(config) => PluginResponse::OptHandle(host.add_layer(config)),
ModifyLayer(config) => PluginResponse::Bool(host.modify_layer(config)),
ExecuteCommand(cmd) => PluginResponse::Bool(host.execute_command(&cmd)),
}
}
@@ -758,6 +758,20 @@ impl HostApi for V4PluginHostApi {
}
}
}
fn execute_command(&mut self, cmd: &str) -> bool {
match self.request(PluginRequest::ExecuteCommand(cmd.to_string())) {
Ok(PluginResponse::Bool(b)) => b,
Ok(other) => {
eprintln!("[plugin] unexpected ExecuteCommand response: {other:?}");
false
}
Err(e) => {
eprintln!("[plugin] ExecuteCommand failed: {e}");
false
}
}
}
}
#[cfg(test)]