From e88894a1a3688ca154829426579236f87cd518dd Mon Sep 17 00:00:00 2001 From: Lukasz Stafiniak Date: Sat, 30 Dec 2023 21:36:06 +0100 Subject: [PATCH] Fixes #28: no misleading uptick for empty tree nodes --- src/printbox-text/PrintBox_text.ml | 10 ++++++++-- test/test_ann_0_3.expected | 2 +- test/test_blending.expected | 21 ++++++++++++++++----- test/test_blending.ml | 5 ++++- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/printbox-text/PrintBox_text.ml b/src/printbox-text/PrintBox_text.ml index 8538049..80324ac 100644 --- a/src/printbox-text/PrintBox_text.ml +++ b/src/printbox-text/PrintBox_text.ml @@ -623,10 +623,16 @@ end = struct assert (Array.length a > 0); if (size n).y > 0 && has_border (Pos.move_y pos' ~-1) conn_m.m then conn_m.m <- create_or_update ~ct:`Nontree ~bottom:true (Pos.move_y pos' ~-1) conn_m.m; + (* To blend-in an empty tree root with a "wall" to the left: *) + (* if (size n).y = 0 then + conn_m.m <- create_or_update ~ct:`Nontree ~right:true (Pos.move_x pos' ~-1) conn_m.m; *) let _ = _array_foldi (fun pos' i b -> - let s = "└─" in - conn_m.m <- create_or_update ~ct:`Tree ~top:true ~right:true pos' conn_m.m; + let s = if pos'.y = pos.y then "──" else "└─" in + if pos'.y <> pos.y then + conn_m.m <- create_or_update ~ct:`Tree ~top:true ~right:true pos' conn_m.m + else + conn_m.m <- create_or_update ~ct:`Tree ~left:true ~right:true pos' conn_m.m; conn_m.m <- create_or_update ~ct:`Tree ~left:true ~right:true (Pos.move_x pos' 1) conn_m.m; conn_m.m <- create_or_update ~ct:`Tree ~top:true (Pos.move_y pos' 1) conn_m.m; if i