Zend Framework  3.0
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
AbstractAdapter Class Reference

Common console adapter codebase. More...

Public Member Functions

 write ($text, $color=null, $bgColor=null)
 Write a chunk of text to console.
 
 writeText ($text, $color=null, $bgColor=null)
 Alias for write()
 
 writeLine ($text="", $color=null, $bgColor=null)
 Write a single line of text to console and advance cursor to the next line.
 
 writeAt ($text, $x, $y, $color=null, $bgColor=null)
 Write a piece of text at the coordinates of $x and $y.
 
 writeBox ($x1, $y1, $x2, $y2, $lineStyle=self::LINE_SINGLE, $fillStyle=self::FILL_NONE, $color=null, $bgColor=null, $fillColor=null, $fillBgColor=null)
 Write a box at the specified coordinates.
 
 writeTextBlock ($text, $width, $height=null, $x=0, $y=0, $color=null, $bgColor=null)
 Write a block of text at the given coordinates, matching the supplied width and height.
 
 getWidth ()
 Determine and return current console width.
 
 getHeight ()
 Determine and return current console height.
 
 getSize ()
 Determine and return current console width and height.
 
 isUtf8 ()
 Check if console is UTF-8 compatible.
 
 setPos ($x, $y)
 Set cursor position.
 
 showCursor ()
 Show console cursor.
 
 hideCursor ()
 Hide console cursor.
 
 getTitle ()
 Return current console window title.
 
 colorize ($string, $color=null, $bgColor=null)
 Prepare a string that will be rendered in color.
 
 setColor ($color)
 Change current drawing color.
 
 setBgColor ($color)
 Change current drawing background color.
 
 resetColor ()
 Reset color to console default.
 
 setCharset (Charset\CharsetInterface $charset)
 Set Console charset to use.
 
 getCharset ()
 Get charset currently in use by this adapter.
 
 getDefaultCharset ()
 
 clear ()
 Clear console screen.
 
 clearLine ()
 Clear line at cursor position.
 
 clearScreen ()
 Clear console screen.
 
 readLine ($maxLength=2048)
 Read a single line from the console input.
 
 readChar ($mask=null)
 Read a single character from the console input.
 
 encodeText ($text)
 Encode a text to match console encoding.
 
- Public Member Functions inherited from AdapterInterface
 setCharset (CharsetInterface $charset)
 Set Console charset to use.
 

Protected Attributes

 $charset
 
 $posX
 
 $posY
 

Static Protected Attributes

static $hasMBString
 

Additional Inherited Members

- Public Attributes inherited from AdapterInterface
const LINE_NONE = 1
 
const LINE_SINGLE = 2
 
const LINE_DOUBLE = 3
 
const LINE_BLOCK = 4
 
const FILL_NONE = 0
 
const FILL_SHADE_LIGHT = 1
 
const FILL_SHADE_MEDIUM = 2
 
const FILL_SHADE_DARK = 3
 
const FILL_BLOCK = 10
 

Detailed Description

Common console adapter codebase.

Member Function Documentation

clear ( )

Clear console screen.

Implements AdapterInterface.

clearLine ( )

Clear line at cursor position.

Implements AdapterInterface.

clearScreen ( )

Clear console screen.

Implements AdapterInterface.

colorize (   $string,
  $color = null,
  $bgColor = null 
)

Prepare a string that will be rendered in color.

Parameters
string$string
int$color
null | int$bgColor
Returns
string

Implements AdapterInterface.

encodeText (   $text)

Encode a text to match console encoding.

Parameters
string$text
Returns
string the encoding text
getCharset ( )

Get charset currently in use by this adapter.

Returns
Charset $charset

Implements AdapterInterface.

getDefaultCharset ( )
Returns
Charset

Implements AdapterInterface.

getHeight ( )

Determine and return current console height.

Returns
int

Implements AdapterInterface.

getSize ( )

Determine and return current console width and height.

Returns
int[] array($width, $height)

Implements AdapterInterface.

getTitle ( )

Return current console window title.

Returns
string

Implements AdapterInterface.

getWidth ( )

Determine and return current console width.

Returns
int

Implements AdapterInterface.

hideCursor ( )

Hide console cursor.

Implements AdapterInterface.

isUtf8 ( )

Check if console is UTF-8 compatible.

Returns
bool

Implements AdapterInterface.

readChar (   $mask = null)

Read a single character from the console input.

Parameters
string | null$maskA list of allowed chars
Returns
string

Implements AdapterInterface.

readLine (   $maxLength = 2048)

Read a single line from the console input.

Parameters
int$maxLengthMaximum response length
Returns
string

Implements AdapterInterface.

resetColor ( )

Reset color to console default.

Implements AdapterInterface.

setBgColor (   $color)

Change current drawing background color.

Parameters
int$color

Implements AdapterInterface.

setCharset ( Charset\CharsetInterface  $charset)

Set Console charset to use.

Parameters
Charset\CharsetInterface$charset
setColor (   $color)

Change current drawing color.

Parameters
int$color

Implements AdapterInterface.

setPos (   $x,
  $y 
)

Set cursor position.

Parameters
int$x
int$y

Implements AdapterInterface.

showCursor ( )

Show console cursor.

Implements AdapterInterface.

write (   $text,
  $color = null,
  $bgColor = null 
)

Write a chunk of text to console.

Parameters
string$text
null | int$color
null | int$bgColor

Implements AdapterInterface.

writeAt (   $text,
  $x,
  $y,
  $color = null,
  $bgColor = null 
)

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

Parameters
string$textText to write
int$xConsole X coordinate (column)
int$yConsole Y coordinate (row)
null | int$color
null | int$bgColor

Implements AdapterInterface.

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

Write a box at the specified coordinates.

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).

Parameters
int$x1Top-left corner X coordinate (column)
int$y1Top-left corner Y coordinate (row)
int$x2Bottom-right corner X coordinate (column)
int$y2Bottom-right corner Y coordinate (row)
int$lineStyle(optional) Box border style.
int$fillStyle(optional) Box fill style or a single character to fill it with.
int$color(optional) Foreground color
int$bgColor(optional) Background color
null | int$fillColor(optional) Foreground color of box fill
null | int$fillBgColor(optional) Background color of box fill
Exceptions
Exception\BadMethodCallExceptionif coordinates are invalid

Implements AdapterInterface.

writeLine (   $text = "",
  $color = null,
  $bgColor = null 
)

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

Parameters
string$text
null | int$color
null | int$bgColor

Implements AdapterInterface.

writeText (   $text,
  $color = null,
  $bgColor = null 
)

Alias for write()

Parameters
string$text
null | int$color
null | int$bgColor

Implements AdapterInterface.

writeTextBlock (   $text,
  $width,
  $height = null,
  $x = 0,
  $y = 0,
  $color = null,
  $bgColor = null 
)

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

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.

Parameters
string$textText to write
int$widthMaximum block width. Negative value means distance from right edge.
int | null$heightMaximum block height. Negative value means distance from bottom edge.
int$xBlock X coordinate (column)
int$yBlock Y coordinate (row)
null | int$color(optional) Text color
null | int$bgColor(optional) Text background color
Exceptions
Exception\InvalidArgumentException

Implements AdapterInterface.

Member Data Documentation

$charset
protected
$hasMBString
staticprotected
$posX
protected
$posY
protected