forked from 1b-agent/opencadstudio-upstream
feat(view): -VIEW command-line form with the standard view presets
-VIEW asks "Enter an option [?/Delete/Orthographic/Restore/Save/sEttings/ Window]:" and takes the orthographic and isometric presets (TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT, SWISO, SEISO, NEISO, NWISO, also with a leading underscore) directly, Orthographic asking for the face with <Top> as the default. Keyword prompts accept a leading underscore on their keywords. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff6e2a6613
commit
62ff1daade
3 files changed
+94
No files matched your search
@@ -642,6 +642,9 @@ pub struct KeywordCommand {
|
||||
/// 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>,
|
||||
/// Keywords taken at the verb step without being offered in the prompt
|
||||
/// (-VIEW's view presets).
|
||||
hidden: &'static [&'static str],
|
||||
}
|
||||
|
||||
impl KeywordCommand {
|
||||
@@ -651,6 +654,12 @@ impl KeywordCommand {
|
||||
self
|
||||
}
|
||||
|
||||
/// Keywords accepted at the verb step but not listed in the prompt.
|
||||
pub fn with_hidden(mut self, keywords: &'static [&'static str]) -> Self {
|
||||
self.hidden = keywords;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
name: &'static str,
|
||||
prompt: &'static str,
|
||||
@@ -662,6 +671,7 @@ impl KeywordCommand {
|
||||
options,
|
||||
pending: None,
|
||||
default: None,
|
||||
hidden: &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -734,6 +744,11 @@ impl CadCommand for KeywordCommand {
|
||||
// Consumed inputs that keep prompting return `Some(NeedPoint)` —
|
||||
// `None` would hand the same text to the command a second time.
|
||||
None => {
|
||||
// A leading underscore marks the English keyword, as in scripts.
|
||||
let t = t.strip_prefix('_').unwrap_or(t);
|
||||
if let Some(keyword) = self.hidden.iter().find(|keyword| keyword.eq_ignore_ascii_case(t)) {
|
||||
return Some(CmdResult::Dispatch(format!("{} {keyword}", self.name)));
|
||||
}
|
||||
let Some((_, keyword, value_prompt)) = match_cmd_option(&self.options, t) else {
|
||||
// Unknown verb — keep prompting rather than dispatch garbage.
|
||||
return Some(CmdResult::NeedPoint);
|
||||
|
||||
Reference in new issue
Block a user