1616DisplaySizePrinter(io:: IO , W:: Number , H:: Number ) = DisplaySizePrinter(io, W, W, H)
1717
1818function 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
2833end
2934
3035function printstyled(p:: DisplaySizePrinter , s; kwargs... )
@@ -43,13 +48,6 @@ function printstyled(p::DisplaySizePrinter, s; kwargs...)
4348 end
4449end
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-
5351function 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