• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ncurses_wborder函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ncurses_wborder函数的典型用法代码示例。如果您正苦于以下问题:PHP ncurses_wborder函数的具体用法?PHP ncurses_wborder怎么用?PHP ncurses_wborder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ncurses_wborder函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:EsterniTY,项目名称:dfl860e-logger,代码行数:7,代码来源:ncurse.php


示例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();
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:9,代码来源:dialog.php


示例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);
 }
开发者ID:jean-pasqualini,项目名称:ia,代码行数:9,代码来源:NCursesOutput.php


示例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);
        }
    }
}
开发者ID:jean-pasqualini,项目名称:ia,代码行数:56,代码来源:test.php


示例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();
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:49,代码来源:menu.php


示例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();
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:22,代码来源:dialog.php


示例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);
 }
开发者ID:MaloufSleep,项目名称:obray,代码行数:26,代码来源:oCLI.php


示例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);
 }
开发者ID:impelling,项目名称:VegaDNS,代码行数:41,代码来源:class.out_ncurses.php


示例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;
}
开发者ID:jean-pasqualini,项目名称:ia,代码行数:67,代码来源:input.php


示例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));
 }
开发者ID:swos-,项目名称:ncurses,代码行数:4,代码来源:Ncurses.php


示例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']);
//.........这里部分代码省略.........
开发者ID:jean-pasqualini,项目名称:ia,代码行数:101,代码来源:dialog.php


示例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 ]");
 }
开发者ID:ShaneMcC,项目名称:synacor-challenge,代码行数:19,代码来源:VMOutput_ncurses.php


示例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) {
开发者ID:jean-pasqualini,项目名称:ia,代码行数:31,代码来源:test2.php


示例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);
 }
开发者ID:jean-pasqualini,项目名称:ia,代码行数:18,代码来源:Window.php


示例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']);
 }
开发者ID:svgorbunov,项目名称:AcePHProxy,代码行数:21,代码来源:class.ncurses_ui.php


示例16: menu_check_list

