Common console adapter codebase

todo Add GNU readline support
link http://en.wikipedia.org/wiki/ANSI_escape_code
package Default
inherited_from \Zend\Console\Adapter\AbstractAdapter

 Methods

Reset color to console default.

clear() 
inherited_from \Zend\Console\Adapter\AbstractAdapter::clear()

Clear console screen

clear() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::clear()

Clear line at cursor position

clearLine() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::clearLine()

Clear console screen

clearScreen() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::clearScreen()

Prepare a string that will be rendered in color.

colorize(string $string, integer $color = null, null|integer $bgColor = null) : string
inherited_from \Zend\Console\Adapter\AbstractAdapter::colorize()

Parameters

$string

string

$color

integer

$bgColor

nullinteger

Exceptions

\Zend\Console\Exception\BadMethodCallException

Returns

string

Prepare a string that will be rendered in color.

colorize(string $string, integer $color = null, null|integer $bgColor = null) : string
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::colorize()

Parameters

$string

string

$color

integer

$bgColor

nullinteger

Returns

string

Encode a text to match console encoding

encodeText(string $text) : string
Inherited

Parameters

$text

string

Returns

stringthe encoding text

Get charset currently in use by this adapter.

getCharset() : \Zend\Console\Charset\CharsetInterface
inherited_from \Zend\Console\Adapter\AbstractAdapter::getCharset()

Returns

\Zend\Console\Charset\CharsetInterface$charset

Get charset currently in use by this adapter.

getCharset() : \Zend\Console\Charset\CharsetInterface
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getCharset()

Returns

\Zend\Console\Charset\CharsetInterface$charset

getDefaultCharset()

getDefaultCharset() : \Zend\Console\Charset\CharsetInterface
inherited_from \Zend\Console\Adapter\AbstractAdapter::getDefaultCharset()

Returns

\Zend\Console\Charset\CharsetInterface

getDefaultCharset()

getDefaultCharset() : \Zend\Console\Charset\Utf8
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getDefaultCharset()

Returns

\Zend\Console\Charset\Utf8

Determine and return current console height.

getHeight() : false | integer
inherited_from \Zend\Console\Adapter\AbstractAdapter::getHeight()

Returns

falseinteger

Determine and return current console height.

getHeight() : integer
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getHeight()

Returns

integer

Determine and return current console width and height.

getSize() : array<mixed,integer>
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getSize()

Returns

array<mixed,integer>array($width, $height)

Return current console window title.

getTitle() : string
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getTitle()

Returns

string

Determine and return current console width.

getWidth() : integer
inherited_from \Zend\Console\Adapter\AbstractAdapter::getWidth()

Returns

integer

Determine and return current console width.

getWidth() : integer
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::getWidth()

Returns

integer

Hide console cursor

hideCursor() 
inherited_from \Zend\Console\Adapter\AbstractAdapter::hideCursor()

Hide console cursor

hideCursor() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::hideCursor()

Check if console is UTF-8 compatible

isUtf8() : boolean
inherited_from \Zend\Console\Adapter\AbstractAdapter::isUtf8()

Returns

boolean

Check if console is UTF-8 compatible

isUtf8() : boolean
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::isUtf8()

Returns

boolean

Read a single character from the console input

readChar(string|null $mask = null) : string
inherited_from \Zend\Console\Adapter\AbstractAdapter::readChar()

Parameters

$mask

stringnull

A list of allowed chars

Returns

string

Read a single character from the console input

readChar(string|null $mask = null) : string
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::readChar()

Parameters

$mask

stringnull

A list of allowed chars

Returns

string

Read a single line from the console input

readLine(integer $maxLength = 2048) : string
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::readLine()

Parameters

$maxLength

integer

Maximum response length

Returns

string

Reset color to console default.

resetColor() 
inherited_from \Zend\Console\Adapter\AbstractAdapter::resetColor()

Reset color to console default.

resetColor() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::resetColor()

Change current drawing background color

setBgColor(integer $bgColor) 
inherited_from \Zend\Console\Adapter\AbstractAdapter::setBgColor()

Parameters

$bgColor

integer

Exceptions

\Zend\Console\Exception\BadMethodCallException

Change current drawing background color

setBgColor(integer $color) 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::setBgColor()

Parameters

$color

integer

Set Console charset to use.

