forked from 1b-agent/opencadstudio-upstream
Merge pull request #1423 from felixriestra:pr/python-host-model
The bundled `opencad.python` plugin drives OCS through plugin API v7: all 43 canvas entity kinds, the drawing tables, and OCS's own commands run step by step. RustPython stays in the plugin process — the plugin crate is outside the workspace with its own lock file, so the application's own dependencies are unchanged. Reconciled with the plugin command work that landed as #1425, which the branch was written before: - Both added `impl Drop for PluginProcessInteractiveAdapter`, which git merges silently into two impls that do not compile. One body now cancels the command and then drops it from the runner, in that order: a plugin waiting on a step has to be released before the runner forgets the command. - `execute_command` (#1425) and `run_command` (#1423) are both routes from a script to the command line, and only the second was guarded. The SCRIPTCOMMANDS switch and the denylist are shared now, so neither route is the unguarded one. - `run_command` dispatched with plugin dispatch still enabled, so a script naming a plugin command re-entered the plugin that was blocked waiting for it. It sets the suppression flag for the length of the dispatch, as `execute_command` does. The denylist read the command as typed, while the dispatcher resolves aliases: a user-defined `Q` for `QUIT` (ALIASEDIT writes those) walked past it. It resolves the alias first. Also: the active-command comparison ran on every message, a mouse move included, allocating two strings for names that are already `&'static str`; SCRIPTCOMMANDS' own messages go through the translation macros; and `docs/.DS_Store` (now ignored) and an unrelated RTF note about constraint commands are out of the tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
41ecc0c458
72 files changed
+30614
-91
No files matched your search
@@ -485,6 +485,10 @@ pub struct UserSettings {
|
||||
/// Minutes between autosaves to a `.sv$` recovery file (SAVETIME command).
|
||||
/// 0 disables autosave.
|
||||
pub savetime_min: i32,
|
||||
/// SCRIPTCOMMANDS: whether a script (the Python plugin) may run OCS commands
|
||||
/// through the host. On by default; a user turns it off with the
|
||||
/// `SCRIPTCOMMANDS 0` command, and a script cannot change it.
|
||||
pub script_commands: bool,
|
||||
/// File type and version used when a new/unsaved drawing is first saved.
|
||||
/// Existing drawings keep their own type and version.
|
||||
pub default_save_format: String,
|
||||
@@ -685,6 +689,7 @@ impl Default for UserSettings {
|
||||
constraint_bar_display: 3,
|
||||
constraint_bar_mode: 4095,
|
||||
savetime_min: 10,
|
||||
script_commands: true,
|
||||
default_save_format: crate::io::DEFAULT_SAVE_FORMAT.to_string(),
|
||||
pick_add: true,
|
||||
pick_drag_rect: false,
|
||||
@@ -798,6 +803,19 @@ mod tests {
|
||||
assert_eq!(cfg.settings.savetime_min, 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_commands_default_on_and_survive_a_round_trip() {
|
||||
let missing: crate::app::config::AppConfig =
|
||||
serde_json::from_str(r#"{"settings": {"pick_add": false}}"#).unwrap();
|
||||
assert!(missing.settings.script_commands, "an old config keeps scripts allowed");
|
||||
let off: crate::app::config::AppConfig =
|
||||
serde_json::from_str(r#"{"settings": {"script_commands": false}}"#).unwrap();
|
||||
assert!(!off.settings.script_commands);
|
||||
let text = serde_json::to_string(&off).unwrap();
|
||||
let back: crate::app::config::AppConfig = serde_json::from_str(&text).unwrap();
|
||||
assert!(!back.settings.script_commands);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn isometric_drafting_never_persists_or_loads() {
|
||||
// A persisted On used to bring the isoplane crosshair (vertical +
|
||||
|
||||
Reference in new issue
Block a user