@@ -61,8 +61,7 @@ function _truncate_at_width_or_chars(str, width, chars="", truncmark="…")
6161end
6262
6363showdict (t:: Associative ; kw... ) = showdict (STDOUT, t; kw... )
64- function showdict {K,V} (io:: IO , t:: Associative{K,V} ; compact = false ,
65- sz= (s = tty_size (); (s[1 ]- 3 , s[2 ])))
64+ function showdict {K,V} (io:: IO , t:: Associative{K,V} ; compact = false )
6665 (:SHOWN_SET => t) in io && (print (io, " #= circular reference =#" ); return )
6766
6867 recur_io = IOContext (io, :SHOWN_SET => t)
@@ -95,11 +94,12 @@ function showdict{K,V}(io::IO, t::Associative{K,V}; compact = false,
9594 end
9695
9796 # Otherwise show more descriptively, with one line per key/value pair
98- rows, cols = sz
9997 print (io, summary (t))
10098 isempty (t) && return
10199 print (io, " :" )
102100 if limit
101+ sz = iosize (io)
102+ rows, cols = sz[1 ] - 3 , sz[2 ]
103103 rows < 2 && (print (io, " …" ); return )
104104 cols < 12 && (cols = 12 ) # Minimum widths of 2 for key, 4 for value
105105 cols -= 6 # Subtract the widths of prefix " " separator " => "
@@ -113,6 +113,8 @@ function showdict{K,V}(io::IO, t::Associative{K,V}; compact = false,
113113 ks[i] = sprint (0 , show, k, env= recur_io)
114114 keylen = clamp (length (ks[i]), keylen, div (cols, 3 ))
115115 end
116+ else
117+ rows = cols = 0
116118 end
117119
118120 for (i, (k, v)) in enumerate (t)
@@ -149,19 +151,21 @@ summary{T<:Union{KeyIterator,ValueIterator}}(iter::T) =
149151
150152show (io:: IO , iter:: Union{KeyIterator,ValueIterator} ) = show (io, collect (iter))
151153
152- showkv (iter:: Union{KeyIterator,ValueIterator} ; kw... ) = showkv (STDOUT, iter; kw... )
153- function showkv {T<:Union{KeyIterator,ValueIterator}} (io:: IO , iter:: T ;
154- sz= (s = tty_size (); (s[1 ]- 3 , s[2 ])))
155- limit:: Bool = limit_output (io)
156- rows, cols = sz
154+ showkv (iter:: Union{KeyIterator,ValueIterator} ) = showkv (STDOUT, iter)
155+ function showkv {T<:Union{KeyIterator,ValueIterator}} (io:: IO , iter:: T )
157156 print (io, summary (iter))
158157 isempty (iter) && return
159158 print (io, " . " , T<: KeyIterator ? " Keys" : " Values" , " :" )
159+ limit:: Bool = limit_output (io)
160160 if limit
161+ sz = iosize (io)
162+ rows, cols = sz[1 ] - 3 , sz[2 ]
161163 rows < 2 && (print (io, " …" ); return )
162164 cols < 4 && (cols = 4 )
163165 cols -= 2 # For prefix " "
164166 rows -= 2 # For summary and final ⋮ continuation lines
167+ else
168+ rows = cols = 0
165169 end
166170
167171 for (i, v) in enumerate (iter)
0 commit comments