2017 © Pedro Peláez
 

project colorizer

A php class to manage background color, font color and font style on a CLI. It is compatible with all terminal screens.

image

chrismervyn/colorizer

A php class to manage background color, font color and font style on a CLI. It is compatible with all terminal screens.

  • Saturday, September 10, 2016
  • by chrismervyn
  • Repository
  • 2 Watchers
  • 16 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 20 % Grown

The README.md

Colorizer Awesome Colorizer

The nifty PHP class to add some color to your boring terminal output

This is an example of a dialogue screen generated on BASH terminal screen using Colorizer, (*1)

Example Colorizer Dialogue, (*2)

This is another example of the Colorizer, (*3)

Example Colorizer Dialogue, (*4)

The primary features of this class are in its fluidity and simplicity., (*5)

Example Code

$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)

  • Initialization of the constructor

    The paramters are, (*7)

    1. Screen Width (or any width in terms of number of columns that you want)
    2. The background color (from the list of background colors in the source file)
    3. The foreground color (from the list of background colors in the source file) tput cols is a handy command to count the number of columns
  • Clear

    Clearing the screen, (*8)

  • Add Message

    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)

  • Spit (output)

    Output the final rendition of your masterpiece, (*10)


Some convinience thrown in

  • Colorizer::end()

    This is a static method that terminates the dialogue with a message on screen, (*11)

  • Colorizer::alert()

    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)

  • newLn()

    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)

The Versions

10/09 2016

dev-master

9999999-dev

A php class to manage background color, font color and font style on a CLI. It is compatible with all terminal screens.

  Sources   Download

MIT

by Chris

terminal color shell color face ncurses curses alternative php bash color