本文整理汇总了PHP中ncurses_wborder函数的典型用法代码示例。如果您正苦于以下问题:PHP ncurses_wborder函数的具体用法?PHP ncurses_wborder怎么用?PHP ncurses_wborder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ncurses_wborder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: title
public function title($text)
{
ncurses_wborder($this->resource, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wattron($this->resource, NCURSES_A_REVERSE);
ncurses_mvwaddstr($this->resource, 0, 2, '[' . $text . ']');
ncurses_wattroff($this->resource, NCURSES_A_REVERSE);
}
示例2: onDraw
public function onDraw()
{
if ($this->window) {
ncurses_wborder($this->window, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_mvwaddstr($this->window, 0, 3, "[ x ]");
ncurses_wrefresh($this->window);
}
parent::onDraw();
}
示例3: __construct
public function __construct()
{
parent::__construct();
$this->setFormatter(new OutputFormatter());
ncurses_init();
//ncurses_mvaddstr(55,1,"My first ncurses application");
$this->window = ncurses_newwin(40, 30, 0, 0);
ncurses_wborder($this->window, 0, 0, 0, 0, 0, 0, 0, 0);
}
示例4: 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);
}
}
}
示例5: draw
/**
* Draws the menu on the workspace.
*
* @param int $workspace The workspace window handle for curses
*/
function draw($workspace)
{
$wh = $this->_wh;
ncurses_wcolor_set($wh, NCC_FRAME);
ncurses_wborder($wh, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wcolor_set($wh, NCC_TITLE);
ncurses_wattron($wh, NCURSES_A_BOLD);
$left = floor(($this->_w - 2) / 2 - (strlen($this->_title) + 2) / 2);
ncurses_mvwaddstr($wh, 0, $left, ' ' . $this->_title . ' ');
ncurses_wattroff($wh, NCURSES_A_BOLD);
ncurses_wcolor_set($wh, NCC_TEXT);
$i = $this->_scroll;
$sm = count($this->_items) - ($this->_h - 2);
if ($sm < 0) {
$sm = 0;
}
for ($n = 0; $n < $this->_h - 2; $n++) {
if ($n + $i < count($this->_items)) {
$str = " " . $this->_itemsidx[$n + $i];
} else {
$str = "";
}
$str .= str_repeat(' ', $this->_w - 2 - strlen($str));
if ($n + $i == $this->_selected) {
ncurses_wattron($wh, NCURSES_A_REVERSE);
}
$str = substr($str, 0, $this->_w - 2);
ncurses_mvwaddstr($wh, $n + 1, 1, $str);
ncurses_wattroff($wh, NCURSES_A_REVERSE);
}
ncurses_wcolor_set($wh, NCC_MORE);
if ($i > 0) {
ncurses_wmove($wh, 1, $this->_w - 1);
ncurses_waddch($wh, NCURSES_ACS_UARROW | NCURSES_A_BOLD);
}
if ($sm - $i > 0) {
ncurses_wmove($wh, $this->_h - 2, $this->_w - 1);
ncurses_waddch($wh, NCURSES_ACS_DARROW | NCURSES_A_BOLD);
}
ncurses_wrefresh($wh);
ncurses_wcolor_set($wh, 0);
ncurses_move(-1, 1);
ncurses_refresh();
}
示例6: draw
/**
*
*/
function draw($workspace)
{
$wh = $this->_wh;
ncurses_wcolor_set($wh, NCC_FRAME);
ncurses_wborder($wh, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wcolor_set($wh, NCC_TITLE);
ncurses_wattron($wh, NCURSES_A_BOLD);
$left = floor(($this->_w - 2) / 2 - (strlen($this->_title) + 2) / 2);
ncurses_mvwaddstr($wh, 0, $left, ' ' . $this->_title . ' ');
ncurses_wattroff($wh, NCURSES_A_BOLD);
ncurses_wcolor_set($wh, NCC_TEXT);
for ($n = 0; $n < $this->_h - 2; $n++) {
ncurses_mvwaddstr($wh, $n + 1, 1, str_repeat(" ", $this->_w - 2));
}
ncurses_wrefresh($wh);
ncurses_wcolor_set($wh, 0);
ncurses_move(-1, 1);
ncurses_refresh();
}
示例7: log
public function log($name, $rows = NULL, $cols = NULL, $x = NULL, $y = NULL)
{
if (empty($windows[$name])) {
if (is_null($rows)) {
$rows = $this->rows - 10;
}
if (is_null($cols)) {
$cols = intval($this->cols / 2) - 3;
}
if (is_null($x)) {
$x = intval($this->cols / 2) + 1;
}
if (is_null($y)) {
$y = 2;
}
$log = new stdClass();
$log->window = ncurses_newwin($rows, $cols, $x, $y);
$log->items = array();
ncurses_wborder($log->window, 0, 0, 0, 0, 0, 0, 0, 0);
$windows[$name] = $log;
} else {
$log = $windows[$name];
}
ncurses_mvwaddstr($log->window, 0, 1, " " . $name . " ");
ncurses_wrefresh($log->window);
}
示例8: _window_with_lines
public function _window_with_lines($name, $lines, $x = 5, $y = 5, $set_width = false)
{
// Need an array of lines.
$lines = (array) $lines;
// Ignore disabled liens
$lines = array_filter($lines);
// Do we not have a specific set width? Calculate the longest line
if (!is_numeric($set_width)) {
$longest_line = strlen($name) + 10;
foreach ($lines as $line) {
$length = strlen(implode('', $line));
$longest_line = $length > $longest_line ? $length : $longest_line;
}
$width = $longest_line + 4;
} else {
$width = $set_width;
}
// Calculate window hight
$height = 3 + count($lines);
// Create window
$win = ncurses_newwin($height, $width, $x, $y);
// This character will be the side borders
$side = ord('|');
// Do the borders of the window
ncurses_wborder($win, $side, $side, ord('-'), ord('-'), ord('/'), ord('\\'), ord('\\'), ord('/'));
// Add window title string
ncurses_mvwaddstr($win, 1, 1, $this->_charpad($name, $width, 'c', '='));
// Keep track of vertical position for each line
$v = 1;
// Go through and output each line, while incrementing line position counter
foreach ($lines as $line) {
ncurses_mvwaddstr($win, $v + 1, 1, $this->_charpad($line[0] . $this->_charpad($line[1], $width - strlen($line[0]), 'r', '.'), $width, 'n'));
$v++;
}
// Show it
ncurses_wrefresh($win);
// Store it so we can kill it later
$this->_windows[] =& $win;
// Return window dimensions
return array($width, $height);
}
示例9: dlg_input
function dlg_input($params = array())
{
###############################################################################################
$title = isset($params['title']) ? $params['title'] : NULL;
$max_length = isset($params['max_len']) ? (int) $params['max_len'] : 10;
$dlg_rows = isset($params['dlg_cols']) ? (int) $params['dlg_cols'] : 3;
$dlg_cols = isset($params['dlg_cols']) ? (int) $params['dlg_cols'] : 40;
$parent_cols = isset($params['cols']) ? (int) $params['cols'] : NULL;
$parent_rows = isset($params['rows']) ? (int) $params['rows'] : NULL;
$dlg_x = (int) (($parent_cols - $dlg_cols) / 2);
if ($dlg_x < 0) {
$dlg_x = 0;
}
$dlg_y = (int) (($parent_rows - $dlg_rows) / 2);
if ($dlg_y < 0) {
$dlg_y = 0;
}
if ($max_length <= 0 || $dlg_rows <= 0 || $dlg_cols <= 0) {
trigger_error('wrong params');
return NULL;
}
$dlg_window = ncurses_newwin($dlg_rows, $dlg_cols, $dlg_y, $dlg_x);
if (empty($dlg_window)) {
return NULL;
}
ncurses_wborder($dlg_window, 0, 0, 0, 0, 0, 0, 0, 0);
if ($title) {
ncurses_wattron($dlg_window, NCURSES_A_REVERSE);
ncurses_mvwaddstr($dlg_window, 0, 2, ' ' . $title . ' ');
ncurses_wattroff($dlg_window, NCURSES_A_REVERSE);
}
ncurses_curs_set(1);
ncurses_wmove($dlg_window, 2, 2);
ncurses_wrefresh($dlg_window);
$do_getch = 1;
$input_val = '';
$input_char = '';
$input_len = 0;
$cursor_x = 2;
$cursor_y = 1;
ncurses_wmove($dlg_window, $cursor_y, $cursor_x);
ncurses_noecho();
ncurses_keypad($dlg_window, TRUE);
while ($do_getch) {
$key_code = ncurses_wgetch($dlg_window);
if ($key_code == XCURSES_KEY_CR || $key_code == XCURSES_KEY_LF) {
$do_getch = 0;
} elseif ($key_code == NCURSES_KEY_BACKSPACE) {
if ($input_len > 0) {
$input_len--;
$input_val = substr($input_val, 0, $input_len);
$cursor_x--;
ncurses_mvwaddstr($dlg_window, $cursor_y, $cursor_x, ' ');
ncurses_wmove($dlg_window, $cursor_y, $cursor_x);
}
} elseif ($key_code < XCURSES_KEY_PRINTABLE_MIN || $key_code > XCURSES_KEY_PRINTABLE_MAX) {
continue;
} elseif ($input_len < $max_length) {
$input_val .= $input_char = chr($key_code);
$input_len++;
$cursor_x++;
ncurses_waddstr($dlg_window, $input_char);
}
}
ncurses_delwin($dlg_window);
return $input_val;
}
示例10: border
private function border($w, $left = '|', $top = '-', $right = '|', $bottom = '-', $tlCorner = '+', $trCorner = '+', $brCorner = '+', $blCorner = '+')
{
ncurses_wborder($w, ord($left), ord($right), ord($top), ord($bottom), ord($tlCorner), ord($trCorner), ord($blCorner), ord($brCorner));
}
示例11: dialog
function dialog($params)
{
###############################################################################################
if (empty($params) || !is_array($params)) {
trigger_error('params must be non-empty array');
return NULL;
}
$message = isset($params['message']) ? $params['message'] : '';
$buttons = !empty($params['buttons']) && is_array($params['buttons']) ? $params['buttons'] : array('OK');
$n_buttons = count($buttons);
for ($i = 0; $i < $n_buttons; $i++) {
$buttons[$i] = ' ' . $buttons[$i] . ' ';
}
$parent_rows = isset($params['rows']) && $params['rows'] > 0 ? (int) $params['rows'] : 25;
$parent_cols = isset($params['cols']) && $params['cols'] > 0 ? (int) $params['cols'] : 80;
if (empty($message) || empty($buttons) || $parent_rows <= 0 || $parent_cols <= 0) {
trigger_error('wrong params');
return NULL;
}
$message_lines = split("\n", $message);
$message_width = 0;
$n_message_lines = count($message_lines);
for ($i = 0; $i < $n_message_lines; $i++) {
$message_width = max(strlen($message_lines[$i]), $message_width);
}
$buttons_delim = ' ';
$buttons_delim_len = strlen($buttons_delim);
$buttons_len = strlen(implode($buttons_delim, $buttons));
$width = 4 + max($buttons_len + 2 * $buttons_delim_len, $message_width);
$height = 4 + $n_message_lines;
$dlg_y = $parent_rows > $height ? $parent_rows - $height >> 1 : 1;
$dlg_x = $parent_cols > $width ? $parent_cols - $width >> 1 : 1;
$window = ncurses_newwin($height, $width, $dlg_y, $dlg_x);
if (empty($window)) {
trigger_error('unable to create window');
return NULL;
}
ncurses_wborder($window, 0, 0, 0, 0, 0, 0, 0, 0);
$i_x = 0;
$i_y = 0;
for ($i = 0; $i < $n_message_lines; $i++) {
$i_y = 1 + $i;
$i_x = 1 + ($width - 2 - strlen($message_lines[$i]) >> 1);
ncurses_mvwaddstr($window, $i_y, $i_x, rtrim($message_lines[$i]));
}
$buttons_data = array();
$buttons_shift_x = 1 + ($width - 1 - $buttons_len >> 1);
$buttons_shift_y = 2 + $n_message_lines;
$i_title = '';
$i_x = $buttons_shift_x;
for ($i = 0; $i < $n_buttons; $i++) {
$i_title = $buttons[$i];
$buttons_data[] = array('x' => $i_x, 's' => $i_title);
if (0 == $i) {
ncurses_wattron($window, NCURSES_A_REVERSE);
}
ncurses_mvwaddstr($window, $buttons_shift_y, $i_x, $i_title);
if (0 == $i) {
ncurses_wattroff($window, NCURSES_A_REVERSE);
}
$i_x += strlen($i_title) + $buttons_delim_len;
}
ncurses_wrefresh($window);
ncurses_keypad($window, TRUE);
ncurses_curs_set(0);
ncurses_noecho();
$result = -1;
$do_loop = 1;
$move = 0;
$current = 0;
while ($do_loop) {
$key = ncurses_wgetch($window);
$move = 0;
switch ($key) {
case NCURSES_KEY_LEFT:
if ($current > 0) {
$move = -1;
}
break;
case NCURSES_KEY_RIGHT:
if ($current < $n_buttons - 1) {
$move = 1;
}
break;
case XCURSES_KEY_LF:
case XCURSES_KEY_CR:
$result = $current;
$do_loop = 0;
break;
case XCURSES_KEY_ESC:
$do_loop = 0;
break;
}
if (0 == $do_loop) {
ncurses_flushinp();
} elseif ($move) {
ncurses_mvwaddstr($window, $buttons_shift_y, $buttons_data[$current]['x'], $buttons_data[$current]['s']);
$current += $move;
ncurses_wattron($window, NCURSES_A_REVERSE);
ncurses_mvwaddstr($window, $buttons_shift_y, $buttons_data[$current]['x'], $buttons_data[$current]['s']);
//.........这里部分代码省略.........
示例12: redrawDebug
/**
* Redraw the debug Panel.
*/
public function redrawDebug()
{
ncurses_wclear($this->panels['debug']);
ncurses_wborder($this->panels['debug'], 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_mvwaddstr($this->panels['debug'], 2, 2, "R1: [ " . $this->getVM()->get(0) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 3, 2, "R2: [ " . $this->getVM()->get(1) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 4, 2, "R3: [ " . $this->getVM()->get(2) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 2, 27, "R4: [ " . $this->getVM()->get(3) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 3, 27, "R5: [ " . $this->getVM()->get(4) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 4, 27, "R6: [ " . $this->getVM()->get(5) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 2, 52, "R7: [ " . $this->getVM()->get(6) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 3, 52, "R8: [ " . $this->getVM()->get(7) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 6, 2, "Location: [ " . $this->getVM()->getLocation() . " ]");
ncurses_mvwaddstr($this->panels['debug'], 6, 27, "Stack: [ " . implode(' ', $this->getVM()->getStack()) . " ]");
ncurses_mvwaddstr($this->panels['debug'], 0, 2, "[ Debug ]");
}
示例13: ncurses_newwin
$main = ncurses_newwin(0, 0, 0, 0);
// main window
ncurses_getmaxyx($main, $lines, $columns);
ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
while (1) {
// border the main window
ncurses_attron(NCURSES_A_REVERSE);
ncurses_mvaddstr(0, 1, "Traceroute example");
ncurses_attroff(NCURSES_A_REVERSE);
// create a lower window which is dynamically sized...
$lower_frame_window = ncurses_newwin(10, $columns - 3, $lines - 11, 1);
ncurses_wborder($lower_frame_window, 0, 0, 0, 0, 0, 0, 0, 0);
// border it
$lower_main_window = ncurses_newwin(8, $columns - 5, $lines - 10, 2);
$main_list_window = ncurses_newwin($lines - 12, $columns - 3, 1, 1);
ncurses_wborder($main_list_window, 0, 0, 0, 0, 0, 0, 0, 0);
// border it
if ($currently_selected == "") {
$currently_selected = 0;
}
for ($a = 0; $a < count($tr_return); $a++) {
$out = $tr_return[$a];
if ($currently_selected == intval($a)) {
ncurses_wattron($main_list_window, NCURSES_A_REVERSE);
ncurses_mvwaddstr($main_list_window, 1 + $a, 1, $out);
ncurses_wattroff($main_list_window, NCURSES_A_REVERSE);
} else {
ncurses_mvwaddstr($main_list_window, 1 + $a, 1, $out);
}
}
if ($y == ENTER_KEY) {
示例14: setBorder
/**
* Set borders window
*
* @param int $left |
* @param int $right |
* @param int $top -
* @param int $bottom _
* @param int $tl_corner +
* @param int $tr_corner +
* @param int $bl_corner +
* @param int $br_corner +
* @return int
*/
public function setBorder($left = 0, $right = 0, $top = 0, $bottom = 0, $tl_corner = 0, $tr_corner = 0, $bl_corner = 0, $br_corner = 0)
{
return ncurses_wborder($this->window, $left, $right, $top, $bottom, $tl_corner, $tr_corner, $bl_corner, $br_corner);
$this->setChanged(true);
}
示例15: log
public function log($msg, $color = self::CLR_DEFAULT)
{
ncurses_getmaxyx($this->windows['log'], $y, $x);
ncurses_getyx($this->windows['log'], $cy, $cx);
// cursor xy
if ($cy > $y - 3) {
ncurses_werase($this->windows['log']);
ncurses_wborder($this->windows['log'], 0, 0, 0, 0, 0, 0, 0, 0);
$cy = 0;
}
$msg = mb_substr($msg, 0, $x - 2);
$color and ncurses_wcolor_set($this->windows['log'], $color);
ncurses_mvwaddstr($this->windows['log'], $cy + 1, 1, $msg);
ncurses_clrtoeol();
$color and ncurses_wcolor_set($this->windows['log'], self::CLR_DEFAULT);
// никак скроллить не выходит
#ncurses_insdelln (1);
#ncurses_scrl (-2); // вообще 0 реакции
#ncurses_insertln ();
ncurses_wrefresh($this->windows['log']);
}