当前位置: 首页>>代码示例>>PHP>>正文


PHP ncurses_getmaxyx函数代码示例

本文整理汇总了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];
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:7,代码来源:context.php

示例2: __construct

 public function __construct($window)
 {
     $this->window = $window;
     ncurses_getmaxyx($this->window, $y, $x);
     $this->rows = $y - 1;
     $this->cols = $x;
     $this->tabs = [];
 }
开发者ID:ck99,项目名称:kurses,代码行数:8,代码来源:TabsManager.php

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

示例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;
 }
开发者ID:ck99,项目名称:kurses,代码行数:10,代码来源:Screen.php

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

示例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];
             }
         }
     }
 }
开发者ID:rafeca,项目名称:Spec-PHP,代码行数:17,代码来源:ResultPrinter.php

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

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

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

示例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);
 }
开发者ID:samleybrize,项目名称:bugzorcist,代码行数:25,代码来源:NcursesStackTrace.php

示例11: getMaxYX

 public function getMaxYX(&$y, &$x)
 {
     ncurses_getmaxyx($this->window, $y, $x);
 }
开发者ID:ck99,项目名称:kurses,代码行数:4,代码来源:Window.php

示例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.
 }
开发者ID:rburchell,项目名称:ircc,代码行数:22,代码来源:ncurse.class.php

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

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

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


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