Download the PHP package testomat/terminal-colour without Composer
On this page you can find all versions of the php package testomat/terminal-colour. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download testomat/terminal-colour
More information about testomat/terminal-colour
Files in testomat/terminal-colour
Package terminal-colour
Short Description Return your terminal message in style! Change the text style, text color and text background color from the terminal, console or shell interface with ANSI color codes.
License MIT
Homepage http://github.com/testomat/terminal-colour
Informations about the package terminal-colour
Terminal color
- The easiest way to style your text in the command line / terminal
- Change text color to red, green, yellow ...
- Change background color to red, green, yellow ...
- Change text style to bold, dim, underlined, blink ...
- Has support for 0 , 16, 256 and true color ...
Installation
Run
Note : By default, the Windows command console doesn’t support output coloring. This library disables output coloring for Windows systems. But if your commands or scripts invoke other scripts which emit color sequences, they will be wrongly displayed as raw escape characters. Install the Cmder, ConEmu, ANSICON or Mintty (used by default in GitBash and Cygwin) to add coloring support to your Windows command console.
Usage
Using Color Styles
The closing tag can be replaced by </>
, which revokes all formatting options established by the last opened tag.
It’s possible to define your own styles using the Formatter class:
Available foreground and background colors are black, red, green, yellow, blue, magenta, cyan, white, default, dark_grey, light_grey, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, light_white
.
And available options are: none, bold, dark, italic, underscore, blink, blink_fast, crossed_out, double_underline, curly_underline, overlinem, reverse
(enables the "reverse video" mode where the background and foreground colors are swapped) and conceal
(sets the foreground color to transparent, making the typed text invisible—although it can be selected and copied; this option is commonly used when asking the user to type sensitive information).
You want to use 256 colors
or true colors
than you must use the StyleCode
class.
You can also set these colors and options directly inside the tag name:
Note: if you need to render a tag literally, escape it with a backslash: \
or use the escape() method to escape all the tags included in the given string.
You have the possibility with formatAndWrap(string $message, int $width)
function to wrap you text to a specific width, 0 means no wrapping.
Note: you want to check the color support for you terminal check the example folder out.
Displaying Clickable Links
Commands can use the special <href>
tag to display links like the <a>
elements of web pages:
If your terminal belongs to the list of terminal emulators that support links you can click on the "Narrowspark Homepage" text to open its URL in your default browser. Otherwise, you’ll see "Narrowspark Homepage" as regular text and the URL will be lost.
Terminal Util
You want to know, what color or how any columns your terminal supports, than you can call:
Links
Hyperlinks (a.k.a. HTML-like anchors) in terminal emulators
Versioning
This library follows semantic versioning, and additions to the code ruleset are performed in major releases.
Changelog
Please have a look at CHANGELOG.md
.
Contributing
Please have a look at CONTRIBUTING.md
.
Code of Conduct
Please have a look at CODE_OF_CONDUCT.md
.
License
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.