@@ -120,27 +120,54 @@ function show(io::IO, ct::CoefTable)
120
120
if length (rownms) == 0
121
121
rownms = [lpad (" [$i ]" ,floor (Integer, log10 (nr))+ 3 ) for i in 1 : nr]
122
122
end
123
+
124
+ if ! (get (io, :limit , false ):: Bool )
125
+ screenheight = screenwidth = typemax (Int)
126
+ else
127
+ sz = displaysize (io):: Tuple{Int,Int}
128
+ screenheight, screenwidth = sz[1 ] - 4 , sz[2 ]
129
+ end
130
+
131
+ sepsize = 3
132
+ hdots = " \u 2026 "
123
133
mat = [j == 1 ? NoQuote (rownms[i]) :
124
134
j- 1 == ct. pvalcol ? NoQuote (sprint (show, PValue (cols[j- 1 ][i]))) :
125
135
j- 1 in ct. teststatcol ? TestStat (cols[j- 1 ][i]) :
126
136
cols[j- 1 ][i] isa AbstractString ? NoQuote (cols[j- 1 ][i]) : cols[j- 1 ][i]
127
137
for i in 1 : nr, j in 1 : nc+ 1 ]
138
+
128
139
# Code inspired by print_matrix in Base
129
140
io = IOContext (io, :compact => true , :limit => false )
130
141
A = Base. alignment (io, mat, 1 : size (mat, 1 ), 1 : size (mat, 2 ),
131
- typemax (Int), typemax (Int), 3 )
142
+ screenwidth, screenwidth, sepsize )
132
143
nmswidths = pushfirst! (length .(colnms), 0 )
133
144
A = [nmswidths[i] > sum (A[i]) ? (A[i][1 ]+ nmswidths[i]- sum (A[i]), A[i][2 ]) : A[i]
134
145
for i in 1 : length (A)]
135
- totwidth = sum (sum .(A)) + 2 * (length (A) - 1 )
146
+
147
+ # remove columns that do not fit on the screen
148
+ maxcols = length (A)
149
+ totwidth = sum (sum .(A)) + 2 * (length (A) - 1 )+ sepsize
150
+ if maxcols < nc+ 1
151
+ ncols = min (nc, maxcols)
152
+ mat = mat[:, 1 : ncols]
153
+ colnms = colnms[1 : ncols]
154
+ sepsize = length (hdots)+ 1
155
+ else
156
+ sepsize = 0
157
+ end
158
+
159
+ # print table
160
+ totwidth = sum (sum .(A)) + 2 * (length (A) - 1 )+ sepsize
136
161
println (io, repeat (' ─' , totwidth))
137
162
print (io, repeat (' ' , sum (A[1 ])))
138
- for j in 1 : length (colnms)
163
+ for j in 1 : maxcols - 1
139
164
print (io, " " , lpad (colnms[j], sum (A[j+ 1 ])))
140
165
end
166
+ maxcols < nc+ 1 && print (io, lpad (hdots, sepsize))
141
167
println (io, ' \n ' , repeat (' ─' , totwidth))
142
168
for i in 1 : size (mat, 1 )
143
169
Base. print_matrix_row (io, mat, A, i, 1 : size (mat, 2 ), " " )
170
+ maxcols < nc+ 1 && print (io, lpad (hdots, sepsize))
144
171
i != size (mat, 1 ) && println (io)
145
172
end
146
173
print (io, ' \n ' , repeat (' ─' , totwidth))
0 commit comments