basho / clique

CLI Framework for Erlang
Apache License 2.0
147 stars 49 forks source link

Improve table resizing so columns are more evenly sized #30

Closed JeetKunDoug closed 9 years ago

JeetKunDoug commented 9 years ago

Table columns, when the console is too small, are resized in a very uneven/unfair way. For example, take the following code:

Table = [[{foo, "Foo"}, {bar, "Bar"}, {baz, "Another"}, {buzz, "Yup"}, {"Transfer Rate","127 kbp[[{foo,"Foo"},"1280 objs"}, {pid, "<14479.003>"}]].
clique:print([clique_status:table(Table)], fun clique_human_writer:write/1).

If you run this in a console window that's a normal size, you'll get

+---+---+-------+----+-------------+---------+-----------+
|foo|bar|  baz  |buzz|Transfer Rate|  Size   |    pid    |
+---+---+-------+----+-------------+---------+-----------+
|Foo|Bar|Another|Yup |  127 kbps   |1280 objs|<14479.003>|
+---+---+-------+----+-------------+---------+-----------+

Now, shrink your console to be exactly wide enough to show that table, and run clique:print([clique_status:table(Table)], fun clique_human_writer:write/1). again. This time, you get:

+-----------+--------+------------+---+------+--+--+
|    foo    |  bar   |    baz     |buz|Transf|Si|pi|
+-----------+--------+------------+---+------+--+--+
|    Foo    |  Bar   |  Another   |Yup|127 kb|12|<1|
+-----------+--------+------------+---+------+--+--+

Need to find a better method of resizing the columns.

JeetKunDoug commented 9 years ago

Fixed by #54 - closing