Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/test-common-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# FreeBSD cross-compile and real aarch64 test execution for cadcraft.
# Points at william-wwh/craft-common-actions@ci/freebsd-cross-final, the fork branch
# under evaluation. Dispatch-only: pushing to any branch never starts a run, so the
# default branch stays quiet while the per-binary timeout profile is collected.
name: FreeBSD Cross Validation

on:
workflow_dispatch:
inputs:
cold-start:
description: "Skip the Cargo cache restore so the build starts from an empty target/ (the fresh artifacts are still saved)"
type: boolean
default: true

permissions:
contents: read

jobs:
freebsd-cross:
uses: william-wwh/craft-common-actions/.github/workflows/freebsd-cross.yml@ci/freebsd-cross-final
with:
architectures: '["x86_64","aarch64"]'
cold-start: ${{ inputs.cold-start }}
require-craft-fonts: false
skip-tests: false
run-package-check: false
craft-fonts-ref: 3d9ab3a132ed0eff457e424226a435a901da30d3
51 changes: 34 additions & 17 deletions crates/engine/src/cmd/annotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,8 @@ impl Interactive for LinearM {
return Ok(Step::Continue);
}
if self.selecting {
if let Input::Point(p) = i {
if let Input::Point(pi) = i {
let p = pi.point();
let Some(h) = pick_at(s, p) else {
s.echo("*Invalid selection*");
return Ok(Step::Continue);
Expand Down Expand Up @@ -1048,11 +1049,13 @@ impl Interactive for LinearM {
self.selecting = true;
Ok(Step::Continue)
}
(n, Input::Point(p)) if n < 2 => {
(n, Input::Point(pi)) if n < 2 => {
let p = pi.point();
self.pts.push(p);
Ok(Step::Continue)
}
(_, Input::Point(at)) => {
(_, Input::Point(pi)) => {
let at = pi.point();
let (Some(&a), Some(&b)) = (self.pts.first(), self.pts.get(1)) else { return Ok(Step::Continue) };
let k = self.text.apply(dim(s, linear_kind(a, b, at, self.rotation, self.aligned), at, a, b, Vec2::ZERO, Vec2::ZERO, ""));
add_dim(s, k)?;
Expand Down Expand Up @@ -1126,14 +1129,16 @@ impl Interactive for RadialM {
return Ok(Step::Continue);
}
match (self.target, i) {
(None, Input::Point(p)) => {
(None, Input::Point(pi)) => {
let p = pi.point();
match pick_at(s, p).and_then(|h| circle_of(s, h)) {
Some(t) => self.target = Some(t),
None => s.echo("Object selected is not a circle or arc."),
}
Ok(Step::Continue)
}
(Some((c, r)), Input::Point(at)) => {
(Some((c, r)), Input::Point(pi)) => {
let at = pi.point();
let k = self.kind(s, c, r, at);
add_dim(s, k)?;
Ok(Step::Done)
Expand Down Expand Up @@ -1221,15 +1226,17 @@ impl Interactive for AngularM {
return Ok(Step::Continue);
}
if self.asking_quadrant {
if let Input::Point(q) = i {
if let Input::Point(pi) = i {
let q = pi.point();
self.quadrant = Some(q);
}
self.asking_quadrant = false;
return Ok(Step::Continue);
}
if let Some((v, a, b)) = self.geometry() {
return match i {
Input::Point(at) => {
Input::Point(pi) => {
let at = pi.point();
let at = self.located(v, at);
let k = match (self.handles.as_slice(), self.arc) {
([h1, h2], None) => angular_from_lines(s, *h1, *h2, at),
Expand All @@ -1253,7 +1260,10 @@ impl Interactive for AngularM {
}
if self.vertex {
match i {
Input::Point(p) => self.vertex_mode.push(p),
Input::Point(pi) => {
let p = pi.point();
self.vertex_mode.push(p)
}
Input::Enter => return Ok(Step::Cancel),
_ => {}
}
Expand All @@ -1264,7 +1274,8 @@ impl Interactive for AngularM {
self.vertex = true;
Ok(Step::Continue)
}
Input::Point(p) => {
Input::Point(pi) => {
let p = pi.point();
let Some(h) = pick_at(s, p) else {
s.echo("*Invalid selection*");
return Ok(Step::Continue);
Expand Down Expand Up @@ -1359,8 +1370,8 @@ impl Interactive for ArcLenM {
}
if let Some(picked) = self.partial.take() {
match (i, picked.first().copied(), self.arc) {
(Input::Point(p), None, _) => self.partial = Some(vec![p]),
(Input::Point(q), Some(p), Some(g)) => match arc_part(&g, p, q) {
(Input::Point(pi), None, _) => self.partial = Some(vec![pi.point()]),
(Input::Point(pi), Some(p), Some(g)) => match arc_part(&g, p, pi.point()) {
Some(part) => self.arc = Some(part),
None => s.echo("The two points must be different."),
},
Expand All @@ -1370,15 +1381,17 @@ impl Interactive for ArcLenM {
return Ok(Step::Continue);
}
match (self.arc, i) {
(None, Input::Point(p)) => {
(None, Input::Point(pi)) => {
let p = pi.point();
if let Some(EntityKind::Arc(a)) = pick_at(s, p).and_then(|h| s.doc().ok()?.entity(h).map(|e| e.kind.clone())) {
self.arc = Some(cadcraft_geom::Arc::new(a.center.xy(), a.radius, a.start, a.end));
} else {
s.echo("Select an arc.");
}
Ok(Step::Continue)
}
(Some(g), Input::Point(at)) => {
(Some(g), Input::Point(pi)) => {
let at = pi.point();
add_dim(s, self.text.apply(dim(s, DimKind::ArcLength, at, g.start_point(), g.end_point(), g.center, Vec2::ZERO, "")))?;
Ok(Step::Done)
}
Expand Down Expand Up @@ -1438,7 +1451,8 @@ impl Interactive for OrdinateM {
return Ok(Step::Continue);
}
match (self.feature, i) {
(None, Input::Point(p)) => {
(None, Input::Point(pi)) => {
let p = pi.point();
self.feature = Some(p);
Ok(Step::Continue)
}
Expand All @@ -1452,7 +1466,8 @@ impl Interactive for OrdinateM {
}
Ok(Step::Continue)
}
(Some(f), Input::Point(l)) => {
(Some(f), Input::Point(pi)) => {
let l = pi.point();
add_dim(s, self.kind(s, f, l))?;
Ok(Step::Done)
}
Expand Down Expand Up @@ -1495,7 +1510,8 @@ impl Interactive for ChainM {
}
fn input(&mut self, s: &mut Session, i: Input) -> Result<Step> {
match i {
Input::Point(p) => {
Input::Point(pi) => {
let p = pi.point();
let prev = last_linear(s).ok_or_else(|| EngineError::Other("no linear dimension".into()))?;
let k = chained(s, &prev, p, self.baseline);
self.created.push(add_dim(s, k)?);
Expand Down Expand Up @@ -1786,7 +1802,8 @@ impl Interactive for MLeaderM {
return if self.leader_done { self.finish(s) } else { Ok(Step::Continue) };
}
match i {
Input::Point(p) => {
Input::Point(pi) => {
let p = pi.point();
let p = self.constrained(p);
self.pts.push(p);
if self.pts.len() >= self.max_points || self.no_leader() {
Expand Down
18 changes: 11 additions & 7 deletions crates/engine/src/cmd/annotate_dimedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,17 @@ impl Interactive for JoggedM {
return Ok(Step::Continue);
}
match (self.circle, self.center, self.at, i) {
(None, _, _, Input::Point(p)) => match pick_at(s, p).and_then(|h| circle_of(s, h)) {
(None, _, _, Input::Point(pi)) => match pick_at(s, pi.point()).and_then(|h| circle_of(s, h)) {
Some(t) => self.circle = Some(t),
None => s.echo("Object selected is not a circle or arc."),
},
(Some(_), None, _, Input::Point(p)) => self.center = Some(p),
(Some(_), None, _, Input::Point(pi)) => self.center = Some(pi.point()),
(Some(_), Some(_), None, Input::Keyword(k)) => {
self.text.keyword(&k);
}
(Some(_), Some(_), None, Input::Point(p)) => self.at = Some(p),
(Some((c, r)), Some(o), Some(at), Input::Point(j)) => {
(Some(_), Some(_), None, Input::Point(pi)) => self.at = Some(pi.point()),
(Some((c, r)), Some(o), Some(at), Input::Point(pi)) => {
let j = pi.point();
if let Some(k) = jogged_kind(s, c, r, o, at, Some(j), "") {
add_dim(s, self.text.apply(k))?;
}
Expand Down Expand Up @@ -432,7 +433,8 @@ impl Interactive for JogLineM {
None => s.echo("Select a linear or aligned dimension."),
}
}
(Some(h), Input::Point(at)) => {
(Some(h), Input::Point(pi)) => {
let at = pi.point();
run_jogline(s, &json!({ "handle": h.hex(), "at": [at.x, at.y] }))?;
return Ok(Step::Done);
}
Expand Down Expand Up @@ -628,11 +630,13 @@ impl Interactive for DimBreakM {
}
if self.manual_mode {
return match i {
Input::Point(p) if self.manual.is_empty() => {
Input::Point(pi) if self.manual.is_empty() => {
let p = pi.point();
self.manual.push(p);
Ok(Step::Continue)
}
Input::Point(p) => {
Input::Point(pi) => {
let p = pi.point();
let a = self.manual.first().copied().unwrap_or(p);
self.run(s, json!({ "mode": "manual", "first": [a.x, a.y], "second": [p.x, p.y] }))
}
Expand Down
11 changes: 7 additions & 4 deletions crates/engine/src/cmd/annotate_qdim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ impl Interactive for QDimM {
};
}
match (self.ask, i) {
(Ask::Position, Input::Point(at)) => {
(Ask::Position, Input::Point(pi)) => {
let at = pi.point();
let r = run(s, &self.params(at))?;
let n = r.get("handles").and_then(Value::as_array).map_or(0, Vec::len);
s.echo(format!("{n} dimension(s) created."));
Expand All @@ -327,15 +328,17 @@ impl Interactive for QDimM {
}
}
},
(Ask::Datum, Input::Point(p)) => {
(Ask::Datum, Input::Point(pi)) => {
let p = pi.point();
self.datum = Some(p);
self.ask = Ask::Position;
}
(Ask::Remove, Input::Point(p)) => {
(Ask::Remove, Input::Point(pi)) => {
let p = pi.point();
self.tol = self.tol.max(s.pixel_size() * s.settings.pickbox.max(1.0));
self.remove.push(p);
}
(Ask::Add, Input::Point(p)) => self.add.push(p),
(Ask::Add, Input::Point(pi)) => self.add.push(pi.point()),
(Ask::Remove, Input::Keyword(k)) if k == "Add" => self.ask = Ask::Add,
(Ask::Add, Input::Keyword(k)) if k == "Remove" => self.ask = Ask::Remove,
(Ask::Remove | Ask::Add | Ask::Settings, Input::Keyword(_) | Input::Enter) => self.ask = Ask::Position,
Expand Down
5 changes: 4 additions & 1 deletion crates/engine/src/cmd/annotate_tedit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ impl Interactive for TEditM {
};
}
match i {
Input::Point(p) => self.run(s, json!({ "at": [p.x, p.y] })),
Input::Point(pi) => {
let p = pi.point();
self.run(s, json!({ "at": [p.x, p.y] }))
}
Input::Keyword(k) if k == "Angle" => {
self.asking_angle = true;
Ok(Step::Continue)
Expand Down
40 changes: 28 additions & 12 deletions crates/engine/src/cmd/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,10 @@ impl RectM {
let d = match i {
Input::Enter => return Ok(Some(cur)),
Input::Text(t) => number(t),
Input::Point(p) => Some(self.base.dist(*p)),
Input::Point(pi) => {
let p = pi.point();
Some(self.base.dist(p))
}
_ => return Ok(None),
};
d.filter(|d| d.is_finite() && d.abs() > 1e-12).map(Some).ok_or_else(|| other("Requires a nonzero distance."))
Expand All @@ -567,7 +570,10 @@ impl RectM {
let k = match i {
Input::Enter => return self.finish(s),
Input::Keyword(k) => k,
Input::Point(_) => return Err(other("Editing the array with grips is not available yet; choose an option.")),
Input::Point(pi) => {
let _ = pi.point();
return Err(other("Editing the array with grips is not available yet; choose an option."));
}
_ => return Err(other("Invalid option keyword.")),
};
self.stage = match k.as_str() {
Expand Down Expand Up @@ -661,8 +667,9 @@ impl Interactive for RectM {
}
None => return Err(other("Requires Yes or No.")),
},
(Base, Input::Point(p)) => {
self.base = *p;
(Base, Input::Point(pi)) => {
let p = pi.point();
self.base = p;
Main
}
(Base, Input::Enter) => {
Expand Down Expand Up @@ -757,12 +764,13 @@ impl Interactive for RectM {
}
_ => return Err(other("Requires a number.")),
},
(UnitCell, Input::Point(p)) => match self.corner {
(UnitCell, Input::Point(pi)) => match self.corner {
None => {
self.corner = Some(*p);
self.corner = Some(pi.point());
UnitCell
}
Some(c) => {
let p = pi.point();
let (dx, dy) = (p.x - c.x, p.y - c.y);
if dx.abs() <= 1e-12 || dy.abs() <= 1e-12 {
return Err(other("The unit cell must have a width and a height."));
Expand Down Expand Up @@ -940,7 +948,10 @@ impl PolarM {
let k = match i {
Input::Enter => return self.finish(s),
Input::Keyword(k) => k,
Input::Point(_) => return Err(other("Editing the array with grips is not available yet; choose an option.")),
Input::Point(pi) => {
let _ = pi.point();
return Err(other("Editing the array with grips is not available yet; choose an option."));
}
_ => return Err(other("Invalid option keyword.")),
};
self.stage = match k.as_str() {
Expand All @@ -963,7 +974,10 @@ impl PolarM {
let d = match i {
Input::Enter => return Ok(Some(cur)),
Input::Text(t) => number(t),
Input::Point(p) => Some(self.center.dist(*p)),
Input::Point(pi) => {
let p = pi.point();
Some(self.center.dist(p))
}
_ => return Ok(None),
};
d.filter(|d| d.is_finite() && d.abs() > 1e-12).map(Some).ok_or_else(|| other("Requires a nonzero distance."))
Expand Down Expand Up @@ -1031,8 +1045,9 @@ impl Interactive for PolarM {
}
None => return Err(other("Requires Yes or No.")),
},
(Center, Input::Point(p)) => {
self.center = *p;
(Center, Input::Point(pi)) => {
let p = pi.point();
self.center = p;
Main
}
(Center, Input::Keyword(k)) if k == "Base point" => CenterBase,
Expand All @@ -1041,8 +1056,9 @@ impl Interactive for PolarM {
Center
}
(Center, _) => return Err(other("Requires a point or an option keyword.")),
(CenterBase | Base, Input::Point(p)) => {
self.base = Some(*p);
(CenterBase | Base, Input::Point(pi)) => {
let p = pi.point();
self.base = Some(p);
if stage == CenterBase { Center } else { Main }
}
(CenterBase | Base, Input::Enter) => {
Expand Down
Loading
Loading