本文整理汇总了PHP中ncurses_end函数的典型用法代码示例。如果您正苦于以下问题:PHP ncurses_end函数的具体用法?PHP ncurses_end怎么用?PHP ncurses_end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ncurses_end函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onTerminate
public function onTerminate()
{
if ($this->nc) {
ncurses_end();
}
$this->nc = null;
}
示例2: __destruct
public function __destruct()
{
static::$init--;
if (static::$init == 0) {
ncurses_end();
}
}
示例3: __destruct
function __destruct()
{
if (function_exists('\\ncurses_end')) {
\ncurses_end();
}
fclose($this->fpin);
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
mb_internal_encoding('UTF-8');
try {
list($line, $colonne) = explode("x", $input->getOption("size"));
$symfonyStyle = new SymfonyStyle($input, $output);
$symfonyStyle->title("IA");
$mapRender = !$input->getOption("curse") ? new ConsoleMapRender($output, true) : new NCurseRender($line, $colonne);
if (!$input->getOption("load-dump")) {
$sizeMap = $mapRender->getSize();
$mapProvider = $input->getOption("map") ? new FileMapProvider($input->getOption("map")) : new RandomMapProvider($sizeMap["y"], $sizeMap["x"]);
$map = new MapBuilder($mapProvider->getMap());
$world = new World($map, array($this->addChat(5, 5), $this->addChat(10, 10)));
} else {
$file = $input->getOption("load-dump");
if (!file_exists($file)) {
if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
ncurses_end();
}
$symfonyStyle->error("le fichier {$file} n'existe pas");
return;
}
$world = unserialize(file_get_contents($file))->getFlashMemory()->all()[0]->getData();
}
while (1) {
$this->render($mapRender, $world);
}
} catch (\Exception $e) {
if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
ncurses_end();
}
$symfonyStyle->error($e->getMessage());
return;
}
}
示例5: HandleResize
public function HandleResize($iSignal)
{
//$this->Output(BUFFER_CURRENT, "FFS RESIZE");
ncurses_end();
ncurses_doupdate();
$this->InitialiseTerminal();
$this->CreateWindows();
$this->DrawBuffer($this->iCurrentBuffer);
$this->setuserinput();
}
示例6: sig_handler
function sig_handler($signo)
{
switch ($signo) {
case SIGINT:
ncurses_end();
exit('exit');
case SIGTERM:
ncurses_end();
exit('exit');
default:
// other
}
}
示例7: parse
private function parse($char = '')
{
switch ($char) {
case ESCAPE_KEY:
ncurses_end();
exit;
break;
case ENTER:
$buffer = $this->getBuffer();
ncurses_mvaddstr(0, 1, $buffer);
ncurses_wclear($this->small);
ncurses_wborder($this->small, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_mvwaddstr($this->small, 5, 5, $buffer);
ncurses_wrefresh($this->small);
break;
default:
$this->pushBuffer(chr($char));
ncurses_wclear($this->small);
ncurses_wborder($this->small, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_mvwaddstr($this->small, 5, 5, chr($char));
ncurses_wrefresh($this->small);
break;
}
}
示例8: define
<?php
/**
* nCurses Keys
*
* Show nCurses key code.
*
* @author Kenny Parnell <kparnell@redventures.com>
* @date Tue 05 Aug 2008 09:08:07 PM EDT
*/
define('ESCAPE_KEY', 27);
ncurses_init();
$fullscreen = ncurses_newwin(0, 0, 0, 0);
ncurses_border(0, 0, 0, 0, 0, 0, 0, 0);
ncurses_getmaxyx($fullscreen, $y, $x);
$small = ncurses_newwin(5, 7, ($y - 5) / 2, ($x - 7) / 2);
ncurses_wborder($small, 0, 0, 0, 0, 0, 0, 0, 0);
ncurses_refresh();
ncurses_mvwaddstr($small, 5, 2, "12");
ncurses_wrefresh($small);
do {
$k = ncurses_wgetch($small);
if ($k == ESCAPE_KEY) {
ncurses_end();
exit;
} else {
echo $k;
}
} while (1);
/* vim:set ft=php ts=4 sw=4 et */
示例9: 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
}
示例10: __destruct
public function __destruct()
{
if ($this->loaded) {
ncurses_end();
}
}
示例11: closeCLI
public function closeCLI()
{
ncurses_end();
}
示例12: __destruct
/**
* Application class destructor
*
* @return void
*/
public function __destruct()
{
// Reset terminal settings & end ncurses
if ($this->initialized) {
ncurses_resetty();
ncurses_end();
}
}
示例13: importDataFromSource
//.........这里部分代码省略.........
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);
ncurses_wrefresh($r_status);
}
$o_log->logInfo(_t('Started import of %1 using mapping %2', $ps_source, $t_mapping->get("importer_code")));
$t = new Timer();
$vn_start_time = time();
$va_log_import_error_opts = array('startTime' => $vn_start_time, 'window' => $r_errors, 'log' => $o_log, 'request' => $po_request, 'progressCallback' => isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback']) ? $ps_callback : null, 'reportCallback' => isset($pa_options['reportCallback']) && ($ps_callback = $pa_options['reportCallback']) ? $ps_callback : null);
global $g_ui_locale_id;
// constant locale set by index.php for web requests
$vn_locale_id = isset($pa_options['locale_id']) && (int) $pa_options['locale_id'] ? (int) $pa_options['locale_id'] : $g_ui_locale_id;
$o_dm = $t_mapping->getAppDatamodel();
$o_progress->start(_t('Reading %1', $ps_source), array('window' => $r_progress));
if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) {
$ps_callback($po_request, $pn_file_number, $pn_number_of_files, $ps_source, 0, 100, _t('Reading %1', $ps_source), time() - $vn_start_time, memory_get_usage(true), 0, ca_data_importers::$s_num_import_errors);
}
// Open file
$ps_format = isset($pa_options['format']) && $pa_options['format'] ? $pa_options['format'] : null;
if (!($o_reader = $t_mapping->getDataReader($ps_source, $ps_format))) {
ca_data_importers::logImportError(_t("Could not open source %1 (format=%2)", $ps_source, $ps_format), $va_log_import_error_opts);
if ($vb_use_ncurses) {
ncurses_end();
}
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
if (!$o_reader->read($ps_source, array('basePath' => $t_mapping->getSetting('basePath')))) {
ca_data_importers::logImportError(_t("Could not read source %1 (format=%2)", $ps_source, $ps_format), $va_log_import_error_opts);
if ($vb_use_ncurses) {
ncurses_end();
}
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
$o_log->logDebug(_t('Finished reading input source at %1 seconds', $t->getTime(4)));
$vn_num_items = $o_reader->numRows();
$o_progress->setTotal($vn_num_items);
$o_progress->start(_t('Importing from %1', $ps_source), array('window' => $r_progress));
if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) {
$ps_callback($po_request, $pn_file_number, $pn_number_of_files, $ps_source, 0, $vn_num_items, _t('Importing from %1', $ps_source), time() - $vn_start_time, memory_get_usage(true), 0, ca_data_importers::$s_num_import_errors);
}
// What are we importing?
$vn_table_num = $t_mapping->get('table_num');
if (!($t_subject = $o_dm->getInstanceByTableNum($vn_table_num))) {
// invalid table
if ($vb_use_ncurses) {
ncurses_end();
}
if ($o_trans) {
$o_trans->rollback();
示例14: curlInfoIPC
/**
* get IPC message and display
*
* @param callback $callback
* return true to end the loop, called on every loop
*/
function curlInfoIPC($callback = null)
{
$queue = $this->getMessageQueue(true)[0];
$nc = ncurses_init();
$window = ncurses_newwin(0, 0, 0, 0);
$caption = '';
$list = array();
$lastClear = time();
while (true) {
$time = time();
if ($time - $lastClear > 10) {
ncurses_clear();
$lastClear = $time;
}
$error = '';
if (msg_receive($queue, 0, $msgtype, 1024 * 1024, $msg, true, MSG_IPC_NOWAIT, $errorCode)) {
if (strlen($msg['caption']) > strlen($caption)) {
$caption = $msg['caption'];
}
$pid = $msg['pid'];
$isLast = $msg['isLast'];
unset($msg['pid'], $msg['isLast'], $msg['caption']);
$list[$pid] = $msg;
if (true === $isLast) {
unset($list[$pid]);
ncurses_clear();
if (empty($list)) {
break;
}
}
} else {
if ($errorCode != MSG_ENOMSG) {
$error = 'IPC receive error, errorCode=' . $errorCode;
}
}
$content = '';
$output = '';
foreach ($list as $k => $v) {
$content .= $v['content'] . "\n";
$output .= $v['output'] . "\n";
}
$str = trim($caption . "\n" . $content . "\n" . $output . "\n" . $error);
ncurses_move(0, 0);
ncurses_addstr($str);
ncurses_refresh();
if (isset($callback)) {
if (call_user_func($callback)) {
break;
}
}
usleep(100 * 1000);
}
ncurses_end();
msg_remove_queue($queue);
}
示例15: __destruct
public function __destruct()
{
ncurses_end();
ncurses_resetty();
}