本文整理汇总了PHP中ncurses_getmaxyx函数的典型用法代码示例。如果您正苦于以下问题:PHP ncurses_getmaxyx函数的具体用法?PHP ncurses_getmaxyx怎么用?PHP ncurses_getmaxyx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ncurses_getmaxyx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getScreenWidthFromNcurses
protected function getScreenWidthFromNcurses()
{
// @codeCoverageIgnoreStart
if (!function_exists('ncurses_getmaxyx')) {
return false;
}
// @codeCoverageIgnoreEnd
$screenWidth = 0;
$screenHeight = 0;
if (!$this->isReallyATty()) {
return false;
}
// @codeCoverageIgnoreStart
ncurses_init();
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_wrefresh($fullscreen);
ncurses_getmaxyx($fullscreen, $screenHeight, $screenWidth);
ncurses_end();
return $screenWidth;
// @codeCoverageIgnoreEnd
}
开发者ID:Gradwell,项目名称:ConsoleDisplayLib,代码行数:21,代码来源:StreamOutput.php
示例17: _init_screen
function _init_screen()
{
ncurses_curs_set(0);
ncurses_noecho();
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx($fullscreen, $this->_screen_max_height, $this->_screen_max_width);
ncurses_delwin($fullscreen);
ncurses_start_color();
ncurses_init_pair(1, NCURSES_COLOR_WHITE, NCURSES_COLOR_RED);
ncurses_init_pair(4, NCURSES_COLOR_BLACK, 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(5, NCURSES_COLOR_WHITE, NCURSES_COLOR_BLUE);
ncurses_init_pair(6, NCURSES_COLOR_YELLOW, NCURSES_COLOR_BLUE);
ncurses_init_pair(7, NCURSES_COLOR_YELLOW, NCURSES_COLOR_WHITE);
ncurses_color_set(1);
ncurses_erase();
ncurses_mvhline(0, 0, 0, $this->_screen_max_width);
ncurses_attron(NCURSES_A_BOLD);
ncurses_mvaddstr(0, 1, $this->title_page_header);
ncurses_attroff(NCURSES_A_BOLD);
for ($y = 1; $y < $this->_screen_max_height; $y++) {
ncurses_mvhline($y, 0, 32, $this->_screen_max_width);
}
ncurses_refresh();
}
开发者ID:roelforg,项目名称:UbFoInfo,代码行数:26,代码来源:nDialog.class.php
示例18: __construct
/**
* Screen class constructor
*
* @return void
*/
public function __construct()
{
$this->handle = STDSCR;
ncurses_getmaxyx($this->handle, $this->width, $this->height);
ncurses_refresh();
}
开发者ID:nicholasc,项目名称:blink,代码行数:11,代码来源:Screen.php
示例19: importDataFromSource
/**
*
*
* @param string $ps_source
* @param string $ps_mapping
* @param array $pa_options
* user_id = user to execute import for
* description = Text describing purpose of import to be logged.
* showCLIProgressBar = Show command-line progress bar. Default is false.
* format = Format of data being imported. MANDATORY
* useNcurses = Use ncurses library to format output
* logDirectory = path to directory where logs should be written
* logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness:
* KLogger::EMERG = Emergency messages (system is unusable)
* KLogger::ALERT = Alert messages (action must be taken immediately)
* KLogger::CRIT = Critical conditions
* KLogger::ERR = Error conditions
* KLogger::WARN = Warnings
* KLogger::NOTICE = Notices (normal but significant conditions)
* KLogger::INFO = Informational messages
* KLogger::DEBUG = Debugging messages
* dryRun = do import but don't actually save data
* environment = an array of environment values to provide to the import process. The keys manifest themselves as mappable tags.
* forceImportForPrimaryKeys = list of primary key ids to force mapped source data into. The number of keys passed should equal or exceed the number of rows in the source data. [Default is empty]
* transaction = transaction to perform import within. Will not be used if noTransaction option is set. [Default is to create a new transaction]
* noTransaction = don't wrap the import in a transaction. [Default is false]
*/
public static function importDataFromSource($ps_source, $ps_mapping, $pa_options = null)
{
ca_data_importers::$s_num_import_errors = 0;
ca_data_importers::$s_num_records_processed = 0;
ca_data_importers::$s_num_records_skipped = 0;
ca_data_importers::$s_import_error_list = array();
$opa_app_plugin_manager = new ApplicationPluginManager();
$va_notices = $va_errors = array();
$pb_no_transaction = caGetOption('noTransaction', $pa_options, false, array('castTo' => 'bool'));
$pa_force_import_for_primary_keys = caGetOption('forceImportForPrimaryKeys', $pa_options, null);
if (!($t_mapping = ca_data_importers::mappingExists($ps_mapping))) {
return null;
}
$o_event = ca_data_import_events::newEvent(isset($pa_options['user_id']) ? $pa_options['user_id'] : null, $pa_options['format'], $ps_source, isset($pa_options['description']) ? $pa_options['description'] : '');
$o_trans = null;
if (!$pb_no_transaction) {
if (!($o_trans = caGetOption('transaction', $pa_options, null))) {
$o_trans = new Transaction();
}
$t_mapping->setTransaction($o_trans);
}
$po_request = caGetOption('request', $pa_options, null);
$pb_dry_run = caGetOption('dryRun', $pa_options, false);
$pn_file_number = caGetOption('fileNumber', $pa_options, 0);
$pn_number_of_files = caGetOption('numberOfFiles', $pa_options, 1);
$o_config = Configuration::load();
if (!is_array($pa_options) || !isset($pa_options['logLevel']) || !$pa_options['logLevel']) {
$pa_options['logLevel'] = KLogger::INFO;
}
if (!is_array($pa_options) || !isset($pa_options['logDirectory']) || !$pa_options['logDirectory'] || !file_exists($pa_options['logDirectory'])) {
if (!($pa_options['logDirectory'] = $o_config->get('batch_metadata_import_log_directory'))) {
$pa_options['logDirectory'] = ".";
}
}
if (!is_writeable($pa_options['logDirectory'])) {
$pa_options['logDirectory'] = caGetTempDirPath();
}
$o_log = new KLogger($pa_options['logDirectory'], $pa_options['logLevel']);
$vb_show_cli_progress_bar = isset($pa_options['showCLIProgressBar']) && $pa_options['showCLIProgressBar'] ? true : false;
$o_progress = caGetOption('progressBar', $pa_options, new ProgressBar('WebUI'));
if ($vb_show_cli_progress_bar) {
$o_progress->setMode('CLI');
$o_progress->set('outputToTerminal', true);
}
if ($vb_use_ncurses = isset($pa_options['useNcurses']) && $pa_options['useNcurses'] ? true : false) {
$vb_use_ncurses = caCLIUseNcurses();
}
$vn_error_window_height = null;
$vn_max_x = $vn_max_y = null;
if ($vb_use_ncurses) {
ncurses_init();
$r_screen = ncurses_newwin(0, 0, 0, 0);
ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
ncurses_getmaxyx($r_screen, $vn_max_y, $vn_max_x);
$vn_error_window_height = $vn_max_y - 8;
$r_errors = ncurses_newwin($vn_error_window_height, $vn_max_x - 4, 4, 2);
ncurses_wborder($r_errors, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wattron($r_errors, NCURSES_A_REVERSE);
ncurses_mvwaddstr($r_errors, 0, 1, _t(" Recent errors "));
ncurses_wattroff($r_errors, NCURSES_A_REVERSE);
$r_progress = ncurses_newwin(3, $vn_max_x - 4, $vn_max_y - 4, 2);
ncurses_wborder($r_progress, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wattron($r_progress, NCURSES_A_REVERSE);
ncurses_mvwaddstr($r_progress, 0, 1, _t(" Progress "));
ncurses_wattroff($r_progress, NCURSES_A_REVERSE);
$r_status = ncurses_newwin(3, $vn_max_x - 4, 1, 2);
ncurses_wborder($r_status, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_wattron($r_status, NCURSES_A_REVERSE);
ncurses_mvwaddstr($r_status, 0, 1, _t(" Import status "));
ncurses_wattroff($r_status, NCURSES_A_REVERSE);
ncurses_refresh(0);
ncurses_wrefresh($r_progress);
ncurses_wrefresh($r_errors);
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:ca_data_importers.php
示例20: 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
注:本文中的ncurses_getmaxyx函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论