diff --git a/src/backends/text/print.jl b/src/backends/text/print.jl index d8af7394..41d10807 100644 --- a/src/backends/text/print.jl +++ b/src/backends/text/print.jl @@ -256,14 +256,20 @@ function _pt_text(io, pinfo; tf.right_intersection, tf.row) end + # The variable `all_cols_width` contains the width of all printed columns, + # including the row number and row name if the user requested. This is used + # when drawing lines. + all_cols_width = copy(cols_width) + + show_row_names && (all_cols_width = vcat(row_name_width, all_cols_width)) + show_row_number && (all_cols_width = vcat(row_number_width, all_cols_width)) + # Top table line # ========================================================================== tf.top_line && _draw_line!(screen, buf, tf.up_left_corner, tf.up_intersection, tf.up_right_corner, tf.row, - border_crayon, num_printed_cols, cols_width, - show_row_number, row_number_width, - show_row_names, row_name_width) + border_crayon, all_cols_width) # Header # ========================================================================== @@ -335,10 +341,7 @@ function _pt_text(io, pinfo; tf.header_line && _draw_line!(screen, buf, tf.left_intersection, tf.middle_intersection, tf.right_intersection, tf.row, - border_crayon, num_printed_cols, - cols_width, show_row_number, - row_number_width, show_row_names, - row_name_width) + border_crayon, all_cols_width) end # Data @@ -417,18 +420,14 @@ function _pt_text(io, pinfo; # Check if we must draw a horizontal line here. i != num_rows && i in hlines && - _draw_line!(screen, buf, hlines_format..., border_crayon, - num_printed_cols, cols_width, show_row_number, - row_number_width, show_row_names, row_name_width) + _draw_line!(screen, buf, hlines_format..., border_crayon, all_cols_width) # Here we must check if the vertical size of the screen has been # reached. Notice that we must add 4 to account for the command line, # the continuation line, the bottom table line, and the last blank line. if (screen.size[1] > 0) && (screen.row + 4 >= screen.size[1]) _draw_continuation_row(screen, buf, tf, text_crayon, border_crayon, - num_printed_cols, cols_width, - show_row_number, row_number_width, - show_row_names, row_name_width) + all_cols_width) break end end @@ -439,9 +438,7 @@ function _pt_text(io, pinfo; tf.bottom_line && _draw_line!(screen, buf, tf.bottom_left_corner, tf.bottom_intersection, tf.bottom_right_corner, tf.row, border_crayon, - num_printed_cols, cols_width, show_row_number, - row_number_width, show_row_names, - row_name_width) + all_cols_width) # Print the buffer # ========================================================================== diff --git a/src/backends/text/private.jl b/src/backends/text/private.jl index e622a212..10e7c83f 100644 --- a/src/backends/text/private.jl +++ b/src/backends/text/private.jl @@ -135,29 +135,17 @@ available. This function prints in each column the character `⋮` centered. """ function _draw_continuation_row(screen, io, tf, text_crayon, border_crayon, - num_printed_cols, cols_width, show_row_number, - row_number_width, show_row_names, - row_name_width) + cols_width) - _p!(screen, io, border_crayon, tf.column) - - if show_row_number - row_number_i_str = _str_aligned("⋮", :c, row_number_width + 2) - _p!(screen, io, text_crayon, row_number_i_str) - _p!(screen, io, border_crayon, tf.column) - end + num_cols = length(cols_width) - if show_row_names - row_names_i_str = _str_aligned("⋮", :c, row_name_width + 2) - _p!(screen, io, text_crayon, row_names_i_str) - _p!(screen, io, border_crayon, tf.column) - end + _p!(screen, io, border_crayon, tf.column) - @inbounds for j = 1:num_printed_cols + @inbounds for j = 1:num_cols data_ij_str = _str_aligned("⋮", :c, cols_width[j] + 2) _p!(screen, io, text_crayon, data_ij_str) - flp = j == num_printed_cols + flp = j == num_cols _p!(screen, io, border_crayon, tf.column, flp) _eol(screen) && break @@ -169,26 +157,17 @@ function _draw_continuation_row(screen, io, tf, text_crayon, border_crayon, end """ - _draw_line!(screen, io, left, intersection, right, row, border_crayon, num_cols, cols_width, show_row_number, row_number_width, show_row_names, row_name_width) + _draw_line!(screen, io, left, intersection, right, row, border_crayon, cols_width) Draw a vertical line in `io` using the information in `screen`. """ function _draw_line!(screen, io, left, intersection, right, row, border_crayon, - num_cols, cols_width, show_row_number, row_number_width, - show_row_names, row_name_width) + cols_width) - _p!(screen, io, border_crayon, left) - - if show_row_number - _p!(screen, io, border_crayon, row^(row_number_width+2)) - _p!(screen, io, border_crayon, intersection) - end + num_cols = length(cols_width) - if show_row_names - _p!(screen, io, border_crayon, row^(row_name_width+2)) - _p!(screen, io, border_crayon, intersection) - end + _p!(screen, io, border_crayon, left) @inbounds for i = 1:num_cols # Check the alignment and print.