This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/console' of https://github.com/Thinkscape/zf2 i…
…nto feature/console Conflicts: documentation/manual/en/module_specs/Zend_Mvc-Intro.xml documentation/manual/en/module_specs/Zend_Mvc-Services.xml documentation/manual/en/module_specs/zend.view.quick-start.xml library/Zend/Mvc/Service/ModuleManagerFactory.php library/Zend/Text/Table/Table.php
- Loading branch information
66 parents
3b4ec35
+
e53a267
+
51bf3c7
+
10a1e95
+
30ee303
+
96417b9
+
50ea13f
+
24d1c0c
+
b09295e
+
13758aa
+
99316f8
+
40b8ac3
+
e284e0b
+
8ff51b4
+
4b5ea1e
+
5b24371
+
ed932b6
+
357852d
+
262e5d6
+
9057a3f
+
0e1e846
+
5d11876
+
0ae0984
+
6ff135c
+
0b45aba
+
1778b0c
+
a574713
+
ba3f132
+
56365a6
+
019f89a
+
b09b3ba
+
2af32d0
+
cb39fc7
+
3f8a6fd
+
8999753
+
a7cd86b
+
da1c469
+
5371cdb
+
fd9f625
+
99d3fcd
+
1e3ed17
+
a360459
+
1a1e9aa
+
4c8955c
+
94f2feb
+
5b450ef
+
e64e5b0
+
e9d19a6
+
a5a9b6e
+
5e59c3a
+
a47f2db
+
3cf915a
+
a2a5c91
+
1cd3439
+
ef9c643
+
298a619
+
001ae99
+
c37ab8e
+
017f6f1
+
0711f77
+
38af804
+
23120b4
+
5f96f53
+
a257169
+
8085bc4
+
1578526
commit 712223d
Showing
28 changed files
with
3,736 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Console | ||
*/ | ||
|
||
namespace Zend\Console\Adapter; | ||
|
||
use Zend\Console\AdapterInterface; | ||
use Zend\Console\ColorInterface; | ||
use Zend\Console\CharsetInterface; | ||
use Zend\Console; | ||
|
||
/** | ||
* Virtual buffer adapter | ||
* | ||
* @category Zend | ||
* @package Zend_Console | ||
* @subpackage Adapter | ||
*/ | ||
class Virtual extends AbstractAdapter implements AdapterInterface | ||
{ | ||
protected static $hasMBString; | ||
|
||
protected $modeResult; | ||
|
||
/** | ||
* Determine and return current console width. | ||
* | ||
* @return int | ||
*/ | ||
public function getWidth() | ||
{ | ||
static $width; | ||
if ($width > 0) { | ||
return $width; | ||
} | ||
|
||
/** | ||
* Try to read console size from "mode" command | ||
*/ | ||
if ($this->modeResult === null) { | ||
$this->runProbeCommand(); | ||
} | ||
|
||
if (preg_match('/Columns\:\s+(\d+)/',$this->modeResult,$matches)) { | ||
$width = $matches[1]; | ||
} else { | ||
$width = parent::getWidth(); | ||
} | ||
|
||
return $width; | ||
} | ||
|
||
/** | ||
* Determine and return current console height. | ||
* | ||
* @return false|int | ||
*/ | ||
public function getHeight() | ||
{ | ||
static $height; | ||
if ($height > 0) { | ||
return $height; | ||
} | ||
|
||
/** | ||
* Try to read console size from "mode" command | ||
*/ | ||
if ($this->modeResult === null) { | ||
$this->runProbeCommand(); | ||
} | ||
|
||
if (preg_match('/Rows\:\s+(\d+)/',$this->modeResult,$matches)) { | ||
$height = $matches[1]; | ||
} else { | ||
$height = parent::getHeight(); | ||
} | ||
|
||
return $height; | ||
} | ||
|
||
protected function runProbeCommand() | ||
{ | ||
exec('mode',$output,$return); | ||
if ($return || !count($output)) { | ||
$this->modeResult = ''; | ||
} else { | ||
$this->modeResult = trim(implode('',$output)); | ||
} | ||
} | ||
|
||
/** | ||
* Check if console is UTF-8 compatible | ||
* | ||
* @return bool | ||
*/ | ||
public function isUtf8() | ||
{ | ||
/** | ||
* Try to read code page info from "mode" command | ||
*/ | ||
if ($this->modeResult === null) { | ||
$this->runProbeCommand(); | ||
} | ||
|
||
if (preg_match('/Code page\:\s+(\d+)/',$this->modeResult,$matches)) { | ||
return (int)$matches[1] == 65001; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Set cursor position | ||
* @param int $x | ||
* @param int $y | ||
*/ | ||
public function setPos($x, $y) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Return current console window title. | ||
* | ||
* @return string | ||
*/ | ||
public function getTitle() | ||
{ | ||
/** | ||
* Try to use powershell to retrieve console window title | ||
*/ | ||
exec('powershell -command "write $Host.UI.RawUI.WindowTitle"',$output,$result); | ||
if ($result || !$output) { | ||
return ''; | ||
} | ||
|
||
return trim($output,"\r\n"); | ||
} | ||
|
||
/** | ||
* Set Console charset to use. | ||
* | ||
* @param \Zend\Console\CharsetInterface $charset | ||
*/ | ||
public function setCharset(CharsetInterface $charset) | ||
{ | ||
$this->charset = $charset; | ||
} | ||
|
||
/** | ||
* Get charset currently in use by this adapter. | ||
* | ||
* @return \Zend\Console\CharsetInterface $charset | ||
*/ | ||
public function getCharset() | ||
{ | ||
if ($this->charset === null) { | ||
$this->charset = $this->getDefaultCharset(); | ||
} | ||
|
||
return $this->charset; | ||
} | ||
|
||
/** | ||
* @return \Zend\Console\Charset\AsciiExtended | ||
*/ | ||
public function getDefaultCharset() | ||
{ | ||
return new Charset\AsciiExtended; | ||
} | ||
|
||
protected function switchToUtf8() | ||
{ | ||
`mode con cp select=65001`; | ||
} | ||
|
||
} |
Oops, something went wrong.