forked from 1b-agent/opencadstudio-upstream
cargo fmt
This commit is contained in:
1 parent
468cbde5e1
commit
ca07268c7c
204 files changed
+13997
-5525
No files matched your search
@@ -32,17 +32,23 @@ pub struct DdeditCommand {
|
||||
|
||||
impl DdeditCommand {
|
||||
pub fn new() -> Self {
|
||||
Self { step: DdeditStep::PickEntity }
|
||||
Self {
|
||||
step: DdeditStep::PickEntity,
|
||||
}
|
||||
}
|
||||
|
||||
/// Start with a pre-picked entity (for double-click use).
|
||||
pub fn with_handle(handle: Handle, current: String) -> Self {
|
||||
Self { step: DdeditStep::EnterText { handle, current } }
|
||||
Self {
|
||||
step: DdeditStep::EnterText { handle, current },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CadCommand for DdeditCommand {
|
||||
fn name(&self) -> &'static str { "DDEDIT" }
|
||||
fn name(&self) -> &'static str {
|
||||
"DDEDIT"
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
match &self.step {
|
||||
@@ -58,10 +64,15 @@ impl CadCommand for DdeditCommand {
|
||||
}
|
||||
|
||||
fn on_entity_pick(&mut self, handle: Handle, _pt: Vec3) -> CmdResult {
|
||||
if handle.is_null() { return CmdResult::NeedPoint; }
|
||||
if handle.is_null() {
|
||||
return CmdResult::NeedPoint;
|
||||
}
|
||||
// The current value will be filled in by the caller (commands.rs dispatch)
|
||||
// via on_text_input once the entity is known. Store handle here.
|
||||
self.step = DdeditStep::EnterText { handle, current: String::new() };
|
||||
self.step = DdeditStep::EnterText {
|
||||
handle,
|
||||
current: String::new(),
|
||||
};
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
|
||||
@@ -75,23 +86,32 @@ impl CadCommand for DdeditCommand {
|
||||
_ => return None,
|
||||
};
|
||||
// Empty input → keep existing text
|
||||
let new_text = if text.trim().is_empty() { current } else { text.to_string() };
|
||||
let new_text = if text.trim().is_empty() {
|
||||
current
|
||||
} else {
|
||||
text.to_string()
|
||||
};
|
||||
Some(CmdResult::DdeditEntity { handle, new_text })
|
||||
}
|
||||
|
||||
fn on_point(&mut self, _pt: Vec3) -> CmdResult { CmdResult::NeedPoint }
|
||||
fn on_enter(&mut self) -> CmdResult { CmdResult::Cancel }
|
||||
fn on_escape(&mut self) -> CmdResult { CmdResult::Cancel }
|
||||
fn on_point(&mut self, _pt: Vec3) -> CmdResult {
|
||||
CmdResult::NeedPoint
|
||||
}
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
fn on_escape(&mut self) -> CmdResult {
|
||||
CmdResult::Cancel
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract the text content from a Text or MText entity.
|
||||
pub fn entity_text(entity: &EntityType) -> Option<String> {
|
||||
match entity {
|
||||
EntityType::Text(t) => Some(t.value.clone()),
|
||||
EntityType::Text(t) => Some(t.value.clone()),
|
||||
EntityType::MText(t) => Some(t.value.clone()),
|
||||
EntityType::AttributeDefinition(a) => Some(a.default_value.clone()),
|
||||
EntityType::AttributeEntity(a) => Some(a.get_value().to_string()),
|
||||
EntityType::AttributeEntity(a) => Some(a.get_value().to_string()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user