本文整理汇总了PHP中ncurses_getmaxyx函数的典型用法代码示例。如果您正苦于以下问题:PHP ncurses_getmaxyx函数的具体用法?PHP ncurses_getmaxyx怎么用?PHP ncurses_getmaxyx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ncurses_getmaxyx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDimensions
public function getDimensions()
{
$height = 0;
$width = 0;
ncurses_getmaxyx(STDSCR, $height, $width);
return [$width, $height];
}
示例2: __construct
public function __construct($window)
{
$this->window = $window;
ncurses_getmaxyx($this->window, $y, $x);
$this->rows = $y - 1;
$this->cols = $x;
$this->tabs = [];
}
示例3: ncurses_show_screen
function ncurses_show_screen($showHelp)
{
// basic settings
ncurses_noecho();
ncurses_curs_set(0);
// set app title
$title = "Red Ventures Selenium Runner";
// commands to be listed in help
$commands = array('q' => 'quit', 'r' => 'run selected tests', 'space' => 'toggle test selection', 'enter' => 'run highlighted tests', 'up' => 'move up', 'down' => 'move down', 'pgUp' => 'scroll description up', 'pgDown' => 'scroll description down', '?/h' => 'show this help panel');
// create a fullscreen window
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx($fullscreen, $max_y, $max_x);
// enter the main event loop
$do_loop = 1;
while ($do_loop) {
// calculate width of help window columns
$c = $t = 0;
foreach ($commands as $cmd => $txt) {
$c = strlen($cmd) > $c ? strlen($cmd) : $c;
$t = strlen($txt) > $t ? strlen($txt) : $t;
}
$h = count($commands);
// calculate the help windows height
if ($showHelp) {
if (!empty($helpWin)) {
ncurses_delwin($helpWin);
}
$helpWin = ncurses_newwin($h + 4, $c + $t + 5, ($max_y - $h - 4) / 2, ($max_x - $c - $t - 5) / 2);
ncurses_wborder($helpWin, 0, 0, 0, 0, 0, 0, 0, 0);
$i = 0;
foreach ($commands as $cmd => $txt) {
ncurses_mvwaddstr($helpWin, 2 + $i, 2, $cmd);
ncurses_mvwaddstr($helpWin, 2 + $i, 2 + $c + 1, $txt);
}
if (!empty($helpWin)) {
ncurses_wrefresh($helpWin);
} else {
ncurses_refresh();
}
}
if (empty($helpWin)) {
$key = ncurses_getch();
} else {
$key = ncurses_wgetch($helpWin);
}
switch ($key) {
case 27:
ncurses_flushinp();
$do_loop = 0;
break;
default:
$showHelp = $showHelp === true ? false : true;
ncurses_show_screen($showHelp);
}
}
}
示例4: getWindow
public function getWindow()
{
if (!$this->window) {
$this->window = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx($this->window, $y, $x);
$this->rows = $y;
$this->cols = $x;
}
return $this->window;
}
示例5: getWindowSize
public function getWindowSize()
{
static $stored = null;
// Get the window size only once
// We're avoiding problems with resizing windows
if ($stored == null) {
ncurses_wrefresh($this->window);
ncurses_getmaxyx($this->window, $y, $x);
$stored = array($x, $y);
}
return $stored;
}
示例6: __construct
public function __construct($out = NULL, $verbose = FALSE, $colors = FALSE, $debug = FALSE)
{
parent::__construct($out, $verbose, $colors);
if (!empty($_SERVER['COLUMNS'])) {
$this->maxColumns = $_SERVER['COLUMNS'];
} else {
if (function_exists('ncurses_getmaxyx')) {
ncurses_getmaxyx(STDSCR, $height, $this->maxColumns);
} else {
// Try to get it on *nix like systems
exec('resize 2>/dev/null', $output, $ret);
if ($ret === 0 && preg_match('/COLUMNS=([0-9]+)/', $output[0], $m)) {
$this->maxColumns = $m[1];
}
}
}
}
示例7: output
public function output()
{
// Gain access to translations
$lang = $this->linfo->getLang();
// And info
$this->linfo->scan();
$info = $this->linfo->getInfo();
// Say we're called more than once. Kill previous remnants
if (count($this->_windows) > 0) {
$this->_kill_windows();
}
// Get dimensions and give lovely header text
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_wrefresh($fullscreen);
ncurses_getmaxyx($fullscreen, $x, $y);
ncurses_mvwaddstr($fullscreen, 0, 0, 'Generated by ' . $this->linfo->getAppName() . ' (' . $this->linfo->getVersion() . ') (ncurses) on ' . date('m/d/Y @ h:i:s A (T)'));
ncurses_wrefresh($fullscreen);
$this->_max_dims = array($x, $y);
// Some important windows
$core_wins = array(array('name' => $lang['core'], 'content' => array(array($lang['os'], $info['OS']), array_key_exists('Distro', $info) ? array($lang['distro'], $info['Distro']['name'] . ($info['Distro']['version'] ? ' ' . $info['Distro']['version'] : '')) : false, array($lang['kernel'], $info['Kernel']), array_key_exists('Model', $info) && !empty($info['Model']) ? array($lang['model'], $info['Model']) : false, array($lang['uptime'], str_ireplace(array(' ', 'days', 'minutes', 'hours', 'seconds'), array('', 'd', 'm', 'h', 's'), $info['UpTime']['text'])), array($lang['hostname'], $info['HostName']), array_key_exists('CPUArchitecture', $info) ? array($lang['cpu_arch'], $info['CPUArchitecture']) : false, array($lang['load'], implode(' ', (array) $info['Load'])))), array('name' => $lang['memory'], 'content' => array(array($lang['size'], Common::byteConvert($info['RAM']['total'])), array($lang['used'], Common::byteConvert($info['RAM']['total'] - $info['RAM']['free'])), array($lang['free'], Common::byteConvert($info['RAM']['free'])))));
// Show them
$h = 1;
foreach ($core_wins as $win) {
list($width, $height) = $this->_window_with_lines($win['name'], $win['content'], $h, 0);
$h += $height + 1;
}
// Makeshift event loop
while (true) {
// Die on input
$getch = ncurses_getch();
if ($getch > 0 && $getch == 113) {
$this->__destruct();
echo "\nEnding at your request.\n";
// exit(0);
}
// Stop temporariy
ncurses_napms(1000);
// Call ourselves
$this->output();
}
}
示例8: openCLI
public function openCLI($title = NULL)
{
// 1. initiate ncurses
ncurses_init();
// Create a full-screen window
$this->window = ncurses_newwin(0, 0, 0, 0);
// Disable echoing the characters without our control
ncurses_noecho();
// let ncurses know we wish to use the whole screen
$screen = ncurses_newwin(0, 0, 0, 0);
// get screen size
ncurses_getmaxyx($screen, $this->rows, $this->cols);
// draw a border around the whole thing.
ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
// set the application title
if (!is_null($title)) {
ncurses_mvaddstr(0, 2, " " . $title . " ");
}
// paint window
ncurses_refresh();
}
示例9: initScreen
protected function initScreen()
{
ncurses_curs_set(0);
ncurses_noecho();
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx($fullscreen, $this->screenMaxHeight, $this->screenMaxWidth);
ncurses_delwin($fullscreen);
//COLOR SCHEMES
ncurses_start_color();
// text color, background color
/*
COLOR_BLACK 0
COLOR_RED 1
COLOR_GREEN 2
COLOR_YELLOW 3
COLOR_BLUE 4
COLOR_MAGENTA 5
COLOR_CYAN 6
COLOR_WHITE 7
*/
ncurses_init_pair(1, NCURSES_COLOR_WHITE, NCURSES_COLOR_RED);
ncurses_init_pair(2, NCURSES_COLOR_BLACK, NCURSES_COLOR_WHITE);
ncurses_init_pair(3, NCURSES_COLOR_WHITE, NCURSES_COLOR_WHITE);
ncurses_init_pair(4, NCURSES_COLOR_BLACK, NCURSES_COLOR_RED);
ncurses_init_pair(5, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE);
ncurses_init_pair(6, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE);
ncurses_init_pair(7, NCURSES_COLOR_BLUE, NCURSES_COLOR_WHITE);
ncurses_color_set(5);
ncurses_erase();
ncurses_mvhline(0, 0, 0, $this->screenMaxWidth);
ncurses_attron(NCURSES_A_BOLD);
ncurses_mvaddstr(0, 1, $this->titlePageHeader);
ncurses_attroff(NCURSES_A_BOLD);
for ($y = 1; $y < $this->screenMaxHeight; $y++) {
ncurses_mvhline($y, 0, 32, $this->screenMaxWidth);
}
ncurses_refresh();
}
示例10: createPad
/**
* Creates the ncurses pad.
* If the pad already exists, it is deleted and recreated.
* @throws \RuntimeException
*/
protected function createPad()
{
if (null !== $this->pad) {
ncurses_delwin($this->pad);
} elseif (null === $this->padRealWidth) {
$this->calculatePadRealSize();
}
$globalWidth = null;
$globalHeight = null;
ncurses_getmaxyx(STDSCR, $globalHeight, $globalWidth);
$this->padWidth = $globalWidth;
$this->padHeight = $globalHeight - 3;
$w = max($this->padWidth, $this->padRealWidth);
$h = max($this->padHeight, $this->padRealHeight);
$this->pad = ncurses_newpad($h, $w);
if (false === $this->pad) {
throw new \RuntimeException("Failed to create a ncurses pad (width: {$this->padRealWidth}, height: {$this->padRealHeight})");
}
ncurses_keypad($this->pad, true);
}
示例11: getMaxYX
public function getMaxYX(&$y, &$x)
{
ncurses_getmaxyx($this->window, $y, $x);
}
示例12: CreateWindows
public function CreateWindows()
{
// If this is set, then we've "been here before", and we are probably being called from resize, so
// we need to destroy our windows first, so as to not leak resources.
if ($this->mainwin) {
$this->DeleteWindows();
}
$this->mainwin = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx(&$this->mainwin, $this->lines, $this->columns);
// Generate a blank line so we can write over the output
for ($x = 0; $x < $this->columns; $x++) {
$this->cl .= ' ';
}
$this->ircoutput = ncurses_newwin($this->lines - 2, $this->columns, 0, 0);
$this->userinputw = ncurses_newwin(2, $this->columns, $this->lines - 2, 0);
ncurses_wcolor_set($this->ircoutput, NC_PAIR_IRCOUT);
ncurses_wcolor_set($this->userinputw, NC_PAIR_INPUT);
ncurses_refresh();
ncurses_wrefresh($this->ircoutput);
ncurses_wrefresh($this->userinputw);
//ncurses_keypad($this->userinputw, true); // enable keypad.
}
示例13: draw
function draw()
{
static $lx, $ly;
$cx = null;
$cy = null;
ncurses_getmaxyx(STDSCR, $cx, $cy);
if ($cx != $lx || $cy != $ly) {
$this->emit(Cwt::ON_RESIZE, array('x' => $cx, 'y' => $cy));
$lx = $cx;
$ly = $cy;
}
$this->desktop->resize($cy, $cx);
$this->emit(Cwt::ON_BEFORE_DRAW);
$this->desktop->draw();
$this->emit(Cwt::ON_AFTER_DRAW);
ncurses_refresh();
}
示例14: setWidth
/**
* Set the width the rendered text must fit in
*
* @param int $width passed in options
*
* @static
* @return void
*/
protected static function setWidth($width = null)
{
$height = null;
if ($width === null) {
if (self::$window) {
ncurses_getmaxyx(self::$window, $width, $height);
$width = 96;
} else {
if (DIRECTORY_SEPARATOR === '/') {
$width = `tput cols`;
}
}
if ($width < 80) {
$width = 80;
}
}
self::$width = $width;
}
示例15: getSize
/**
* Gets window size
* @param int $columns Will be filled with window columns
* @param int $rows Will be filled with window rows
* @return array An array with elements 'columns' and 'rows'
*/
public function getSize(&$columns = null, &$rows = null)
{
ncurses_getmaxyx($this->windowResource, $rows, $columns);
return array('columns' => $columns, 'rows' => $rows);
}