some basic tui examples working

This commit is contained in:
Evan Almloff committed 2022-12-05 13:30:13 -06:00
1 parent 11b37ee141
commit 1587056a4b
5 files changed
+21 -14

No files matched your search

+3 -1
View File
@@ -215,8 +215,10 @@ fn resolve_downward_pass<T, P: DownwardPass<T> + ?Sized>(
while let Some(id) = dirty.pop_front() {
let (node, parent) = tree.node_parent_mut(id).unwrap();
let result = pass.pass(node, parent, ctx);
if result.mark_dirty || result.progress {
if result.mark_dirty {
nodes_updated.insert(id);
}
if result.mark_dirty || result.progress {
for id in tree.children_ids(id).unwrap() {
if result.mark_dirty {
for dependant in pass.dependants() {
+6 -3
View File
@@ -164,7 +164,10 @@ impl<S: State> RealDom<S> {
}
/// Updates the dom with some mutations and return a set of nodes that were updated. Pass the dirty nodes to update_state.
pub fn apply_mutations(&mut self, mutations: Mutations) -> DirtyNodeStates {
pub fn apply_mutations(
&mut self,
mutations: Mutations,
) -> (DirtyNodeStates, FxHashMap<RealNodeId, NodeMask>) {
let mut nodes_updated: FxHashMap<RealNodeId, NodeMask> = FxHashMap::default();
for template in mutations.templates {
let mut template_root_ids = Vec::new();
@@ -348,7 +351,7 @@ impl<S: State> RealDom<S> {
}
let dirty_nodes = DirtyNodeStates::default();
for (n, mask) in nodes_updated {
for (&n, mask) in &nodes_updated {
// remove any nodes that were created and then removed in the same mutations from the dirty nodes list
if self.tree.contains(n) {
for (m, p) in S::MASKS.iter().zip(S::PASSES.iter()) {
@@ -359,7 +362,7 @@ impl<S: State> RealDom<S> {
}
}
dirty_nodes
(dirty_nodes, nodes_updated)
}
/// Update the state of the dom, after appling some mutations. This will keep the nodes in the dom up to date with their VNode counterparts.
+1 -3
View File
@@ -221,10 +221,8 @@ pub trait State: Default + Clone + 'static {
tree: &mut T,
ctx: SendAnyMap,
) -> FxDashSet<RealNodeId> {
let set = FxDashSet::default();
let passes = Self::PASSES.iter().collect();
resolve_passes(tree, dirty, passes, ctx);
set
resolve_passes(tree, dirty, passes, ctx)
}
}