feat(command): clickable option buttons in the command line (#304)

Commands now expose their step options as clickable buttons rendered
inline beside the command-line prompt, so options need not be typed.

Adds a CmdOption/options() API to CadCommand: each command returns the
options for its current step; the command line renders them as
uppercase buttons and a click feeds the keyword to the command exactly
as if typed (an empty keyword submits like Enter).

Construction commands become "central" — CIRCLE offers [3P/2P/TTR/TTT/
DIAMETER], ELLIPSE [ARC/AXIS], ARC [SCE/SCA/SEA/SER/CSA/3P], RECTANGLE
[ROTATION/CENTER], POLYGON [CIRCUMSCRIBED/EDGE] — each keyword hands off
to the existing dedicated variant command via CmdResult::Dispatch,
instead of the variants only being reachable as isolated commands.

Migrates the existing bracketed-option prompts (PLINE, PEDIT, SPLINE,
SCALE, FILLET, CHAMFER, HATCH, GRADIENT, SOLID, POINT, RAY, XLINE, TRIM,
EXTEND) to the same button API and strips the option text from the
prompt strings, keeping value/coordinate hints. PEDIT's Width option
now enters a value sub-step so the button acts on click.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-08 00:16:59 +03:00
1 parent efa4bdd5e1
commit 31ac5372d6
18 files changed
+457 -28

No files matched your search

+3
View File
@@ -1300,6 +1300,9 @@ pub enum Message {
/// User clicked an autocomplete suggestion — fill the input with
/// the chosen command name and dispatch it.
CommandSuggestionPick(String),
/// User clicked a command-line option button — feed its keyword to the
/// active command as if typed (empty keyword = Enter). (#304)
CommandOptionPick(String),
ToggleLayers,
LayerToggleVisible(usize),
LayerToggleLock(usize),
+20
View File
@@ -147,6 +147,13 @@ impl OpenCADStudio {
.as_ref()
.map(|c| c.prompt());
self.command_line.set_step_prompt(prompt);
// Mirror the step's clickable options so they render as buttons (#304).
let opts = self.tabs[self.active_tab]
.active_cmd
.as_ref()
.map(|c| c.options())
.unwrap_or_default();
self.command_line.set_step_options(opts);
// Persist UI preferences whenever a toggle changes them (issue #68).
self.persist_settings_if_changed();
// OTRACK acquires tracking points only while a command or grip drag is
@@ -829,6 +836,19 @@ impl OpenCADStudio {
self.dispatch_command(&cmd)
}
Message::CommandOptionPick(kw) => {
// Clicking an option button feeds its keyword to the active
// command through the same path as typed text; an empty keyword
// finishes the step like Enter. (#304)
self.command_line.input.clear();
self.command_line.close_history();
if kw.is_empty() {
return self.feed_command(crate::command::StepInput::Enter);
}
self.feed_active_cmd(&kw);
Task::none()
}
Message::CommandSubmit => self.on_command_submit(),
Message::CommandSpace => {