setCharset(\Zend\Console\Charset\CharsetInterface $charset) 
inherited_from \Zend\Console\Adapter\AbstractAdapter::setCharset()

Parameters

$charset

\Zend\Console\Charset\CharsetInterface

Set Console charset to use.

setCharset(\Zend\Console\Charset\CharsetInterface $charset) 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::setCharset()

Parameters

$charset

\Zend\Console\Charset\CharsetInterface

Change current drawing color.

setColor(integer $color) 
inherited_from \Zend\Console\Adapter\AbstractAdapter::setColor()

Parameters

$color

integer

Exceptions

\Zend\Console\Exception\BadMethodCallException

Change current drawing color.

setColor(integer $color) 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::setColor()

Parameters

$color

integer

Set cursor position

setPos(integer $x, integer $y) 
inherited_from \Zend\Console\Adapter\AbstractAdapter::setPos()

Parameters

$x

integer

$y

integer

Set cursor position

setPos(integer $x, integer $y) 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::setPos()

Parameters

$x

integer

$y

integer

Show console cursor

showCursor() 
inherited_from \Zend\Console\Adapter\AbstractAdapter::showCursor()

Show console cursor

showCursor() 
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::showCursor()

Write a chunk of text to console.

write(string $text, null|integer $color = null, null|integer $bgColor = null
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::write()

Parameters

$text

string

$color

nullinteger

$bgColor

nullinteger

Write a piece of text at the coordinates of $x and $y

writeAt(string $text, integer $x, integer $y, null|integer $color = null, null|integer $bgColor = null
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::writeAt()

Parameters

$text

string

Text to write

$x

integer

Console X coordinate (column)

$y

integer

Console Y coordinate (row)

$color

nullinteger

$bgColor

nullinteger

Write a box at the specified coordinates.

writeBox(integer $x1, integer $y1, integer $x2, integer $y2, integer $lineStyle = self::LINE_SINGLE, integer $fillStyle = self::FILL_NONE, integer $color = null, integer $bgColor = null, null|integer $fillColor = null, null|integer $fillBgColor = null
Inherited

If X or Y coordinate value is negative, it will be calculated as the distance from far right or bottom edge of the console (respectively).

inherited_from \Zend\Console\Adapter\AdapterInterface::writeBox()

Parameters

$x1

integer

Top-left corner X coordinate (column)

$y1

integer

Top-left corner Y coordinate (row)

$x2

integer

Bottom-right corner X coordinate (column)

$y2

integer

Bottom-right corner Y coordinate (row)

$lineStyle

integer

(optional) Box border style.

$fillStyle

integer

(optional) Box fill style or a single character to fill it with.

$color

integer

(optional) Foreground color

$bgColor

integer

(optional) Background color

$fillColor

nullinteger

(optional) Foreground color of box fill

$fillBgColor

nullinteger

(optional) Background color of box fill

Exceptions

\Zend\Console\Exception\BadMethodCallException if coordinates are invalid

Write a single line of text to console and advance cursor to the next line.

writeLine(string $text = "", null|integer $color = null, null|integer $bgColor = null

This override works around a bug in some terminals that cause the background color to fill the next line after EOL. To remedy this, we are sending the colored string with appropriate color reset sequences before sending EOL character.

link https://github.com/zendframework/zf2/issues/4167
inherited_from \Zend\Console\Adapter\AbstractAdapter::writeLine()

Parameters

$text

string

$color

nullinteger

$bgColor

nullinteger

Write a single line of text to console and advance cursor to the next line.

writeLine(string $text = "", null|integer $color = null, null|integer $bgColor = null
Inherited

If the text is longer than console width it will be truncated.

inherited_from \Zend\Console\Adapter\AdapterInterface::writeLine()

Parameters

$text

string

$color

nullinteger

$bgColor

nullinteger

Alias for write()

writeText(string $text, null|integer $color = null, null|integer $bgColor = null
Inherited
inherited_from \Zend\Console\Adapter\AdapterInterface::writeText()

Parameters

$text

string

$color

nullinteger

$bgColor

nullinteger

Write a block of text at the given coordinates, matching the supplied width and height.

writeTextBlock(string $text, integer $width, integer|null $height = null, integer $x = 0, integer $y = 0, null|integer $color = null, null|integer $bgColor = null
Inherited

In case a line of text does not fit desired width, it will be wrapped to the next line. In case the whole text does not fit in desired height, it will be truncated.

inherited_from \Zend\Console\Adapter\AdapterInterface::writeTextBlock()

Parameters

$text

string

Text to write

$width

integer

Maximum block width. Negative value means distance from right edge.

$height

integernull

Maximum block height. Negative value means distance from bottom edge.

$x

integer

Block X coordinate (column)

$y

integer

Block Y coordinate (row)

$color

nullinteger

(optional) Text color

$bgColor

nullinteger

(optional) Text background color

Exceptions

\Zend\Console\Exception\InvalidArgumentException

Get the final color code and throw exception on error

getColorCode(null|integer|\Zend\Console\Color\Xterm256 $color, string $type = 'fg') : string

Parameters

$color

nullinteger\Zend\Console\Color\Xterm256

$type

string

(optional) Foreground 'fg' or background 'bg'.

Exceptions

\Zend\Console\Exception\BadMethodCallException

Returns

string

Restore TTY (Console) mode to previous value.

restoreTTYMode() : void

Run a mode command and store results

runModeCommand() : void

Change TTY (Console) mode

setTTYMode(string $mode) 
link http://en.wikipedia.org/wiki/Stty

Parameters

$mode

string

 Properties

 

Map of colors to ANSI codes

$ansiColorMap : array

Default

array('fg' => array(\Zend\Console\ColorInterface::NORMAL => '22;39', \Zend\Console\ColorInterface::RESET => '22;39', \Zend\Console\ColorInterface::BLACK => '0;30', \Zend\Console\ColorInterface::RED => '0;31', \Zend\Console\ColorInterface::GREEN => '0;32', \Zend\Console\ColorInterface::YELLOW => '0;33', \Zend\Console\ColorInterface::BLUE => '0;34', \Zend\Console\ColorInterface::MAGENTA => '0;35', \Zend\Console\ColorInterface::CYAN => '0;36', \Zend\Console\ColorInterface::WHITE => '0;37', \Zend\Console\ColorInterface::GRAY => '1;30', \Zend\Console\ColorInterface::LIGHT_RED => '1;31', \Zend\Console\ColorInterface::LIGHT_GREEN => '1;32', \Zend\Console\ColorInterface::LIGHT_YELLOW => '1;33', \Zend\Console\ColorInterface::LIGHT_BLUE => '1;34', \Zend\Console\ColorInterface::LIGHT_MAGENTA => '1;35', \Zend\Console\ColorInterface::LIGHT_CYAN => '1;36', \Zend\Console\ColorInterface::LIGHT_WHITE => '1;37'), 'bg' => array(\Zend\Console\ColorInterface::NORMAL => '0;49', \Zend\Console\ColorInterface::RESET => '0;49', \Zend\Console\ColorInterface::BLACK => '40', \Zend\Console\ColorInterface::RED => '41', \Zend\Console\ColorInterface::GREEN => '42', \Zend\Console\ColorInterface::YELLOW => '43', \Zend\Console\ColorInterface::BLUE => '44', \Zend\Console\ColorInterface::MAGENTA => '45', \Zend\Console\ColorInterface::CYAN => '46', \Zend\Console\ColorInterface::WHITE => '47', \Zend\Console\ColorInterface::GRAY => '40', \Zend\Console\ColorInterface::LIGHT_RED => '41', \Zend\Console\ColorInterface::LIGHT_GREEN => '42', \Zend\Console\ColorInterface::LIGHT_YELLOW => '43', \Zend\Console\ColorInterface::LIGHT_BLUE => '44', \Zend\Console\ColorInterface::LIGHT_MAGENTA => '45', \Zend\Console\ColorInterface::LIGHT_CYAN => '46', \Zend\Console\ColorInterface::LIGHT_WHITE => '47'))
Static
 

$charset

$charset : \Zend\Console\Charset\CharsetInterface

Default

inherited_from \Zend\Console\Adapter\AbstractAdapter::charset
 

$charset

$charset : \Zend\Console\Charset\CharsetInterface

Default

 

Whether or not mbstring is enabled

$hasMBString : null | boolean

Default

Static
inherited_from \Zend\Console\Adapter\AbstractAdapter::hasMBString
 

Whether or not mbstring is enabled

$hasMBString : null | boolean

Default

Static
 

Last fetched TTY mode

$lastTTYMode : string | null

Default

null
 

Current cursor X position

$posX : integer

Default

 

Current cursor Y position

$posY : integer

Default