forked from 1b-agent/opencadstudio-upstream
feat(commands): prompt for a system-variable value on the next line
Typing a bare system-variable name (MIRRTEXT, FILLMODE, LTSCALE, …) now echoes the current value and prompts "Enter new value for <NAME> <cur>:", 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 <[email protected]>
This commit is contained in:
1 parent
24f7329468
commit
a24232842c
3 files changed
+31
-1
No files matched your search
@@ -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),
|
||||
}
|
||||
|
||||
@@ -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<String>,
|
||||
/// 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,
|
||||
|
||||
@@ -178,6 +178,17 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
||||
};
|
||||
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<Message> {
|
||||
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()
|
||||
|
||||
Reference in new issue
Block a user