fix(plan): show options on activation instead of flipping the view (#326)

PLAN acted like a ViewCube TOP click the moment it ran — already on Top
meant an immediate flip to Bottom, and the options never appeared. It
now prompts "[Current ucs / Ucs / World] <Current>:" right on
activation and only changes the view once an option runs: Current =
plan of the active UCS, World = world XY, Ucs = prompts for a named UCS
(case-insensitive lookup). The new plan_snap goes straight to the plan
view with no flip-to-opposite cube behaviour.

KeywordCommand gains with_default(): a bare Enter at the verb step
dispatches the default verb (PLAN's <Current>) instead of cancelling.

Closes #326

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Fable 5 committed 2026-07-22 16:53:32 +03:00
1 parent b998082c82
commit b32a9b4083
2 files changed
+100 -4

No files matched your search

+16
View File
@@ -332,9 +332,18 @@ pub struct KeywordCommand {
options: Vec<(&'static str, &'static str, Option<&'static str>)>,
/// Set once a value-taking verb is chosen: `(keyword, value prompt)`.
pending: Option<(&'static str, &'static str)>,
/// Keyword a bare Enter dispatches at the verb step (`<Default>` prompts,
/// e.g. PLAN's `<Current>`). `None` = Enter cancels, as before.
default: Option<&'static str>,
}
impl KeywordCommand {
/// Set the verb a bare Enter dispatches (shown as `<Default>` in prompts).
pub fn with_default(mut self, kw: &'static str) -> Self {
self.default = Some(kw);
self
}
pub fn new(
name: &'static str,
prompt: &'static str,
@@ -345,6 +354,7 @@ impl KeywordCommand {
prompt,
options,
pending: None,
default: None,
}
}
}
@@ -411,6 +421,12 @@ impl CadCommand for KeywordCommand {
}
fn on_enter(&mut self) -> CmdResult {
// Bare Enter at the verb step runs the default verb when one is set.
if self.pending.is_none() {
if let Some(kw) = self.default {
return CmdResult::Dispatch(format!("{} {kw}", self.name));
}
}
CmdResult::Cancel
}
}