本文整理汇总了PHP中posix_isatty函数的典型用法代码示例。如果您正苦于以下问题:PHP posix_isatty函数的具体用法?PHP posix_isatty怎么用?PHP posix_isatty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了posix_isatty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_tty
public static function is_tty()
{
if (self::$is_tty === null) {
self::$is_tty = function_exists('posix_isatty') ? posix_isatty(STDOUT) : false;
}
return self::$is_tty;
}
示例2: __construct
/**
* Initializes default configuration.
*/
public function __construct()
{
$templateDir = self::isInstalledByPear() ? '@data_dir@' . DIRECTORY_SEPARATOR . 'ApiGen' : realpath(__DIR__ . DIRECTORY_SEPARATOR . '..');
self::$defaultConfig['templateConfig'] = $templateDir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'config.neon';
self::$defaultConfig['colors'] = 'WIN' === substr(PHP_OS, 0, 3) ? false : (function_exists('posix_isatty') && defined('STDOUT') ? posix_isatty(STDOUT) : true);
$this->config = self::$defaultConfig;
}
示例3: isSupported
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon, ConEmu or Babun
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
*
* @link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L95-L102
* @codeCoverageIgnore
*/
public function isSupported()
{
if (DIRECTORY_SEPARATOR == '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || false !== getenv('BABUN_HOME');
}
return false !== getenv('BABUN_HOME') || function_exists('posix_isatty') && @posix_isatty(STDOUT);
}
示例4: supports_colour
static function supports_colour()
{
if (!defined('STDOUT')) {
define('STDOUT', fopen("php://stdout", "w"));
}
return @posix_isatty(STDOUT);
}
示例5: __construct
function __construct()
{
if (DIRECTORY_SEPARATOR == '\\' || !function_exists('posix_isatty') || !@posix_isatty(STDOUT)) {
self::$colorizedOutputSupported = false;
}
$this->registerStyle('PARAMETER', array('fg' => 'cyan'))->registerStyle('COMMENT', array('fg' => 'green'))->registerStyle('INFO', array('fg' => 'blue'))->registerStyle('WARNING', array('fg' => 'magenta'))->registerStyle('ERROR', array('fg' => 'red', 'bold' => true))->registerStyle('ACTION_DELETE', array('fg' => 'red'))->registerStyle('BOLD', array('bold' => true))->registerStyle('ITALIC', array('italic' => true));
}
示例6: setupColors
/**
* Configures colored output.
* @return void
*/
public static function setupColors()
{
self::$useColors = getenv(self::COLORS) !== FALSE ? (bool) getenv(self::COLORS) : (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (function_exists('posix_isatty') && posix_isatty(STDOUT) || getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE) || getenv('TERM') === 'xterm-256color';
ob_start(function ($s) {
return self::$useColors ? $s : Dumper::removeColors($s);
}, 1, FALSE);
}
示例7: hasColorSupport
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
*/
protected function hasColorSupport()
{
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
return function_exists('posix_isatty') && @posix_isatty($this->stream);
}
示例8: hasColorSupport
/**
* Code from Symfony/Component/Console/Output/StreamOutput.php
*/
function hasColorSupport()
{
if (DIRECTORY_SEPARATOR == '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
}
return function_exists('posix_isatty') && @posix_isatty(STDOUT);
}
示例9: isInteractive
public function isInteractive()
{
if (null === $this->isInteractive) {
$this->isInteractive = 'cli' === php_sapi_name() && (function_exists('posix_isatty') && @posix_isatty(STDOUT) || 'ON' === getenv('ConEmuANSI') || false !== getenv('ANSICON'));
}
return $this->isInteractive;
}
示例10: setupColors
/**
* Configures colored output.
* @return void
*/
public static function setupColors()
{
self::$useColors = getenv(self::COLORS) !== FALSE ? (bool) getenv(self::COLORS) : PHP_SAPI === 'cli' && (function_exists('posix_isatty') && posix_isatty(STDOUT) || getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE);
ob_start(function ($s) {
return Environment::$useColors ? $s : Dumper::removeColors($s);
}, PHP_VERSION_ID < 50400 ? 2 : 1);
}
示例11: supportsAnsi
/**
* {@inheritdoc}
*/
public function supportsAnsi()
{
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
}
return function_exists('posix_isatty') && @posix_isatty($this->stream);
}
示例12: call_phing
public static function call_phing($task, $target, $build_file = '', $options = array())
{
$args = array();
foreach ($options as $key => $value) {
$args[] = "-D{$key}={$value}";
}
if ($build_file) {
$args[] = '-f';
$args[] = realpath($build_file);
}
if (!$task->is_verbose()) {
$args[] = '-q';
}
if (is_array($target)) {
$args = array_merge($args, $target);
} else {
$args[] = $target;
}
if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) {
$args[] = '-logger';
$args[] = 'phing.listener.AnsiColorLogger';
}
Phing::startup();
Phing::setProperty('phing.home', getenv('PHING_HOME'));
$m = new pakePhing();
$m->execute($args);
$m->runBuild();
}
示例13: __construct
/**
* Initialize
* @param array
* @param array
* @param array
* @param Executor
* @param bool
*/
public function __construct(array $argv, array $envp, array $descriptors, Executor $executor, $interactive = NULL)
{
$this->argv = $argv;
$this->envp = $envp;
if (!isset($this->envp['PS1'])) {
$this->envp['PS1'] = self::DEFAULT_PS1;
}
if (!isset($this->envp['PS2'])) {
$this->envp['PS2'] = self::DEFAULT_PS2;
}
$this->descriptors = $descriptors;
list($this->stdin, $this->stdout, $this->stderr) = $this->descriptors;
$this->executor = $executor;
if (!is_bool($interactive)) {
$interactive = FALSE;
if (function_exists('posix_isatty') && @posix_isatty($descriptors[0])) {
$interactive = TRUE;
}
}
$this->interactive = $interactive;
if ($this->interactive) {
$descriptors[0] = fopen('sh-interactiveinput://', NULL, FALSE, stream_context_create(array('sh-interactiveinput' => array('handle' => $this->stdin, 'out' => $this->stdout))));
$this->descriptors[1] = fopen('sh-interactiveoutput://', NULL, FALSE, stream_context_create(array('sh-interactiveoutput' => array('handle' => $this->descriptors[1]))));
$this->descriptors[2] = fopen('sh-interactiveoutput://', NULL, FALSE, stream_context_create(array('sh-interactiveoutput' => array('handle' => $this->descriptors[2]))));
}
}
示例14: run
public function run()
{
$method = $this->getArgument('method', array());
if (count($method) !== 1) {
throw new ArcanistUsageException(pht('Provide exactly one Conduit method name.'));
}
$method = reset($method);
$console = PhutilConsole::getConsole();
if (!function_exists('posix_isatty') || posix_isatty(STDIN)) {
$console->writeErr("%s\n", pht('Waiting for JSON parameters on stdin...'));
}
$params = @file_get_contents('php://stdin');
try {
$params = phutil_json_decode($params);
} catch (PhutilJSONParserException $ex) {
throw new ArcanistUsageException(pht('Provide method parameters on stdin as a JSON blob.'));
}
$error = null;
$error_message = null;
try {
$result = $this->getConduit()->callMethodSynchronous($method, $params);
} catch (ConduitClientException $ex) {
$error = $ex->getErrorCode();
$error_message = $ex->getMessage();
$result = null;
}
echo json_encode(array('error' => $error, 'errorMessage' => $error_message, 'response' => $result)) . "\n";
return 0;
}
示例15: run
public function run($folder)
{
set_time_limit(0);
$this->useColors = PHP_SAPI === 'cli' && (function_exists('posix_isatty') && posix_isatty(STDOUT) || getenv('ConEmuANSI') === 'ON' || getenv('ANSICON') !== FALSE);
if ($this->readOnly) {
echo "Running in read-only mode\n";
}
echo "Scanning folder {$this->color('white', $folder)}\n";
$counter = 0;
$success = TRUE;
foreach (Nette\Utils\Finder::findFiles($this->accept)->exclude($this->ignore)->from($folder)->exclude($this->ignore) as $file) {
echo str_pad(str_repeat('.', $counter++ % 40), 40), "\r";
$orig = $s = file_get_contents($file);
$this->file = ltrim(substr($file, strlen($folder)), '/\\');
$this->error = FALSE;
foreach ($this->tasks as $task) {
$res = $task($this, $s);
if ($this->error) {
$success = FALSE;
continue 2;
} elseif (is_string($res)) {
$s = $res;
}
}
if ($s !== $orig && !$this->readOnly) {
file_put_contents($file, $s);
}
}
echo str_pad('', 40), "\rDone.\n";
return $success;
}