clitable icon indicating copy to clipboard operation
clitable copied to clipboard

Table Alignment - Middle of Screen

Open spaced-out-mvc opened this issue 2 years ago • 2 comments

Hi,

Can you tell me if there is a way to display the table at the middle of the screen, and if not do you think you can add this feature.

Thanks

spaced-out-mvc avatar Oct 24 '21 14:10 spaced-out-mvc

there is a way... some calculations needed... $width = trim(system("tput cols")); //get the width of the screen but i guess this guy has abandoned this awesome project

pulketo avatar Aug 20 '22 16:08 pulketo

I've added this functionality to my fork of the project ( https://github.com/conrad10781/clitable/commit/9b68c09ad77694bcfc2061dc85f6d7e7c54c33bd )

You can either merge into your fork, or use my fork.

Only update that's needed is a change of your initialization of CliTable. There is now a third parameter to center the table, which is false by default, so not to break any existing installs. I also have a fix to #6 if you were doing that which currently has a PR on this project. If that gets merged, I'll submit a PR for the table centering and you won't need my project.

In any event, if you previously used something like:

$table = new CliTable;

It will now need to be something like the following. Most important part is the 3rd parameter, which needs to be true to center.

$table = new CliTable('Row', true, true);

One other key point, in my usage of the library, I have occasionally created tables larger than the width of my screen. If that's the case, it doesn't matter whether or not you pass "true", the value will be ignored unless there is available space to center.

conrad10781 avatar Sep 01 '23 15:09 conrad10781