-
Notifications
You must be signed in to change notification settings - Fork 45
Smart padding #187
Description
A detailed description of the feature you would like to see added.
When table has a whitespace as border, it can look quite cramped, especially when the cells have text with whitespaces. For example, below is a sample output of a certain table:
Line User Idle Location
-- ------- ----- -------- --------------------------------------
1 con 0 root 07:29:04 -
2 vty 3 root 09:12:23 10.243.214.227
3 vty 5 root 07:09:36 10.243.214.212
* 4 vty 7 admin 00:00:00 fdfd:5c41:712d:d08e:2ce2:7eff:fea5:ae5
As you can see most of the columns (especially the second and third) are separated by just a single whitespace which makes it rather hard to read.
The idea of smart padding is to detect that two adjacent cells are only separated by one whitespace, in which case we add one more whitespace between the two columns. With smart padding the above table would look like:
Line User Idle Location
-- -------- ------ --------- --------------------------------------
1 con 0 root 07:29:04 -
2 vty 3 root 09:12:23 10.243.214.227
3 vty 5 root 07:09:36 10.243.214.212
* 4 vty 7 admin 00:00:00 fdfd:5c41:712d:d08e:2ce2:7eff:fea5:ae5
Smart padding does not take effect if one of the condition is true:
1. There is no extra space left
2. The left column is right aligned and the right column is left aligned
I have an implementation below:
hzhongmj@0517929
Please let me know what you think.
Explain your usecase of the requested feature
The smart padding tries to make the padding a bit smarter and only adds extra whitespace when it's necessary (affecting readability). Without this feature we'd have to add the padding unconditionally for all columns which could be wasteful and undesirable.
Alternatives
Manually manage each column to decide whether to add extra padding, but it can only be done statically instead of adjusting to dynamic content.
Additional context
No response