console : add getTermHeight getTermWidth methods
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5829 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
30
console.php
30
console.php
@@ -69,6 +69,10 @@ class console
|
||||
*/
|
||||
private $termWidth;
|
||||
|
||||
/** Set the height of the terminal in chars
|
||||
*/
|
||||
private $termHeight;
|
||||
|
||||
/** Store the last cursor position in the last readline
|
||||
*/
|
||||
private $cursorPos = 1;
|
||||
@@ -98,6 +102,8 @@ class console
|
||||
public function updateTerminalSize ()
|
||||
// {{{
|
||||
{
|
||||
$this->termWidth = 80;
|
||||
$this->termHeight = 25;
|
||||
$termSize = exec ("stty size", $null, $rc);
|
||||
if ($rc === 0)
|
||||
{
|
||||
@@ -106,9 +112,11 @@ class console
|
||||
$this->termWidth = 80;
|
||||
else
|
||||
$this->termWidth = intval ($termWidth);
|
||||
if (is_null ($termHeight) || is_bool ($termHeight))
|
||||
$this->termHeight = 25;
|
||||
else
|
||||
$this->termHeight = intval ($termHeight);
|
||||
}
|
||||
else
|
||||
$this->termWidth = 80;
|
||||
}
|
||||
// }}}
|
||||
|
||||
@@ -734,6 +742,24 @@ class console
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** Get the terminal Height
|
||||
*/
|
||||
public function getTermHeight ()
|
||||
// {{{
|
||||
{
|
||||
return $this->termHeight;
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** Get the terminal Width
|
||||
*/
|
||||
public function getTermWidth ()
|
||||
// {{{
|
||||
{
|
||||
return $this->termWidth;
|
||||
}
|
||||
// }}}
|
||||
|
||||
/** Call a specific function when a completion key is pressed
|
||||
* The function must get the partial text as first parameter, and must return
|
||||
* an array with the possibilities
|
||||
|
||||
Reference in New Issue
Block a user