2017 © Pedro Peláez
 

library terminal

Terminal control

image

xp-forge/terminal

Terminal control

  • Monday, April 2, 2018
  • by thekid
  • Repository
  • 2 Watchers
  • 0 Stars
  • 932 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 9 % Grown

The README.md

Terminal

Build Status on TravisCI XP Framework Module BSD Licence Supports PHP 7.0+ Latest Stable Version, (*1)

The terminal library adds support for color to the util.cmd.Console class., (*2)

Screenshot, (*3)

Styles

There are five predefined styles:, (*4)

use util\cmd\Console;

Console::writeLine('This is <primary>primary</>!');
Console::writeLine('This is <success>success</>!');
Console::writeLine('This is <info>info</>!');
Console::writeLine('This is <warning>warning</>!');
Console::writeLine('This is <danger>danger</>!');

Colors

For direct color control, the colors can be chosen directly by supplying their names. Foreground and background colors are separated by the @ sign:, (*5)

use util\cmd\Console;

Console::writeLine('<red>An error occured</>');
Console::writeLine('<white@green>OK: 100 Tests succeeded</>');

The colors' names are black, dark-red, dark-green, dark-yellow, dark-blue, dark-magenta, dark-cyan, gray, dark-gray, red, green, yellow, blue, magenta, cyan and white., (*6)

Attributes

There are three more attributes. Not all terminals support these, though!, (*7)

use util\cmd\Console;

Console::writeLine('<underline>http://localhost</>');
Console::writeLine('<bold>Watch out!</>');
Console::writeLine('<italic>- The XP Framework group</>');

// Can be combined, too
Console::writeLine('<dark-blue,underline>http://localhost</>');

Positioning

The util.cmd.term.Terminal class allows clearing the screen, positioning the cursor and writing text there., (*8)

Screenshot, (*9)

use util\cmd\term\Terminal;

$message= 'Hello from the middle of the screen';

// Center text in third line
$dim= Terminal::size();
$x= ($dim[0] - strlen($message)) / 2;
$y= 3;

Terminal::clear();
Terminal::write($x, $y, $message);

For the more advanced example seen above in the screenshot, have a look at this code., (*10)

The Versions

02/04 2018

dev-master

9999999-dev http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

02/04 2018

v0.6.0

0.6.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

04/09 2016

v0.5.0

0.5.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

04/09 2016

v0.4.0

0.4.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

05/07 2016

v0.3.0

0.3.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

20/06 2016

v0.2.0

0.2.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

19/06 2016

v0.1.0

0.1.0.0 http://xp-framework.net/

Terminal control

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp