Prepare to support nested operations

This commit is contained in:
Hanno Braun 2024-12-11 20:55:46 +01:00
parent ec6b444ec9
commit 97ce9f88ac
2 changed files with 9 additions and 3 deletions

View File

@ -78,7 +78,7 @@ impl TextRenderer {
}, },
); );
for (op, selected) in operations.operations().into_iter() { for (op, selected, indent) in operations.operations().into_iter() {
let mut attrs = glyphon::Attrs::new(); let mut attrs = glyphon::Attrs::new();
if selected { if selected {
@ -86,6 +86,11 @@ impl TextRenderer {
} }
let mut line = String::new(); let mut line = String::new();
for _ in 0..indent {
write!(line, "\t")?;
}
write!(line, "{op}")?; write!(line, "{op}")?;
buffer.lines.push(glyphon::BufferLine::new( buffer.lines.push(glyphon::BufferLine::new(

View File

@ -16,7 +16,7 @@ impl OperationView {
} }
} }
pub fn operations(&self) -> Vec<(Self, bool)> { pub fn operations(&self) -> Vec<(Self, bool, usize)> {
self.operation self.operation
.children() .children()
.into_iter() .into_iter()
@ -28,6 +28,7 @@ impl OperationView {
selected: None, selected: None,
}, },
Some(i) == self.selected, Some(i) == self.selected,
0,
) )
}) })
.collect() .collect()
@ -55,7 +56,7 @@ impl OperationView {
self.operations() self.operations()
.into_iter() .into_iter()
.nth(selected) .nth(selected)
.map(|(op, _)| op) .map(|(op, _, _)| op)
}) })
.unwrap_or(self.clone()) .unwrap_or(self.clone())
} }