Description: use crate kasuari (not abandoned cassowary) Author: Jonas Smedegaard Bug-Debian: https://bugs.debian.org/1129372 Last-Update: 2026-04-08 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- a/helix-tui/Cargo.toml +++ b/helix-tui/Cargo.toml @@ -19,7 +19,7 @@ helix-core = { path = "../helix-core" } bitflags.workspace = true -cassowary = "0.3" +kasuari = "0.4" arrayvec.workspace = true unicode-segmentation.workspace = true termina = { workspace = true, optional = true } --- a/helix-tui/src/layout.rs +++ b/helix-tui/src/layout.rs @@ -3,9 +3,9 @@ use std::cell::RefCell; use std::collections::HashMap; -use cassowary::strength::{REQUIRED, WEAK}; -use cassowary::WeightedRelation::*; -use cassowary::{Constraint as CassowaryConstraint, Expression, Solver, Variable}; +use kasuari::Strength; +use kasuari::WeightedRelation::*; +use kasuari::{Constraint as KasuariConstraint, Expression, Solver, Variable}; use helix_view::graphics::{Margin, Rect}; @@ -208,75 +208,75 @@ vars.insert(e.width, (i, 2)); vars.insert(e.height, (i, 3)); } - let mut ccs: Vec = + let mut ccs: Vec = Vec::with_capacity(elements.len() * 4 + layout.constraints.len() * 6); for elt in &elements { - ccs.push(elt.width | GE(REQUIRED) | 0f64); - ccs.push(elt.height | GE(REQUIRED) | 0f64); - ccs.push(elt.left() | GE(REQUIRED) | f64::from(dest_area.left())); - ccs.push(elt.top() | GE(REQUIRED) | f64::from(dest_area.top())); - ccs.push(elt.right() | LE(REQUIRED) | f64::from(dest_area.right())); - ccs.push(elt.bottom() | LE(REQUIRED) | f64::from(dest_area.bottom())); + ccs.push(elt.width | GE(Strength::REQUIRED) | 0f64); + ccs.push(elt.height | GE(Strength::REQUIRED) | 0f64); + ccs.push(elt.left() | GE(Strength::REQUIRED) | f64::from(dest_area.left())); + ccs.push(elt.top() | GE(Strength::REQUIRED) | f64::from(dest_area.top())); + ccs.push(elt.right() | LE(Strength::REQUIRED) | f64::from(dest_area.right())); + ccs.push(elt.bottom() | LE(Strength::REQUIRED) | f64::from(dest_area.bottom())); } if let Some(first) = elements.first() { ccs.push(match layout.direction { - Direction::Horizontal => first.left() | EQ(REQUIRED) | f64::from(dest_area.left()), - Direction::Vertical => first.top() | EQ(REQUIRED) | f64::from(dest_area.top()), + Direction::Horizontal => first.left() | EQ(Strength::REQUIRED) | f64::from(dest_area.left()), + Direction::Vertical => first.top() | EQ(Strength::REQUIRED) | f64::from(dest_area.top()), }); } if let Some(last) = elements.last() { ccs.push(match layout.direction { - Direction::Horizontal => last.right() | EQ(REQUIRED) | f64::from(dest_area.right()), - Direction::Vertical => last.bottom() | EQ(REQUIRED) | f64::from(dest_area.bottom()), + Direction::Horizontal => last.right() | EQ(Strength::REQUIRED) | f64::from(dest_area.right()), + Direction::Vertical => last.bottom() | EQ(Strength::REQUIRED) | f64::from(dest_area.bottom()), }); } match layout.direction { Direction::Horizontal => { for pair in elements.windows(2) { - ccs.push((pair[0].x + pair[0].width) | EQ(REQUIRED) | pair[1].x); + ccs.push((pair[0].x + pair[0].width) | EQ(Strength::REQUIRED) | pair[1].x); } for (i, size) in layout.constraints.iter().enumerate() { - ccs.push(elements[i].y | EQ(REQUIRED) | f64::from(dest_area.y)); - ccs.push(elements[i].height | EQ(REQUIRED) | f64::from(dest_area.height)); + ccs.push(elements[i].y | EQ(Strength::REQUIRED) | f64::from(dest_area.y)); + ccs.push(elements[i].height | EQ(Strength::REQUIRED) | f64::from(dest_area.height)); ccs.push(match *size { - Constraint::Length(v) => elements[i].width | EQ(WEAK) | f64::from(v), + Constraint::Length(v) => elements[i].width | EQ(Strength::WEAK) | f64::from(v), Constraint::Percentage(v) => { - elements[i].width | EQ(WEAK) | (f64::from(v * dest_area.width) / 100.0) + elements[i].width | EQ(Strength::WEAK) | (f64::from(v * dest_area.width) / 100.0) } Constraint::Ratio(n, d) => { elements[i].width - | EQ(WEAK) + | EQ(Strength::WEAK) | (f64::from(dest_area.width) * f64::from(n) / f64::from(d)) } - Constraint::Min(v) => elements[i].width | GE(WEAK) | f64::from(v), - Constraint::Max(v) => elements[i].width | LE(WEAK) | f64::from(v), + Constraint::Min(v) => elements[i].width | GE(Strength::WEAK) | f64::from(v), + Constraint::Max(v) => elements[i].width | LE(Strength::WEAK) | f64::from(v), }); } } Direction::Vertical => { for pair in elements.windows(2) { - ccs.push((pair[0].y + pair[0].height) | EQ(REQUIRED) | pair[1].y); + ccs.push((pair[0].y + pair[0].height) | EQ(Strength::REQUIRED) | pair[1].y); } for (i, size) in layout.constraints.iter().enumerate() { - ccs.push(elements[i].x | EQ(REQUIRED) | f64::from(dest_area.x)); - ccs.push(elements[i].width | EQ(REQUIRED) | f64::from(dest_area.width)); + ccs.push(elements[i].x | EQ(Strength::REQUIRED) | f64::from(dest_area.x)); + ccs.push(elements[i].width | EQ(Strength::REQUIRED) | f64::from(dest_area.width)); ccs.push(match *size { - Constraint::Length(v) => elements[i].height | EQ(WEAK) | f64::from(v), + Constraint::Length(v) => elements[i].height | EQ(Strength::WEAK) | f64::from(v), Constraint::Percentage(v) => { - elements[i].height | EQ(WEAK) | (f64::from(v * dest_area.height) / 100.0) + elements[i].height | EQ(Strength::WEAK) | (f64::from(v * dest_area.height) / 100.0) } Constraint::Ratio(n, d) => { elements[i].height - | EQ(WEAK) + | EQ(Strength::WEAK) | (f64::from(dest_area.height) * f64::from(n) / f64::from(d)) } - Constraint::Min(v) => elements[i].height | GE(WEAK) | f64::from(v), - Constraint::Max(v) => elements[i].height | LE(WEAK) | f64::from(v), + Constraint::Min(v) => elements[i].height | GE(Strength::WEAK) | f64::from(v), + Constraint::Max(v) => elements[i].height | LE(Strength::WEAK) | f64::from(v), }); } } } - solver.add_constraints(&ccs).unwrap(); + solver.add_constraints(ccs).unwrap(); for &(var, value) in solver.fetch_changes() { let (index, attr) = vars[&var]; let value = if value.is_sign_negative() {