forked from 1b-agent/opencadstudio-upstream
feat(commandline): always-on keyboard capture + space submits like enter
Two behaviour changes that bring the command line in line with established CAD workflow: 1. **Always-on keyboard capture.** The input was blurred whenever no command was running, so typed letters went nowhere until the user clicked into the field. Replace the blur with a re-focus on every command lifecycle transition (cmd_result.rs) and on viewport / tab / ribbon clicks (update.rs), focus the input at startup, and add a global key subscription that catches any unhandled character key or backspace and routes it into the buffer via two new messages (CommandAppendChar / CommandBackspace) — so the command line keeps accumulating keystrokes even if focus parks somewhere not focusable. Removes the unused blur_cmd_input helper. 2. **Space submits.** Typing a space at the end of the input now submits the buffer the same way Enter does. Only exception: an active command that's currently collecting free-form prose (TEXT / MTEXT / DDEDIT body, ATTDEF prompt / default value, INSERT attribute value, ATTEDIT cell). Those advertise the new `CadCommand::wants_text_with_spaces()` flag so the Space character reaches the buffer as a literal. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
e55b280dda
commit
39150d617f
16 files changed
+136
-42
No files matched your search
@@ -241,6 +241,19 @@ pub trait CadCommand: Send {
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns `true` when the active text prompt expects free-form prose
|
||||
/// that can legitimately contain whitespace (the body of a TEXT /
|
||||
/// MTEXT / DDEDIT entity, an attribute default value, etc.). For
|
||||
/// these prompts the command-line input must let `Space` be typed as
|
||||
/// a literal character; for every other prompt `Space` submits the
|
||||
/// input the same way `Enter` does.
|
||||
///
|
||||
/// Default `false` — single-token prompts (option letters, numeric
|
||||
/// radius, block name) do not embed spaces.
|
||||
fn wants_text_with_spaces(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Called when the user submits text via the command line while `wants_text_input` is true.
|
||||
fn on_text_input(&mut self, _text: &str) -> Option<CmdResult> {
|
||||
None
|
||||
|
||||
Reference in new issue
Block a user