Skip to content

Commit eb76181

Browse files
committed
v2.1.5
1 parent 0940421 commit eb76181

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HierarchicalUtils"
22
uuid = "f9ccea15-0695-44b9-8113-df7c26ae4fa9"
33
authors = ["Simon Mandlik <simon.mandlik@gmail.com>"]
4-
version = "2.1.4"
4+
version = "2.1.5"
55

66
[deps]
77
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"

src/printing.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,20 @@ end
1616
DisplaySizePrinter(io::IO, W::Number, H::Number) = DisplaySizePrinter(io, W, W, H)
1717

1818
function Base.println(p::DisplaySizePrinter, pad)
19-
p.h > 0 || return
20-
if p.h 1
21-
println(p.io)
22-
p.w = p.W
23-
end
19+
p.h > 1 || return
20+
println(p.io)
21+
p.w = p.W
22+
p.h -= 1
2423
if p.h == 1
2524
print_last(p, pad)
25+
p.h -= 1
26+
end
27+
end
28+
29+
function print_last(printer::DisplaySizePrinter, pad; kwargs...)
30+
for (c, p) in pad
31+
Base.printstyled(printer.io, replace(p, V_LINE => V_ELLIPSIS); color=c)
2632
end
27-
p.h -= 1
2833
end
2934

3035
function printstyled(p::DisplaySizePrinter, s; kwargs...)
@@ -43,13 +48,6 @@ function printstyled(p::DisplaySizePrinter, s; kwargs...)
4348
end
4449
end
4550

46-
function print_last(printer::DisplaySizePrinter, pad; kwargs...)
47-
printer.h -= 1
48-
for (c, p) in pad
49-
Base.printstyled(printer.io, replace(p, V_LINE => V_ELLIPSIS); color=c)
50-
end
51-
end
52-
5351
function paddedprint(io, s; pad=[], color=:default, kwargs...)
5452
@nospecialize
5553
for (c, p) in pad
@@ -103,7 +101,7 @@ function _printtree(printer, n, C, d, p, pl, e, trav, htrunc, vtrunc, comments)
103101
if d+1 >= htrunc || pl + length(gap) + 6 > printer.W
104102
println(printer, [p; (c, gap * V_LINE)])
105103
paddedprint(printer, gap * V_ELLIPSIS, color=c, pad=p)
106-
elseif nch > vtrunc && vtrunc + 1 < printer.h
104+
elseif nch > vtrunc && vtrunc + 2 < printer.h
107105
l2 = vtrunc < 2 ? 0 : (vtrunc < 4 ? 1 : 2)
108106
l1 = vtrunc - l2
109107
int1, int2 = 1:l1, nch-l2+1:nch
@@ -137,7 +135,7 @@ function printtree(io::IO, n; trav::Bool=false, htrunc::Number=Inf, vtrunc::Numb
137135
@assert vtrunc 0 "vtrunc must be ≥ 0"
138136
H, W = limit ? displaysize(io) : (Inf, Inf)
139137
# for "julia>" prompts and newline
140-
H -= 4
138+
H -= 3
141139
# print at least one node + ellipsis
142140
H = max(H, 2)
143141
# print at least three characters before ellipsis

0 commit comments

Comments
 (0)