Skip to content

Commit

Permalink
Show only first and last 10 rows for matrices larger, than 21 row
Browse files Browse the repository at this point in the history
  • Loading branch information
versilov committed May 8, 2018
1 parent fbf7946 commit 946f5f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/matrex/inspect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defimpl Inspect, for: Matrex do
} = matrex,
%{width: screen_width} = _opts
)
when columns < screen_width / 8 and rows <= 50 do
when columns < screen_width / 8 and rows <= 21 do
rows_as_strings =
for(
row <- 1..rows,
Expand Down Expand Up @@ -40,7 +40,7 @@ defimpl Inspect, for: Matrex do
} = matrex,
%{width: screen_width} = _opts
)
when columns >= screen_width / 8 or rows > 50 do
when columns >= screen_width / 8 or rows > 21 do
suffix_size = prefix_size = div(screen_width, 16)

rows_as_strings =
Expand Down Expand Up @@ -73,8 +73,8 @@ defimpl Inspect, for: Matrex do
"#{header(rows, columns)}\n#{top}#{contents_str}#{bottom}"
end

defp displayable_rows(rows) when rows > 50,
do: Enum.to_list(1..25) ++ [-1] ++ Enum.to_list((rows - 25)..rows)
defp displayable_rows(rows) when rows > 21,
do: Enum.to_list(1..10) ++ [-1] ++ Enum.to_list((rows - 9)..rows)

defp displayable_rows(rows), do: 1..rows

Expand Down

0 comments on commit 946f5f4

Please sign in to comment.