pub struct Grid {
pub grid: FxHashMap<(u32, u32), CellItem>,
pub grid_rects: FxHashMap<(u32, u32), TheDim>,
pub row_indents: FxHashMap<u32, u32>,
}Fields§
§grid: FxHashMap<(u32, u32), CellItem>§grid_rects: FxHashMap<(u32, u32), TheDim>§row_indents: FxHashMap<u32, u32>Implementations§
Source§impl Grid
impl Grid
pub fn new() -> Self
Sourcepub fn insert(&mut self, at: (u32, u32), item: CellItem)
pub fn insert(&mut self, at: (u32, u32), item: CellItem)
Insert a cell item at the given location.
Sourcepub fn is_role_at(&self, at: (u32, u32), x_offset: i32, role: CellRole) -> bool
pub fn is_role_at(&self, at: (u32, u32), x_offset: i32, role: CellRole) -> bool
Checks the cell role at the given position / offset
Sourcepub fn shift_rows_down_from(&mut self, start_row: u32, count: u32)
pub fn shift_rows_down_from(&mut self, start_row: u32, count: u32)
Shift all rows with index >= start_row down by count.
Sourcepub fn insert_empty(&mut self)
pub fn insert_empty(&mut self)
Ensure invariants:
- Every existing row ends with a trailing
Cell::Empty. - After the last non-empty row, create a suffix of rows — one per
indentation level from that row’s indent down to 0 — each containing at
least one
Cell::Empty. This guarantees there’s always a drop target at every indentation level.
Sourcepub fn fill_indent_gaps(&mut self)
pub fn fill_indent_gaps(&mut self)
Ensure that between any two adjacent existing rows, if the indent drops by more than 1, we insert intermediate empty rows so there is always a drop target at each missing indent level.
Sourcepub fn remove_dependencies_for(&mut self, id: Uuid)
pub fn remove_dependencies_for(&mut self, id: Uuid)
Removes all dependencies for a given id.
Sourcepub fn grid_by_rows(&self) -> Vec<Vec<(&CellItem, (u32, u32))>>
pub fn grid_by_rows(&self) -> Vec<Vec<(&CellItem, (u32, u32))>>
Returns the grid sorted in rows / columns
Sourcepub fn return_sibling_at(&mut self, row: u32)
pub fn return_sibling_at(&mut self, row: u32)
Insert a sibling empty row adjacent to row with the same indent.
For control rows (If/Else), insert above so the line below stays reserved for the block body.
For non-control rows, insert below.
Sourcepub fn return_at(&mut self, row: u32)
pub fn return_at(&mut self, row: u32)
Handles a return at the given row, i.e. pushes the current row and all rows below down
and inserts an empty row at the current position with the same indent.
Special case: if the current row starts with If and the next row is not indented,
insert a new indented line below for the if body instead of moving things down.
Sourcepub fn delete_at(&mut self, row: u32)
pub fn delete_at(&mut self, row: u32)
Handles deletion/backspace at the given row.
If the current row is empty, delete it. Otherwise, if the previous row exists and is empty,
delete that previous row. Otherwise, delete the current row. Then shift rows below up by one
and update indents accordingly. Finally, restore grid invariants via insert_empty().
Sourcepub fn move_down_from(&mut self, row: u32)
pub fn move_down_from(&mut self, row: u32)
Move all rows at or below the given row index one line down (shift by 1).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Grid
impl<'de> Deserialize<'de> for Grid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnsafeUnpin for Grid
impl UnwindSafe for Grid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().