cleanup product editor

This commit is contained in:
Michael Sippel 2022-06-24 15:54:05 +02:00
parent 5fef75e24f
commit d8e8f763a6
Signed by: senvas
GPG key ID: F96CF119C34B64A6
6 changed files with 188 additions and 287 deletions

View file

@ -165,7 +165,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
// up // up
self.cursor.set(ListCursor::none()); self.cursor.set(ListCursor::none());
TreeNavResult::Exit TreeNavResult::Exit
} else { } else {
// horizontal // horizontal

View file

@ -138,6 +138,7 @@ where ItemEditor: TerminalTreeEditor + ?Sized + Send + Sync + 'static
let proj = Arc::new(RwLock::new(ListSegmentSequence { let proj = Arc::new(RwLock::new(ListSegmentSequence {
cur_cursor: cursor_port.get_view().get(), cur_cursor: cursor_port.get_view().get(),
depth, depth,
cursor: proj_helper.new_singleton_arg(0, cursor_port, |s: &mut Self, _msg| { cursor: proj_helper.new_singleton_arg(0, cursor_port, |s: &mut Self, _msg| {
let _old_cursor = s.cur_cursor; let _old_cursor = s.cur_cursor;
s.cur_cursor = s.cursor.get(); s.cur_cursor = s.cursor.get();

View file

@ -9,7 +9,7 @@ use {
tree_nav::{TreeNav, TerminalTreeEditor, TreeNavResult}, tree_nav::{TreeNav, TerminalTreeEditor, TreeNavResult},
vec::{VecBuffer, MutableVecAccess}, vec::{VecBuffer, MutableVecAccess},
list::ListCursorMode, list::ListCursorMode,
product::{element::ProductEditorElement}, product::{segment::ProductEditorSegment},
make_editor::make_editor make_editor::make_editor
}, },
cgmath::Vector2, cgmath::Vector2,
@ -18,49 +18,33 @@ use {
}; };
pub struct ProductEditor { pub struct ProductEditor {
elements: VecBuffer<ProductEditorElement>, segments: VecBuffer<ProductEditorSegment>,
pub(super) n_indices: Vec<usize>, pub(super) n_indices: Vec<usize>,
el_port: OuterViewPort<dyn SequenceView<Item = ProductEditorElement>>, pub(super) ctx: Arc<RwLock<Context>>,
el_view_port: OuterViewPort<dyn SequenceView<Item = OuterViewPort<dyn TerminalView>>>,
pub(super) ctx: Arc<RwLock<Context>>,
pub(super) cursor: Option<isize>, pub(super) cursor: Option<isize>,
pub(super) depth: usize, pub(super) depth: usize,
} }
impl ProductEditor { impl ProductEditor {
pub fn new(depth: usize, ctx: Arc<RwLock<Context>>) -> Self { pub fn new(depth: usize, ctx: Arc<RwLock<Context>>) -> Self {
let mut port = ViewPort::new();
let el_port = port.outer().to_sequence();
let el_view_port = el_port.map({
let ctx = ctx.clone();
move |e: &ProductEditorElement| { e.get_view(ctx.clone()) }
});
ProductEditor { ProductEditor {
elements: VecBuffer::with_port(port.inner()), segments: VecBuffer::new(),
el_port,
el_view_port,
n_indices: Vec::new(), n_indices: Vec::new(),
ctx, ctx,
cursor: None, cursor: None,
depth depth
} }
} }
pub fn with_t(mut self, t: &str) -> Self { pub fn with_t(mut self, t: &str) -> Self {
self.elements.push(ProductEditorElement::T(t.to_string(), self.depth)); self.segments.push(ProductEditorSegment::T(t.to_string(), self.depth));
self self
} }
pub fn with_n(mut self, n: TypeLadder) -> Self { pub fn with_n(mut self, n: TypeLadder) -> Self {
let elem_idx = self.elements.len(); let elem_idx = self.segments.len();
self.elements.push(ProductEditorElement::N{ self.segments.push(ProductEditorSegment::N{
t: n, t: n,
editor: None, editor: None,
cur_depth: 0 cur_depth: 0
@ -69,34 +53,34 @@ impl ProductEditor {
self self
} }
pub fn get_editor_element(&self, mut idx: isize) -> Option<ProductEditorElement> { pub fn get_editor_element(&self, mut idx: isize) -> Option<ProductEditorSegment> {
idx = crate::modulo(idx, self.n_indices.len() as isize); idx = crate::modulo(idx, self.n_indices.len() as isize);
if let Some(i) = self.n_indices.get(idx as usize) { if let Some(i) = self.n_indices.get(idx as usize) {
Some(self.elements.get(*i)) Some(self.segments.get(*i))
} else { } else {
None None
} }
} }
pub fn get_editor_element_mut(&mut self, mut idx: isize) -> Option<MutableVecAccess<ProductEditorElement>> { pub fn get_editor_element_mut(&mut self, mut idx: isize) -> Option<MutableVecAccess<ProductEditorSegment>> {
idx = crate::modulo(idx, self.n_indices.len() as isize); idx = crate::modulo(idx, self.n_indices.len() as isize);
if let Some(i) = self.n_indices.get(idx as usize) { if let Some(i) = self.n_indices.get(idx as usize) {
Some(self.elements.get_mut(*i)) Some(self.segments.get_mut(*i))
} else { } else {
None None
} }
} }
pub fn get_cur_element(&self) -> Option<ProductEditorElement> { pub fn get_cur_element(&self) -> Option<ProductEditorSegment> {
self.get_editor_element(self.cursor?) self.get_editor_element(self.cursor?)
} }
pub fn get_cur_element_mut(&mut self) -> Option<MutableVecAccess<ProductEditorElement>> { pub fn get_cur_element_mut(&mut self) -> Option<MutableVecAccess<ProductEditorSegment>> {
self.get_editor_element_mut(self.cursor?) self.get_editor_element_mut(self.cursor?)
} }
pub fn get_editor(&self, idx: isize) -> Option<Arc<RwLock<dyn TerminalTreeEditor + Send + Sync>>> { pub fn get_editor(&self, idx: isize) -> Option<Arc<RwLock<dyn TerminalTreeEditor + Send + Sync>>> {
if let Some(ProductEditorElement::N{ t: _, editor, cur_depth: _ }) = self.get_editor_element(idx) { if let Some(ProductEditorSegment::N{ t: _, editor, cur_depth: _ }) = self.get_editor_element(idx) {
editor editor
} else { } else {
None None
@ -116,14 +100,21 @@ impl ProductEditor {
impl TerminalEditor for ProductEditor { impl TerminalEditor for ProductEditor {
fn get_term_view(&self) -> OuterViewPort<dyn TerminalView> { fn get_term_view(&self) -> OuterViewPort<dyn TerminalView> {
self.el_view_port.to_grid_horizontal().flatten() let ctx = self.ctx.clone();
self.segments
.get_port()
.to_sequence()
.map(move |e: &ProductEditorSegment| { e.get_view(ctx.clone()) })
.to_grid_horizontal()
.flatten()
} }
fn handle_terminal_event(&mut self, event: &TerminalEvent) -> TerminalEditorResult { fn handle_terminal_event(&mut self, event: &TerminalEvent) -> TerminalEditorResult {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() { if let Some(ProductEditorSegment::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len(); *cur_depth = self.get_cursor().tree_addr.len();
if let Some(e) = editor.clone() { if let Some(e) = editor.clone() {
match e.clone().write().unwrap().handle_terminal_event(event) { let mut ce = e.write().unwrap();
match ce.handle_terminal_event(event) {
TerminalEditorResult::Exit => TerminalEditorResult::Exit =>
match event { match event {
TerminalEvent::Input(Event::Key(Key::Backspace)) => { TerminalEvent::Input(Event::Key(Key::Backspace)) => {
@ -132,7 +123,7 @@ impl TerminalEditor for ProductEditor {
TerminalEditorResult::Continue TerminalEditorResult::Continue
} }
_ => { _ => {
drop(e); drop(ce);
match self.nexd() { match self.nexd() {
TreeNavResult::Continue => TerminalEditorResult::Continue, TreeNavResult::Continue => TerminalEditorResult::Continue,
TreeNavResult::Exit => TerminalEditorResult::Exit TreeNavResult::Exit => TerminalEditorResult::Exit
@ -147,7 +138,7 @@ impl TerminalEditor for ProductEditor {
*editor = Some(e.clone()); *editor = Some(e.clone());
e.write().unwrap().dn(); e.write().unwrap().dn();
let x = e.write().unwrap().handle_terminal_event(event); let x = e.write().unwrap().handle_terminal_event(event);
*cur_depth = self.get_cursor().tree_addr.len(); *cur_depth = self.get_cursor().tree_addr.len()+1;
x x
} }
} else { } else {

View file

@ -1,6 +1,6 @@
pub mod editor; pub mod editor;
pub mod element; pub mod segment;
pub mod nav; pub mod nav;
pub use editor::ProductEditor; pub use editor::ProductEditor;

View file

@ -2,7 +2,8 @@ use {
crate::{ crate::{
list::ListCursorMode, list::ListCursorMode,
tree_nav::{TreeNav, TreeNavResult, TreeCursor, TerminalTreeEditor}, tree_nav::{TreeNav, TreeNavResult, TreeCursor, TerminalTreeEditor},
product::{element::ProductEditorElement, ProductEditor} product::{segment::ProductEditorSegment, ProductEditor},
make_editor::{make_editor}
}, },
cgmath::{Point2, Vector2}, cgmath::{Point2, Vector2},
std::{sync::{Arc, RwLock}, ops::{Deref, DerefMut}}, std::{sync::{Arc, RwLock}, ops::{Deref, DerefMut}},
@ -26,29 +27,50 @@ impl TreeNav for ProductEditor {
} }
} }
} else { } else {
TreeCursor::default() TreeCursor::none()
}
}
fn get_cursor_warp(&self) -> TreeCursor {
if let Some(i) = self.cursor {
if let Some(e) = self.get_editor(i) {
let mut c = e.read().unwrap().get_cursor_warp();
if c.tree_addr.len() == 0 {
c.leaf_mode = ListCursorMode::Select;
}
c.tree_addr.insert(0, i as isize - self.n_indices.len() as isize);
c
} else {
TreeCursor {
leaf_mode: ListCursorMode::Select,
tree_addr: vec![ i as isize - self.n_indices.len() as isize ]
}
}
} else {
TreeCursor::none()
} }
} }
fn goto(&mut self, mut c: TreeCursor) -> TreeNavResult { fn goto(&mut self, mut c: TreeCursor) -> TreeNavResult {
if let Some(mut element) = self.get_cur_element_mut() { if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorElement::N{ t, editor, cur_depth } = element.deref_mut() { if let ProductEditorSegment::N{ t: _t, editor, cur_depth } = element.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
e.write().unwrap().goto(TreeCursor::default()); let mut e = e.write().unwrap();
e.goto(TreeCursor::none());
} }
*cur_depth = self.get_cursor().tree_addr.len(); *cur_depth = 0;
} }
} }
if c.tree_addr.len() > 0 { if c.tree_addr.len() > 0 {
self.cursor = Some(c.clone().tree_addr.remove(0)); self.cursor = Some(crate::modulo(c.tree_addr.remove(0), self.n_indices.len() as isize));
if let Some(mut element) = self.get_cur_element_mut() { if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorElement::N{ t, editor, cur_depth } = element.deref_mut() { if let ProductEditorSegment::N{ t: _t, editor, cur_depth } = element.deref_mut() {
if let Some(e) = editor { if let Some(e) = editor {
e.write().unwrap().goto(c.clone()); e.write().unwrap().goto(c.clone());
} }
*cur_depth = c.tree_addr.len() + 1; *cur_depth = c.tree_addr.len();
} }
} }
@ -60,260 +82,147 @@ impl TreeNav for ProductEditor {
} }
fn goby(&mut self, direction: Vector2<isize>) -> TreeNavResult { fn goby(&mut self, direction: Vector2<isize>) -> TreeNavResult {
TreeNavResult::Exit let mut cur = self.get_cursor();
}
/* match cur.tree_addr.len() {
fn goto_home(&mut self) -> TreeNavResult { 0 => {
if let Some(c) = self.cursor { if direction.y > 0 {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() { self.cursor = Some(0);
if let Some(e) = editor {
let mut ce = e.write().unwrap();
let cur_mode = ce.get_cursor().leaf_mode; if let Some(mut element) = self.get_cur_element_mut() {
let depth = ce.get_cursor().tree_addr.len(); if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
*cur_depth = 1;
}
}
if depth > 0 { self.goby(Vector2::new(direction.x, direction.y-1));
return match ce.goto_home() { TreeNavResult::Continue
TreeNavResult::Exit => { } else if direction.y < 0 {
drop(ce); TreeNavResult::Exit
} else {
TreeNavResult::Continue
}
}
1 => {
if direction.y > 0 {
// dn
if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
if let Some(e) = editor {
let mut e = e.write().unwrap();
e.goby(direction);
*cur_depth = e.get_cursor().tree_addr.len();
} else {
// create editor
let e = make_editor(self.ctx.clone(), t, self.depth+1);
*editor = Some(e.clone());
let mut e = e.write().unwrap();
e.goby(direction);
*cur_depth = e.get_cursor().tree_addr.len() + 1;
}
}
}
TreeNavResult::Continue
} else if direction.y < 0 {
// up
if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
*cur_depth = 0;
}
}
self.cursor = None;
TreeNavResult::Exit
} else {
// horizontal
if (cur.tree_addr[0]+direction.x >= 0) &&
(cur.tree_addr[0]+direction.x < self.n_indices.len() as isize)
{
if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
*cur_depth = 0; *cur_depth = 0;
}
match self.pxev() { }
TreeNavResult::Exit => TreeNavResult::Exit, self.cursor = Some(cur.tree_addr[0] + direction.x);
TreeNavResult::Continue => { if let Some(mut element) = self.get_cur_element_mut() {
for _x in 1..depth { if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
self.dn(); *cur_depth = 1;
self.goto_end(); }
}
TreeNavResult::Continue
} else {
self.cursor = None;
TreeNavResult::Exit
}
}
}
depth => {
if let Some(mut element) = self.get_cur_element_mut() {
if let ProductEditorSegment::N{ t, editor, cur_depth } = element.deref_mut() {
if let Some(e) = editor {
let mut ce = e.write().unwrap();
//\\//\\//\\//\\
// horizontal //
//\\//\\//\\//\\
match ce.goby(direction) {
TreeNavResult::Exit => {
*cur_depth = 0;
drop(ce);
drop(e);
if direction.y < 0 {
if depth <= (1-direction.y) as usize {
// up
TreeNavResult::Exit
} else {
TreeNavResult::Continue
} }
self.dn(); } else if direction.y > 0 {
self.set_leaf_mode(cur_mode); // dn
TreeNavResult::Continue
} else if direction.y == 0 {
// horizontal
if (cur.tree_addr[0]+direction.x >= 0) &&
(cur.tree_addr[0]+direction.x < self.n_indices.len() as isize)
{
if direction.x < 0 {
cur.tree_addr[0] -= 1;
for i in 1..depth {
cur.tree_addr[i] = -1;
}
} else {
cur.tree_addr[0] += 1;
for i in 1..depth {
cur.tree_addr[i] = 0;
}
}
self.goto(cur)
} else {
self.cursor = None;
TreeNavResult::Exit
}
} else {
TreeNavResult::Continue TreeNavResult::Continue
} }
} }
}, TreeNavResult::Continue => {
TreeNavResult::Continue => TreeNavResult::Continue if direction.y > 0 {
}; *cur_depth = depth + direction.y as usize - 1;
}
}
*cur_depth = 0;
if c != 0 {
self.cursor = Some(0);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len() + 1;
}
return TreeNavResult::Continue;
}
}
}
self.cursor = None;
TreeNavResult::Exit
}
fn goto_end(&mut self) -> TreeNavResult {
if let Some(c) = self.cursor {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
if let Some(e) = editor {
let mut ce = e.write().unwrap();
let cur_mode = ce.get_cursor().leaf_mode;
let depth = ce.get_cursor().tree_addr.len();
if depth > 0 {
match ce.goto_end() {
TreeNavResult::Exit => {
drop(ce);
*cur_depth = 0;
if c+1 < self.n_indices.len() {
match self.nexd() {
TreeNavResult::Exit => {
return TreeNavResult::Exit
},
TreeNavResult::Continue => {
for _x in 1..depth {
self.dn();
}
self.dn();
self.set_leaf_mode(cur_mode);
self.goto_end();
return TreeNavResult::Continue;
}
} }
}
},
TreeNavResult::Continue => {return TreeNavResult::Continue; }
}
}
}
*cur_depth = 0;
if c < self.n_indices.len()-1 {
self.cursor = Some(self.n_indices.len()-1);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
}
return TreeNavResult::Continue;
}
}
}
self.cursor = None;
TreeNavResult::Exit
}
fn pxev(&mut self) -> TreeNavResult {
if let Some(c) = self.cursor {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_editor_element_mut(c).as_deref_mut() {
if let Some(e) = editor {
let mut ce = e.write().unwrap();
let depth = ce.get_cursor().tree_addr.len();
let cur_mode = ce.get_cursor().leaf_mode;
if depth > 0 {
return match ce.pxev() {
TreeNavResult::Exit => {
drop(ce);
*cur_depth = 0;
if c > 0 {
self.cursor = Some(c-1);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
}
for _x in 1..depth {
self.dn();
self.goto_end();
}
self.dn();
self.set_leaf_mode(cur_mode);
self.goto_end();
TreeNavResult::Continue
} else {
TreeNavResult::Exit
}
}
TreeNavResult::Continue => TreeNavResult::Continue
};
}
}
*cur_depth = 0;
if c > 0 {
self.cursor = Some(c-1);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
}
return TreeNavResult::Continue;
}
}
}
self.cursor = None;
TreeNavResult::Exit
}
fn nexd(&mut self) -> TreeNavResult {
if let Some(c) = self.cursor.clone() {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_editor_element_mut(c).as_deref_mut() {
if let Some(e) = editor {
let mut ce = e.write().unwrap();
let depth = ce.get_cursor().tree_addr.len();
let cur_mode = ce.get_cursor().leaf_mode;
if depth > 0 {
return match ce.nexd() {
TreeNavResult::Exit => {
drop(ce);
*cur_depth = 0;
if c+1 < self.n_indices.len() {
self.cursor = Some(c+1);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
}
for _x in 1..depth {
self.dn();
self.goto_home();
}
self.dn();
self.set_leaf_mode(cur_mode);
TreeNavResult::Continue TreeNavResult::Continue
} else {
self.cursor = None;
TreeNavResult::Exit
} }
} }
TreeNavResult::Continue => TreeNavResult::Continue } else {
}; TreeNavResult::Continue
}
} else {
TreeNavResult::Continue
} }
}
*cur_depth = 0;
if c+1 < self.n_indices.len() {
self.cursor = Some(c+1);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
}
return TreeNavResult::Continue;
}
}
}
self.cursor = None;
TreeNavResult::Exit
}
fn up(&mut self) -> TreeNavResult {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
if let Some(e) = editor {
let mut ce = e.write().unwrap();
*cur_depth = ce.get_cursor().tree_addr.len();
if ce.get_cursor().tree_addr.len() > 0 {
ce.up();
return TreeNavResult::Continue;
}
}
*cur_depth = 0;
}
self.cursor = None;
TreeNavResult::Exit
}
fn dn(&mut self) -> TreeNavResult {
if let Some(c) = self.cursor {
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_editor_element_mut(c).as_deref_mut() {
if let Some(e) = editor {
e.write().unwrap().dn();
} else { } else {
let e = make_editor(self.ctx.clone(), t, self.depth+1); TreeNavResult::Continue
e.write().unwrap().dn();
*editor = Some(e);
} }
*cur_depth = self.get_cursor().tree_addr.len();
}
} else {
self.cursor = Some(0);
if let Some(ProductEditorElement::N{ t, editor, cur_depth }) = self.get_cur_element_mut().as_deref_mut() {
*cur_depth = self.get_cursor().tree_addr.len();
} }
} }
}
TreeNavResult::Continue
}
*/
} }
impl TerminalTreeEditor for ProductEditor {} impl TerminalTreeEditor for ProductEditor {}

View file

@ -13,7 +13,7 @@ use {
}; };
#[derive(Clone)] #[derive(Clone)]
pub enum ProductEditorElement { pub enum ProductEditorSegment {
T( String, usize ), T( String, usize ),
N { N {
t: TypeLadder, t: TypeLadder,
@ -22,10 +22,10 @@ pub enum ProductEditorElement {
} }
} }
impl ProductEditorElement { impl ProductEditorSegment {
pub fn get_view(&self, ctx: Arc<RwLock<Context>>) -> OuterViewPort<dyn TerminalView> { pub fn get_view(&self, ctx: Arc<RwLock<Context>>) -> OuterViewPort<dyn TerminalView> {
match self { match self {
ProductEditorElement::T(t, depth) => ProductEditorSegment::T(t, depth) =>
make_label(t.as_str()) make_label(t.as_str())
.map_item({ .map_item({
let depth = *depth; let depth = *depth;
@ -34,7 +34,7 @@ impl ProductEditorElement {
} }
), ),
ProductEditorElement::N { t: _, editor: Some(e), cur_depth } => ProductEditorSegment::N { t: _, editor: Some(e), cur_depth } =>
e.read().unwrap() e.read().unwrap()
.get_term_view() .get_term_view()
.map_item({ let cur_depth = *cur_depth;//e.read().unwrap().get_cursor().tree_addr.len()+1; .map_item({ let cur_depth = *cur_depth;//e.read().unwrap().get_cursor().tree_addr.len()+1;
@ -43,7 +43,7 @@ impl ProductEditorElement {
.add_style_back(bg_style_from_depth(cur_depth)) .add_style_back(bg_style_from_depth(cur_depth))
}), }),
ProductEditorElement::N{ t, editor: None, cur_depth } => ProductEditorSegment::N{ t, editor: None, cur_depth } =>
make_label(&ctx.read().unwrap().type_term_to_str(&t[0])) make_label(&ctx.read().unwrap().type_term_to_str(&t[0]))
.map_item({ .map_item({
let cur_depth = *cur_depth; let cur_depth = *cur_depth;