Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Table Alignment - Middle of Screen #5

Open
spaced-out-mvc opened this issue Oct 24, 2021 · 2 comments
Open

Table Alignment - Middle of Screen #5

spaced-out-mvc opened this issue Oct 24, 2021 · 2 comments

Comments

@spaced-out-mvc
Copy link

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

@pulketo
Copy link

pulketo commented Aug 20, 2022

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

conrad10781 added a commit to conrad10781/clitable that referenced this issue Sep 1, 2023
@conrad10781
Copy link
Contributor

I've added this functionality to my fork of the project ( conrad10781@9b68c09 )

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants