continuing work on building a better test tree.

TODO have the iterator return a block ID and its indentation level.
this will facilitate actually rendering the block content properly.
This commit is contained in:
2026-03-29 13:00:05 -04:00
parent bf8f64b904
commit a3158ba034
2 changed files with 18 additions and 6 deletions

View File

@@ -5,8 +5,8 @@ use std::collections::HashMap;
pub struct NoteBlock {
// IDs are int64 as this is the datatype of rowids in sqlite
id: i128,
first_child_id: Option<i128>,
next_sibling_id: Option<i128>,
pub first_child_id: Option<i128>,
pub next_sibling_id: Option<i128>,
content: String
}

View File

@@ -3,10 +3,10 @@ use std::collections::HashMap;
use outline_rs::blocktree::{NoteBlock, NotePage, BlockTreeIterator};
fn main() {
let root_block = NoteBlock::new(0,Some(1),Some(2),String::from("hello"));
let root_block = NoteBlock::new(0,Some(1),None,String::from("hello"));
let mut block_map = HashMap::new();
for idx in 1..5 {
for idx in 1..=5 {
let new_block = NoteBlock::new(idx,None, None, String::from("I'm block {idx}"));
block_map.insert(idx,new_block);
}
@@ -14,12 +14,24 @@ fn main() {
let mut page = NotePage::new(String::from("page 1"), 0, root_block);
// take each new block and give it some children/siblings
let mut block1 = block_vector.remove(1)?;
block1.next_sibling_id =
let mut block1 = block_map.remove(&1).unwrap();
block1.next_sibling_id = Some(2);
page.insert(block1);
let mut block2 = block_map.remove(&2).unwrap();
block2.first_child_id = Some(3);
block2.next_sibling_id = Some(4);
page.insert(block2);
let mut block3 = block_map.remove(&3).unwrap();
page.insert(block3);
let mut block4 = block_map.remove(&4).unwrap();
block4.first_child_id = Some(5);
page.insert(block4);
let mut block5 = block_map.remove(&5).unwrap();
page.insert(block5);
page.build_tree();