From a24232842c9dda80c35270efd29f218abc2cd3ec Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 3 Jul 2026 12:42:55 +0300 Subject: [PATCH] feat(commands): prompt for a system-variable value on the next line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typing a bare system-variable name (MIRRTEXT, FILLMODE, LTSCALE, …) now echoes the current value and prompts "Enter new value for :", capturing the next command-line entry as the new value — Enter keeps the current one, Escape cancels. The single-line "MIRRTEXT 1" form still works. Mirrors the awaiting_vports pattern: a pending_setvar field on the app, consumed at the top of on_command_submit. Co-Authored-By: Claude Opus 4.8 --- src/app/commands/styleprops.rs | 11 ++++++++++- src/app/mod.rs | 5 +++++ src/app/update/command.rs | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/app/commands/styleprops.rs b/src/app/commands/styleprops.rs index aca3ee836..952024d6c 100644 --- a/src/app/commands/styleprops.rs +++ b/src/app/commands/styleprops.rs @@ -1213,8 +1213,17 @@ impl OpenCADStudio { Ok((msg, changed)) => { if changed { self.tabs[i].dirty = true; + self.command_line.push_output(&msg); + } else { + // Queried with no value (`changed == false`): + // prompt for a new value on the next line instead + // of only echoing the current one. Enter keeps it. + let current = msg.split('=').nth(1).map(str::trim).unwrap_or(""); + self.command_line.push_output(&format!( + "Enter new value for {name} <{current}>:" + )); + self.pending_setvar = Some(name.clone()); } - self.command_line.push_output(&msg); } Err(e) => self.command_line.push_error(&e), } diff --git a/src/app/mod.rs b/src/app/mod.rs index 2f113558b..3ee2e9324 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -274,6 +274,10 @@ pub(super) struct OpenCADStudio { /// `true` after a bare `VPORTS` in model space — the next command-line /// entry is treated as the tiled-config option (SIngle/2H/2V/4). awaiting_vports: bool, + /// Set to the variable name after a bare system-variable query (e.g. a lone + /// `MIRRTEXT`) — the next command-line entry is its new value, empty keeps + /// the current one. + pending_setvar: Option, /// Cursor is hovering over the UCS icon body — drives the hover highlight. ucs_icon_hover: bool, /// UCS icon is selected (clicked): its grips are shown and draggable. @@ -1958,6 +1962,7 @@ impl OpenCADStudio { default_bg_color: None, default_paper_bg_color: None, awaiting_vports: false, + pending_setvar: None, ucs_icon_hover: false, ucs_icon_selected: false, ucs_grip_drag: None, diff --git a/src/app/update/command.rs b/src/app/update/command.rs index e9fdca428..174b9c564 100644 --- a/src/app/update/command.rs +++ b/src/app/update/command.rs @@ -178,6 +178,17 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task { }; return self.dispatch_command(&format!("VPORTS {cfg}")); } + // Interactive system-variable value: after a bare `MIRRTEXT` + // (etc.) the next entry is the new value; empty Enter keeps the + // current setting. + if let Some(name) = self.pending_setvar.take() { + let val = self.command_line.input.trim().to_string(); + self.command_line.input.clear(); + if val.is_empty() { + return Task::none(); + } + return self.dispatch_command(&format!("SETVAR {name} {val}")); + } // If the user navigated the autocomplete list with the // arrow keys, Enter dispatches the highlighted command // rather than the partial text actually in the buffer. @@ -414,6 +425,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task { if self.pane_move_from.take().is_some() { return Task::none(); } + // Esc cancels a pending system-variable value prompt. + if self.pending_setvar.take().is_some() { + self.command_line.push_info("*Cancel*"); + return Task::none(); + } // UCS icon: Esc ends any grip drag and clears the selection // (only when no command owns Escape). if self.tabs[self.active_tab].active_cmd.is_none()