forked from 1b-agent/opencadstudio-upstream
refactor(commands): unified StepInput → feed_command step router (F0)
Introduce the single place every input source funnels through to drive the active command's step machine: a `StepInput` vocabulary (one variant per `CadCommand::on_*` method) and `OpenCADStudio::feed_command`, which routes the input to the matching `on_*` and applies the result. Sources keep their own classification (raw input → which StepInput); only the routing is centralized. Migrate the headless automation feeder onto it: feed_active_cmd builds a StepInput, the terminator sends StepInput::Enter. No behavior change — automation_ops_round_trip still passes. Also fixes headless inline-argument loss for plugin commands (#162): run_headless now offers the whole line to plugin dispatch first (plugins parse their own inline args, e.g. `HC_PIPE 2B 2C 1.25 0.013`), falling back to the first-word + fed-tokens path for built-in interactive tools. First phase of routing all input sources (command line, dynamic input, plugin API, viewport clicks) through one driver. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
69ea050124
commit
5fdd212592
3 files changed
+96
-25
No files matched your search
@@ -46,6 +46,39 @@ pub enum TangentObject {
|
||||
Circle { center: DVec3, radius: f64 },
|
||||
}
|
||||
|
||||
/// One unit of input to the active command's step machine.
|
||||
///
|
||||
/// Every input source — the GUI command line, the headless automation feeder,
|
||||
/// dynamic input, the plugin API, and the viewport (clicks / picks / selection
|
||||
/// / tangent) — translates its raw input into one of these and routes it
|
||||
/// through `OpenCADStudio::feed_command`, so a single place drives the command
|
||||
/// regardless of where the step came from.
|
||||
///
|
||||
/// Variants are wired up incrementally as each source is migrated onto
|
||||
/// `feed_command`; `#[allow(dead_code)]` covers those not yet constructed.
|
||||
#[allow(dead_code)]
|
||||
pub enum StepInput {
|
||||
/// A coordinate (`on_point`).
|
||||
Point(DVec3),
|
||||
/// A typed token: keyword, option letter, distance, or value
|
||||
/// (`on_text_input`).
|
||||
Text(String),
|
||||
/// An object pick (`on_entity_pick`).
|
||||
EntityPick(Handle, DVec3),
|
||||
/// A sub-structure pick — vertex / edge / face (`on_structure_pick`).
|
||||
StructurePick(Handle, DVec3),
|
||||
/// A completed selection set (`on_selection_complete`).
|
||||
SelectionComplete(Vec<Handle>),
|
||||
/// A tangent-snap target (`on_tangent_point`).
|
||||
Tangent(TangentObject, DVec3),
|
||||
/// The text / MText editor closed, with its commit flag (`on_editor_closed`).
|
||||
EditorClosed(bool),
|
||||
/// Advance / finish the current step — Enter, or Space-as-Enter (`on_enter`).
|
||||
Enter,
|
||||
/// Cancel the command (`on_escape`).
|
||||
Escape,
|
||||
}
|
||||
|
||||
// ── Result token ──────────────────────────────────────────────────────────
|
||||
|
||||
/// Returned by every `CadCommand` method to tell main.rs what to do.
|
||||
|
||||
Reference in new issue
Block a user