A php class to manage background color, font color and font style on a CLI. It is compatible with all terminal screens.
This is an example of a dialogue screen generated on BASH terminal screen using
Colorizer
, (*1), (*2)
This is another example of the
Colorizer
, (*3), (*4)
The primary features of this class are in its fluidity and simplicity., (*5)
$colorizer = new Colorizer(`tput cols`,"green", "white"); $colorizer->clear(); $colorizer->addMessage("Welcome to the [u]Colorizer Example[/u]")->newLn(); $colorizer->spit();
Simple. While this code is pretty self-explanatory, yet I would go ahead make it more sensible., (*6)
The paramters are, (*7)
tput cols
is a handy command to count the number of columns
Clearing the screen, (*8)
Add a line of text or two. Since, this is a fluid interface, you can chain together multiple methods or the same method multiple times, (*9)
Output the final rendition of your masterpiece, (*10)
This is a static method that terminates the dialogue with a message on screen, (*11)
Another static method that acts as a pop-up, well sort of. It displays your message for 2 seconds and then relinquishes control back to your script, (*12)
This is a public function that simply adds a new line to the end of your message, (*13)
There is an Example.php
file with this project. Do be sure to run it on your terminal and see almost all the features being used in that file., (*14)
Alright then, happy CLI-fying everything!, (*15)