Common console adapter codebase

todo Add GNU readline support
link http://en.wikipedia.org/wiki/ANSI_escape_code

 Methods

Reset color to console default.

clear() : void

Clear line at cursor position

clearLine() : void
Inherited

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

Clear console screen

clearScreen() : void
Inherited

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

Prepare a string that will be rendered in color.

colorize(string $string, int $color, null | int $bgColor) : string

Parameters

$string

string

$color

int

$bgColor

nullint

Exceptions

\Zend\Console\Exception\BadMethodCallException

Returns

string

Encode a text to match console encoding

encodeText(string $text) : string
Inherited

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

Parameters

$text

string

Returns

stringthe encoding text

Get charset currently in use by this adapter.

getCharset() : \Zend\Console\Charset\CharsetInterface

getDefaultCharset()

getDefaultCharset() : \Zend\Console\Charset\CharsetInterface

Determine and return current console height.

getHeight() : false | int

Returns

falseint

Determine and return current console width and height.

getSize() : int[]
Inherited

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

Returns

int[]array($width, $height)

Return current console window title.

getTitle() : string
Inherited

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

Returns

string

Determine and return current console width.

getWidth() : int

Returns

int

Hide console cursor

hideCursor() : void

Check if console is UTF-8 compatible

isUtf8() : bool

Returns

bool

Read a single character from the console input

readChar(string | null $mask) : string

Parameters

$mask

stringnull

A list of allowed chars

Returns

string

Read a single line from the console input

readLine(int $maxLength) : string
Inherited

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

Parameters

$maxLength

int

Maximum response length

Returns

string

Reset color to console default.

resetColor() : void

Change current drawing background color

setBgColor(int $bgColor) : void

Parameters

$bgColor

int

Exceptions

\Zend\Console\Exception\BadMethodCallException

Set Console charset to use.

setCharset(\Zend\Console\Charset\CharsetInterface $charset) : void

Change current drawing color.

setColor(int $color) : void

Parameters

$color

int

Exceptions

\Zend\Console\Exception\BadMethodCallException

Set cursor position

setPos(int $x, int $y) : void

Parameters

$x

int

$y

int

Show console cursor

showCursor() : void

Write a chunk of text to console.

write(string $text, null | int $color, null | int $bgColor) : void
Inherited

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

Parameters

$text

string

$color

nullint

$bgColor

nullint

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

writeAt(string $text, int $x, int $y, null | int $color, null | int $bgColor) : void
Inherited

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

Parameters

$text

string

Text to write

$x

int

Console X coordinate (column)

$y

int

Console Y coordinate (row)

$color

nullint

$bgColor

nullint

Write a box at the specified coordinates.

writeBox(int $x1, int $y1, int $x2, int $y2, int $lineStyle, int $fillStyle, int $color, int $bgColor, null | int $fillColor, null | int $fillBgColor) : void
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\AbstractAdapter::writeBox()

Parameters

$x1

int

Top-left corner X coordinate (column)

$y1

int

Top-left corner Y coordinate (row)

$x2

int

Bottom-right corner X coordinate (column)

$y2

int

Bottom-right corner Y coordinate (row)

$lineStyle

int

(optional) Box border style.

$fillStyle

int

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

$color

int

(optional) Foreground color

$bgColor

int

(optional) Background color

$fillColor

nullint

(optional) Foreground color of box fill

$fillBgColor

nullint

(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 | int $color, null | int $bgColor) : void

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

Parameters

$text

string

$color

nullint

$bgColor

nullint

Alias for write()

writeText(string $text, null | int $color, null | int $bgColor) : void
Inherited

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

Parameters

$text

string

$color

nullint

$bgColor

nullint

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

writeTextBlock(string $text, int $width, int | null $height, int $x, int $y, null | int $color, null | int $bgColor) : void
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\AbstractAdapter::writeTextBlock()

Parameters

$text

string

Text to write

$width

int

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

$height

intnull

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

$x

int

Block X coordinate (column)

$y

int

Block Y coordinate (row)

$color

nullint

(optional) Text color

$bgColor

nullint

(optional) Text background color

Exceptions

\Zend\Console\Exception\InvalidArgumentException

Get the final color code and throw exception on error

getColorCode(null | int | \Zend\Console\Color\Xterm256 $color, string $type) : string

Parameters

$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

   

Whether or not mbstring is enabled

$hasMBString : null | bool

 

Last fetched TTY mode

$lastTTYMode : string | null

 

Current cursor X position

$posX : int
Inherited

inherited_from \Zend\Console\Adapter\AbstractAdapter::$$posX
 

Current cursor Y position

$posY : int
Inherited

inherited_from \Zend\Console\Adapter\AbstractAdapter::$$posY

 Constants

 

FILL_BLOCK

FILL_BLOCK 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::FILL_BLOCK
inherited_from \Zend\Console\Adapter\AbstractAdapter::FILL_BLOCK
 

FILL_NONE

FILL_NONE 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::FILL_NONE
inherited_from \Zend\Console\Adapter\AbstractAdapter::FILL_NONE
 

FILL_SHADE_DARK

FILL_SHADE_DARK 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::FILL_SHADE_DARK
inherited_from \Zend\Console\Adapter\AbstractAdapter::FILL_SHADE_DARK
 

FILL_SHADE_LIGHT

FILL_SHADE_LIGHT 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::FILL_SHADE_LIGHT
inherited_from \Zend\Console\Adapter\AbstractAdapter::FILL_SHADE_LIGHT
 

FILL_SHADE_MEDIUM

FILL_SHADE_MEDIUM 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::FILL_SHADE_MEDIUM
inherited_from \Zend\Console\Adapter\AbstractAdapter::FILL_SHADE_MEDIUM
 

LINE_BLOCK

LINE_BLOCK 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::LINE_BLOCK
inherited_from \Zend\Console\Adapter\AbstractAdapter::LINE_BLOCK
 

LINE_DOUBLE

LINE_DOUBLE 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::LINE_DOUBLE
inherited_from \Zend\Console\Adapter\AbstractAdapter::LINE_DOUBLE
 

LINE_NONE

LINE_NONE 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::LINE_NONE
inherited_from \Zend\Console\Adapter\AbstractAdapter::LINE_NONE
 

LINE_SINGLE

LINE_SINGLE 
Inherited

inherited_from \Zend\Console\Adapter\AdapterInterface::LINE_SINGLE
inherited_from \Zend\Console\Adapter\AbstractAdapter::LINE_SINGLE