3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Console\Adapter
;
12 use Zend\Console\Charset\CharsetInterface
;
14 interface AdapterInterface
17 const LINE_SINGLE
= 2;
18 const LINE_DOUBLE
= 3;
21 const FILL_SHADE_LIGHT
= 1;
22 const FILL_SHADE_MEDIUM
= 2;
23 const FILL_SHADE_DARK
= 3;
24 const FILL_BLOCK
= 10;
27 * Write a chunk of text to console.
30 * @param null|int $color
31 * @param null|int $bgColor
34 public function write($text, $color = null, $bgColor = null);
40 * @param null|int $color
41 * @param null|int $bgColor
44 public function writeText($text, $color = null, $bgColor = null);
47 * Write a single line of text to console and advance cursor to the next line.
48 * If the text is longer than console width it will be truncated.
51 * @param null|int $color
52 * @param null|int $bgColor
55 public function writeLine($text = "", $color = null, $bgColor = null);
58 * Write a piece of text at the coordinates of $x and $y
60 * @param string $text Text to write
61 * @param int $x Console X coordinate (column)
62 * @param int $y Console Y coordinate (row)
63 * @param null|int $color
64 * @param null|int $bgColor
67 public function writeAt($text, $x, $y, $color = null, $bgColor = null);
70 * Write a box at the specified coordinates.
71 * If X or Y coordinate value is negative, it will be calculated as the distance from far right or bottom edge
72 * of the console (respectively).
74 * @param int $x1 Top-left corner X coordinate (column)
75 * @param int $y1 Top-left corner Y coordinate (row)
76 * @param int $x2 Bottom-right corner X coordinate (column)
77 * @param int $y2 Bottom-right corner Y coordinate (row)
78 * @param int $lineStyle (optional) Box border style.
79 * @param int $fillStyle (optional) Box fill style or a single character to fill it with.
80 * @param int $color (optional) Foreground color
81 * @param int $bgColor (optional) Background color
82 * @param null|int $fillColor (optional) Foreground color of box fill
83 * @param null|int $fillBgColor (optional) Background color of box fill
86 public function writeBox(
91 $lineStyle = self
::LINE_SINGLE
,
92 $fillStyle = self
::FILL_NONE
,
100 * Write a block of text at the given coordinates, matching the supplied width and height.
101 * In case a line of text does not fit desired width, it will be wrapped to the next line.
102 * In case the whole text does not fit in desired height, it will be truncated.
104 * @param string $text Text to write
105 * @param int $width Maximum block width. Negative value means distance from right edge.
106 * @param int|null $height Maximum block height. Negative value means distance from bottom edge.
107 * @param int $x Block X coordinate (column)
108 * @param int $y Block Y coordinate (row)
109 * @param null|int $color (optional) Text color
110 * @param null|int $bgColor (optional) Text background color
113 public function writeTextBlock(
124 * Determine and return current console width.
128 public function getWidth();
131 * Determine and return current console height.
135 public function getHeight();
138 * Determine and return current console width and height.
140 * @return array array($width, $height)
142 public function getSize();
145 * Check if console is UTF-8 compatible
149 public function isUtf8();
152 * Set cursor position
158 public function setPos($x, $y);
161 * Hide console cursor
164 public function hideCursor();
167 * Show console cursor
170 public function showCursor();
173 * Return current console window title.
177 public function getTitle();
180 * Prepare a string that will be rendered in color.
182 * @param string $string
183 * @param null|int $color Foreground color
184 * @param null|int $bgColor Background color
187 public function colorize($string, $color = null, $bgColor = null);
190 * Change current drawing color.
195 public function setColor($color);
198 * Change current drawing background color
203 public function setBgColor($color);
206 * Reset color to console default.
209 public function resetColor();
212 * Set Console charset to use.
214 * @param CharsetInterface $charset
217 public function setCharset(CharsetInterface
$charset);
220 * Get charset currently in use by this adapter.
222 * @return CharsetInterface $charset
224 public function getCharset();
227 * @return CharsetInterface
229 public function getDefaultCharset();
232 * Clear console screen
235 public function clear();
238 * Clear line at cursor position
241 public function clearLine();
244 * Clear console screen
247 public function clearScreen();
250 * Read a single line from the console input
252 * @param int $maxLength Maximum response length
255 public function readLine($maxLength = 2048);
258 * Read a single character from the console input
260 * @param string|null $mask A list of allowed chars
263 public function readChar($mask = null);