diff --git a/src/model/selection/tree.rs b/src/model/selection/tree.rs index 89fe9ec..f962933 100644 --- a/src/model/selection/tree.rs +++ b/src/model/selection/tree.rs @@ -6,14 +6,31 @@ use crate::model::document::structure; use crate::model::versioned; use crate::model::versioned::Versioned; +#[derive(Clone)] +pub struct Selection { + pub document: sync::Arc, + root: SparseNode, + + version: versioned::Version, +} + +pub struct TreeIter<'a> { + selection: &'a Selection, + stack: Vec<(usize, SparseNodeOrAllGrandchildren<'a>, &'a sync::Arc)>, + current_sparse: SparseNodeOrAllGrandchildren<'a>, + current_struct: &'a sync::Arc, + child_index: Option, +} + + #[derive(Clone, Debug)] -pub struct SparseNode { +struct SparseNode { self_selected: bool, children_selected: ChildrenMode, } #[derive(Clone, Debug)] -pub enum ChildrenMode { +enum ChildrenMode { None, Mixed(Vec), @@ -25,27 +42,11 @@ pub enum ChildrenMode { AllGrandchildren, } -#[derive(Clone)] -pub struct Selection { - pub document: sync::Arc, - pub root: SparseNode, - - version: versioned::Version, -} - enum SparseNodeOrAllGrandchildren<'a> { Node(&'a SparseNode), AllGrandchildren } -pub struct TreeIter<'a> { - selection: &'a Selection, - stack: Vec<(usize, SparseNodeOrAllGrandchildren<'a>, &'a sync::Arc)>, - current_sparse: SparseNodeOrAllGrandchildren<'a>, - current_struct: &'a sync::Arc, - child_index: Option, -} - impl Selection { pub fn new(document: sync::Arc) -> Self { Selection {