forked from 1b-agent/opencadstudio-upstream
Merge pull request #1425 from yztink:feat/plugin-run-command
This commit is contained in:
commit
0cbaf18551
12 files changed
+464
-21
No files matched your search
+11
-6
@@ -43,7 +43,12 @@ impl OpenCADStudio {
|
||||
}
|
||||
|
||||
pub(super) fn dispatch_command(&mut self, cmd: &str) -> Task<Message> {
|
||||
self.dispatch_command_inner(cmd, false)
|
||||
self.dispatch_command_inner(cmd, false, false)
|
||||
}
|
||||
|
||||
/// Dispatch a command skipping external plugin dispatch to prevent reentrant deadlocks.
|
||||
pub(super) fn dispatch_command_without_plugins(&mut self, cmd: &str) -> Task<Message> {
|
||||
self.dispatch_command_inner(cmd, false, true)
|
||||
}
|
||||
|
||||
/// Dispatch a verb typed at the interactive command line, falling back to
|
||||
@@ -55,10 +60,10 @@ impl OpenCADStudio {
|
||||
/// callers (ribbon, plugins, headless automation) use `dispatch_command`
|
||||
/// and never get silent substitution.
|
||||
pub(super) fn dispatch_command_or_suggest(&mut self, cmd: &str) -> Task<Message> {
|
||||
self.dispatch_command_inner(cmd, true)
|
||||
self.dispatch_command_inner(cmd, true, false)
|
||||
}
|
||||
|
||||
fn dispatch_command_inner(&mut self, cmd: &str, allow_suggest: bool) -> Task<Message> {
|
||||
fn dispatch_command_inner(&mut self, cmd: &str, allow_suggest: bool, skip_plugins: bool) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
// Expand a command alias ("L" → "LINE") on the leading token before any
|
||||
// routing, so every path below (Start-tab gate, plugins, all dispatch
|
||||
@@ -186,7 +191,7 @@ impl OpenCADStudio {
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
if crate::plugin::try_dispatch(self, i, cmd) {
|
||||
if !skip_plugins && crate::plugin::try_dispatch(self, i, cmd) {
|
||||
// try_dispatch returns true for both finished commands and interactive
|
||||
// commands that it just installed. If no command is now active, the
|
||||
// tool was a one-shot and we must turn the ribbon highlight off here —
|
||||
@@ -225,7 +230,7 @@ impl OpenCADStudio {
|
||||
.next()
|
||||
{
|
||||
if !top.eq_ignore_ascii_case(cmd) {
|
||||
return self.dispatch_command_inner(&top, false);
|
||||
return self.dispatch_command_inner(&top, false, skip_plugins);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +244,7 @@ impl OpenCADStudio {
|
||||
/// `Some(task)` for an arm it owns (early-returning or falling through to
|
||||
/// `finish_dispatch`), or `None` to defer to the next — equivalent to one
|
||||
/// sequential `match` over all arms.
|
||||
fn dispatch_families(&mut self, cmd: &str, i: usize) -> Option<Task<Message>> {
|
||||
pub(crate) fn dispatch_families(&mut self, cmd: &str, i: usize) -> Option<Task<Message>> {
|
||||
if let Some(t) = self.dispatch_fileops(cmd, i) {
|
||||
return Some(t);
|
||||
}
|
||||
|
||||
@@ -2739,8 +2739,19 @@ impl OpenCADStudio {
|
||||
.push_output(crate::tf!("CLAYER = \"{cur}\"").as_ref());
|
||||
} else {
|
||||
if self.tabs[i].scene.document.layers.contains(name_arg) {
|
||||
let handle = self.tabs[i]
|
||||
.scene
|
||||
.document
|
||||
.layers
|
||||
.get(name_arg)
|
||||
.map(|l| l.handle)
|
||||
.unwrap_or(acadrust::types::Handle::NULL);
|
||||
self.tabs[i].scene.document.header.current_layer_name =
|
||||
name_arg.to_string();
|
||||
self.tabs[i].scene.document.header.current_layer_handle = handle;
|
||||
self.tabs[i].active_layer = name_arg.to_string();
|
||||
self.tabs[i].layers.current_layer = name_arg.to_string();
|
||||
self.ribbon.active_layer = name_arg.to_string();
|
||||
self.tabs[i].dirty = true;
|
||||
self.command_line
|
||||
.push_output(crate::tf!("CLAYER set to \"{name_arg}\"").as_ref());
|
||||
|
||||
Reference in new issue
Block a user