本文整理汇总了PHP中yii\helpers\Console::getScreenSize方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::getScreenSize方法的具体用法?PHP Console::getScreenSize怎么用?PHP Console::getScreenSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Console
的用法示例。
在下文中一共展示了Console::getScreenSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: determineOwnSize
/**
* Determines and set the size of the frame, if the attributes were not set
* before.
*
* TODO: Create dummy parent frame with size of console and fire the resize
* event.
*/
protected function determineOwnSize()
{
// True for the outermost frame only
if ($this->width == null || $this->height === null) {
// TODO: allow to define fixed size in which the frame is beeing rendered within.
$screenSize = Console::getScreenSize();
if ($screenSize === false) {
throw new UserException('Couldnt determine console window size!');
}
list($screenWidth, $screenHeight) = $screenSize;
if ($this->width === null && $this->layout === self::LAYOUT_HORIZONTAL) {
if (is_float($this->size)) {
$this->width = intval(round($screenWidth * $this->size));
} elseif (is_integer($this->size)) {
$this->width = $this->size;
} else {
$this->width = $screenWidth;
}
}
if ($this->height === null && $this->layout === self::LAYOUT_VERTICAL) {
if (is_float($this->size)) {
$this->height = intval(round($screenHeight * $this->size));
} elseif (is_integer($this->size)) {
$this->height = $this->size;
} else {
$this->height = $screenHeight;
}
}
if ($this->width === null) {
$this->width = $screenWidth;
}
if ($this->height === null) {
$this->height = $screenHeight;
}
if ($this->width > $screenWidth || $this->height > $screenHeight) {
throw new UserException('GUI dimensions are too large!');
}
$this->trigger(self::EVENT_FRAME_RESIZE, $this->createResizeEvent());
}
}
示例2: getScreenWidth
protected function getScreenWidth() : int
{
return Console::getScreenSize(true)[0];
}
示例3: clearScreen
public static function clearScreen()
{
$size = \yii\helpers\Console::getScreenSize();
echo str_repeat("\n", $size[0]);
}