Example #1
0
function phpterm_demo()
{
    echo 'Test basic colors:' . "\n";
    tcechon('Grey color', 'grey');
    tcecho('Red color', 'red');
    echo "\n";
    echo tc_colored('Green color', 'green') . "\n";
    tcechon('Yellow color', 'yellow');
    tcechon('Blue color', 'blue');
    tcechon('Magenta color', 'magenta');
    tcechon('Cyan color', 'cyan');
    tcechon('White color', 'white');
    echo str_repeat('-', 78) . "\n";
    echo 'Test highlights:' . "\n";
    tcechon('On grey color', 'on_grey');
    tcechon('On red color', 'on_red');
    tcechon('On green color', 'on_green');
    tcechon('On yellow color', 'on_yellow');
    tcechon('On blue color', 'on_blue');
    tcechon('On magenta color', 'on_magenta');
    tcechon('On cyan color', 'on_cyan');
    tcechon('On white color', 'grey', 'on_white');
    echo str_repeat('-', 78) . "\n";
    echo 'Test attributes:' . "\n";
    tcechon('Bold grey color', 'grey', 'bold');
    tcechon('Dark red color', 'red', 'dark');
    tcechon('Underline green color', 'green', 'underline');
    tcechon('Blink yellow color', 'yellow', 'blink');
    tcechon('Reversed blue color', 'blue', 'reverse');
    tcechon('Concealed Magenta color', 'magenta', 'concealed');
    tcechon('Bold underline reverse cyan color', 'cyan', 'bold', 'underline', 'reverse');
    tcechon('Dark blink concealed white color', 'white', array('dark', 'blink', 'concealed'));
    echo str_repeat('-', 78) . "\n";
    echo 'Test mixing:' . "\n";
    tcechon('Underline red on grey color', 'red', 'on_grey', 'underline');
    tcechon('Reversed green on red color', 'green', 'on_red', 'reverse');
}
Example #2
0
/**
 * Helper function that builds an array of all the available text colors,
 * background colors and text attributes and their corresponding terminal codes.
 *
 * @return array
 */
function _tc_get_options()
{
    $options = array_merge(array_combine(array('grey', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'), range(30, 37)), array_combine(array('on_grey', 'on_red', 'on_green', 'on_yellow', 'on_blue', 'on_magenta', 'on_cyan', 'on_white'), range(40, 47)), array_combine(array('bold', 'dark', '', 'underline', 'blink', '', 'reverse', 'concealed'), range(1, 8)));
    unset($options['']);
    return $options;
}
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {
    echo 'Test basic colors:' . "\n";
    tcechon('Grey color', 'grey');
    tcecho('Red color', 'red');
    echo "\n";
    echo tc_colored('Green color', 'green') . "\n";
    tcechon('Yellow color', 'yellow');
    tcechon('Blue color', 'blue');
    tcechon('Magenta color', 'magenta');
    tcechon('Cyan color', 'cyan');
    tcechon('White color', 'white');
    echo str_repeat('-', 78) . "\n";
    echo 'Test highlights:' . "\n";
    tcechon('On grey color', 'on_grey');
    tcechon('On red color', 'on_red');
    tcechon('On green color', 'on_green');
    tcechon('On yellow color', 'on_yellow');
    tcechon('On blue color', 'on_blue');
    tcechon('On magenta color', 'on_magenta');