function menu_check_list($params)
{
    ###############################################################################################
    if (!is_array($params) || empty($params)) {
        trigger_error('wrong_params');
        return NULL;
    }
    $menu = isset($params['items']) ? $params['items'] : NULL;
    $rows = isset($params['rows']) ? (int) $params['rows'] : 0;
    $cols = isset($params['cols']) ? (int) $params['cols'] : 0;
    $centered = empty($params['centered']) ? 0 : 1;
    $y_menu = isset($params['y']) ? (int) $params['y'] : 0;
    $x_menu = isset($params['x']) ? (int) $params['x'] : 0;
    if (!is_array($menu) || empty($menu) || $rows <= 0 || $cols <= 0 || $y_menu < 0 || $x_menu < 0) {
        trigger_error('wrong params');
        return NULL;
    }
    $keys = array_keys($menu);
    $n_menu = count($keys);
    $items = array();
    $checked = array();
    $current = 0;
    $width = 0;
    $height = $n_menu + 2;
    $i = 0;
    $k = NULL;
    $i_checked = NULL;
    for ($i = 0; $i < $n_menu; $i++) {
        $k = $keys[$i];
        $i_checked = isset($menu[$k][1]) && $menu[$k][1] == 1 ? 1 : 0;
        $items[$i] = ' [' . ($i_checked ? '*' : ' ') . '] ' . $menu[$k][0];
        $width = max($width, strlen($items[$i]));
        $checked[$i] = $i_checked;
    }
    for ($i = 0; $i < $n_menu; $i++) {
        $items[$i] = $items[$i] . str_repeat(' ', 2 + $width - strlen($items[$i]));
    }
    $width += 4;
    if ($centered) {
        $r = $rows - $height >> 1;
        $c = $cols - $width >> 1;
    }
    $window = ncurses_newwin($height, $width, $r, $c);
    if (empty($window)) {
        trigger_error('unable to create window');
        return NULL;
    }
    ncurses_wborder($window, 0, 0, 0, 0, 0, 0, 0, 0);
    $n_items = count($items);
    for ($i = 0; $i < $n_items; $i++) {
        if ($i == $current) {
            ncurses_wattron($window, NCURSES_A_REVERSE);
        }
        ncurses_mvwaddstr($window, 1 + $i, 1, $items[$i]);
        if ($i == $current) {
            ncurses_wattroff($window, NCURSES_A_REVERSE);
        }
    }
    ncurses_wrefresh($window);
    ncurses_keypad($window, TRUE);
    ncurses_noecho();
    ncurses_curs_set(0);
    $do_loop = 1;
    $save_result = 0;
    while ($do_loop) {
        $key = ncurses_wgetch($window);
        $move = 0;
        switch ($key) {
            case NCURSES_KEY_UP:
                if ($current > 0) {
                    $move = -1;
                }
                break;
            case NCURSES_KEY_DOWN:
                if ($current < $n_menu - 1) {
                    $move = 1;
                }
                break;
            case XCURSES_KEY_LF:
            case XCURSES_KEY_CR:
                $do_loop = 0;
                $save_result = 1;
                break;
            case XCURSES_KEY_SPACE:
                if ($checked[$current]) {
                    $checked[$current] = 0;
                    $items[$current] = ' [ ] ' . substr($items[$current], 5);
                } else {
                    $checked[$current] = 1;
                    $items[$current] = ' [*] ' . substr($items[$current], 5);
                }
                ncurses_wattron($window, NCURSES_A_REVERSE);
                ncurses_mvwaddstr($window, 1 + $current, 1, $items[$current]);
                ncurses_wattroff($window, NCURSES_A_REVERSE);
                ncurses_wrefresh($window);
                break;
            case XCURSES_KEY_ESC:
                ncurses_flushinp();
                $do_loop = 0;
                break;
//.........这里部分代码省略.........
开发者ID:jean-pasqualini,项目名称:ia,代码行数:101,代码来源:checkbox.php


示例17: createFriendsBox

 public function createFriendsBox()
 {
     $this->friendsBox = ncurses_newwin($this->mainWindowLine - 5, 20, 1, 2);
     ncurses_wborder($this->friendsBox, 0, 0, 0, 0, 0, 0, 0, 0);
     ncurses_wrefresh($this->friendsBox);
 }
开发者ID:kissthink,项目名称:PHPQQ,代码行数:6,代码来源:PHPQQ.php


示例18: ncurses_show_text

function ncurses_show_text($title, $text, $question, $keys = TRUE)
{
    // prepare text
    $textH = count($text);
    $textW = 1;
    $textLEN = array();
    for ($i = 0; $i < $textH; $i++) {
        $textLEN[$i] = strlen($text[$i]);
        if ($textLEN[$i] > $textW) {
            $textW = $textLEN[$i];
        }
    }
    // create text pad (invisible window)
    $textWIN = ncurses_newpad($textH, $textW);
    // fill it with text
    for ($i = 0; $i < $textH; $i++) {
        ncurses_mvwaddstr($textWIN, $i, 0, $text[$i]);
    }
    // prepare question
    $questionH = count($question);
    $questionLastW = strlen($question[$questionH - 1]);
    // initialize...
    $posX = $posY = 0;
    $screenH = $screenW = 0;
    // loop around...
    while (1) {
        // get actual screen size
        $oldH = $screenH;
        $oldW = $screenW;
        ncurses_getmaxyx(STDSCR, $screenH, $screenW);
        // something changed?
        if ($screenH != $oldH || $screenW != $oldW) {
            if ($oldH > 0) {
                ncurses_delwin($upperWIN);
                ncurses_delwin($lowerWIN);
            }
            ncurses_erase();
            ncurses_refresh(STDSCR);
            $upperWIN = ncurses_newwin($screenH - (2 + $questionH), $screenW, 0, 0);
            $lowerWIN = ncurses_newwin(2 + $questionH, $screenW, $screenH - (2 + $questionH), 0);
            $upperH = $screenH - (4 + $questionH);
            $upperW = $screenW - 2;
            $copyH = $upperH > $textH ? $textH : $upperH;
            $copyW = $upperW > $textW ? $textW : $upperW;
            // border lower window
            ncurses_wborder($lowerWIN, 0, 0, 0, 0, 0, 0, 0, 0);
            // print text in lower window
            for ($i = 0; $i < $questionH; $i++) {
                ncurses_mvwaddstr($lowerWIN, $i + 1, 1, $question[$i]);
            }
        }
        // check and fix positions
        if ($posY < 0 || $upperH >= $textH) {
            $posY = 0;
        } else {
            if ($upperH + $posY > $textH) {
                $posY = $textH - $upperH;
            }
        }
        if ($posX < 0 || $upperW >= $textW) {
            $posX = 0;
        } else {
            if ($upperW + $posX > $textW) {
                $posX = $textW - $upperW;
            }
        }
        // border upper window
        ncurses_wborder($upperWIN, 0, 0, 0, 0, 0, 0, 0, 0);
        // draw title and info line
        ncurses_wattron($upperWIN, NCURSES_A_REVERSE);
        ncurses_mvwaddstr($upperWIN, 0, 2, ' ' . $title . ' ');
        if ($upperH < $textH) {
            ncurses_mvwaddstr($upperWIN, $upperH + 1, 2, ' line ' . ($posY + 1) . '-' . ($posY + $copyH) . '/' . $textH . ' ');
        }
        ncurses_wattroff($upperWIN, NCURSES_A_REVERSE);
        // draw < and > at left/right side when horizontal scrolling is nesseccary
        if ($upperW < $textW) {
            for ($i = 0; $i < $copyH; $i++) {
                if ($textLEN[$i + $posY] > $copyW + $posX) {
                    ncurses_mvwaddstr($upperWIN, $i + 1, $screenW - 1, '>');
                }
                if ($posX > 0 && $textLEN[$i + $posY] > 0) {
                    ncurses_mvwaddstr($upperWIN, $i + 1, 0, '<');
                }
            }
        }
        // draw upper window
        ncurses_wrefresh($upperWIN);
        // copy a part of the text (pad) to the screen
        ncurses_prefresh($textWIN, $posY, $posX, 1, 1, $upperH, $upperW);
        // move cursor to end of last line of question
        ncurses_wmove($lowerWIN, $questionH, $questionLastW + 1);
        // draw lower window
        ncurses_wrefresh($lowerWIN);
        // get a character and do...
        $char = ncurses_getch();
        if (is_array($keys) && array_search($char, $keys) !== FALSE) {
            break;
        } else {
            if ($char == NCURSES_KEY_UP) {
//.........这里部分代码省略.........
开发者ID:jean-pasqualini,项目名称:ia,代码行数:101,代码来源:example.php


示例19: menu_select

function menu_select($params)
{
    ###################################################################################################
    if (!is_array($params) || empty($params)) {
        trigger_error('wrong params');
        return NULL;
    }
    $menu = isset($params['items']) ? $params['items'] : NULL;
    $rows = isset($params['rows']) ? (int) $params['rows'] : 0;
    $cols = isset($params['cols']) ? (int) $params['cols'] : 0;
    $selected = isset($params['selected']) ? (int) $params['selected'] : 0;
    $centered = empty($params['centered']) ? 0 : 1;
    $y_menu = isset($params['y']) ? (int) $params['y'] : 0;
    $x_menu = isset($params['x']) ? (int) $params['x'] : 0;
    if (!is_array($menu) || empty($menu) || $rows <= 0 || $cols <= 0 || $y_menu < 0 || $x_menu < 0) {
        trigger_error('wrong params');
        return NULL;
    }
    $keys = array_keys($menu);
    $values = array();
    $current = 0;
    $width = 0;
    $height = count($menu) + 2;
    foreach ($menu as $value) {
        $width = max($width, strlen($value));
    }
    $i = 0;
    foreach ($menu as $k => $v) {
        $values[$i] = ' ' . $v . str_repeat(' ', 1 + $width - strlen($v));
        if ($k == $selected) {
            $current = $i;
        }
        $i++;
    }
    $width += 4;
    if ($centered) {
        $y_menu = $rows - $height >> 1;
        $x_menu = $cols - $width >> 1;
    }
    $window = ncurses_newwin($height, $width, $y_menu, $x_menu);
    if (empty($window)) {
        trigger_error('unable to create window');
        return NULL;
    }
    ncurses_wborder($window, 0, 0, 0, 0, 0, 0, 0, 0);
    for ($a = 0; $a < count($values); $a++) {
        if ($a == $current) {
            ncurses_wattron($window, NCURSES_A_REVERSE);
        }
        ncurses_mvwaddstr($window, 1 + $a, 1, $values[$a]);
        if ($a == $current) {
            ncurses_wattroff($window, NCURSES_A_REVERSE);
        }
    }
    ncurses_wrefresh($window);
    ncurses_keypad($window, TRUE);
    ncurses_curs_set(0);
    do {
        $key = ncurses_wgetch($window);
        $move = 0;
        switch ($key) {
            case NCURSES_KEY_UP:
                if ($current > 0) {
                    $move = -1;
                }
                break;
            case NCURSES_KEY_DOWN:
                if ($current < count($values) - 1) {
                    $move = 1;
                }
                break;
            case XCURSES_KEY_LF:
            case XCURSES_KEY_CR:
                $result = $keys[$current];
                break;
            case XCURSES_KEY_ESC:
                ncurses_flushinp();
                $result = '';
                break;
        }
        if ($move) {
            ncurses_mvwaddstr($window, 1 + $current, 1, $values[$current]);
            $current += $move;
            ncurses_wattron($window, NCURSES_A_REVERSE);
            ncurses_mvwaddstr($window, 1 + $current, 1, $values[$current]);
            ncurses_wattroff($window, NCURSES_A_REVERSE);
            ncurses_wrefresh($window);
        }
    } while (!isset($result));
    ncurses_delwin($window);
    return $result;
}
开发者ID:jean-pasqualini,项目名称:ia,代码行数:92,代码来源:menu.php


示例20: gui

function gui()
{
    // we begin by initializing ncurses
    $ncurse = ncurses_init();
    // let ncurses know we wish to use the whole screen
    $fullscreen = ncurses_newwin(0, 0, 0, 0);
    // draw a border around the whole thing.
    ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
    ncurses_attron(NCURSES_A_REVERSE);
    ncurses_mvaddstr(0, 1, "AEMB2 SIMULATOR OUTPUT TRANSLATOR");
    ncurses_attroff(NCURSES_A_REVERSE);
    // now lets create a small window
    $small = ncurses_newwin(10, 30, 2, 2);
    // border our small window.
    ncurses_wborder($small, 0, 0, 0, 0, 0, 0, 0, 0);
    ncurses_refresh();
    // paint both windows
    // move into the small window and write a string
    ncurses_mvwaddstr($small, 5, 5, "   Test  String   ");
    // show our handiwork and refresh our small window
    ncurses_wrefresh($small);
    $pressed = ncurses_getch();
    // wait for a user keypress
    ncurses_end();
    // clean up our screen
}
开发者ID:jiangxilong,项目名称:aemb,代码行数:26,代码来源:simulator.php



注:本文中的ncurses_wborder函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ncurses_wrefresh函数代码示例发布时间:2022-05-15
下一篇:
PHP ncurses_newwin函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap