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


PHP readline_info函数代码示例

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


在下文中一共展示了readline_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: autocompleter

 /**
  * Tries to return autocompletion for the current entered text.
  *
  * @param string  $text     The last segment of the entered text
  * @param integer $position The current position
  */
 protected function autocompleter($text, $position)
 {
     $info = readline_info();
     $text = substr($info['line_buffer'], 0, $info['end']);
     if ($info['point'] !== $info['end']) {
         return true;
     }
     // task name?
     if (false === strpos($text, ' ') || !$text) {
         return array_keys($this->application->getCommands());
     }
     // options and arguments?
     try {
         $command = $this->application->findCommand(substr($text, 0, strpos($text, ' ')));
     } catch (\Exception $e) {
         return true;
     }
     $list = array('--help');
     foreach ($command->getDefinition()->getOptions() as $option) {
         $list[] = '--' . $option->getName();
     }
     if (method_exists($command, 'getAutocompleteValues')) {
         foreach ($command->getAutocompleteValues() as $value) {
             $list[] = $value;
         }
     }
     return $list;
 }
开发者ID:KernelMadness,项目名称:ContainerKit,代码行数:34,代码来源:Shell.php

示例2: get_real_keyword

	protected static function get_real_keyword($keyword) {
		$info = readline_info();
		
		if(!is_array($info) or !isset($info['pending_input']))
			return $keyword;
		
		return substr($info['line_buffer'], 0, $info['end']);
	}
开发者ID:rATRIJS,项目名称:AIP,代码行数:8,代码来源:Completor.php

示例3: _initCompletion

 protected static function _initCompletion()
 {
     self::$_readlineFile = sys_get_temp_dir() . '/phputils-data-history';
     // init read line
     readline_info('readline_name', 'data');
     readline_completion_function([__CLASS__, 'readlineCompletion']);
     is_file(self::$_readlineFile) and readline_read_history(self::$_readlineFile);
 }
开发者ID:ligro,项目名称:php-utils,代码行数:8,代码来源:cli.php

示例4: complete

 /**
  * @param string $input
  * @param int $index
  * @return array|bool
  */
 public function complete($input, $index)
 {
     $configuration = $this->configuration;
     if ($index == 0) {
         $completion = array_keys($configuration);
     } else {
         $buffer = preg_replace('/\\s+/', ' ', trim(readline_info('line_buffer')));
         $tokens = explode(' ', $buffer);
         $completion = $this->fetchCompletion($configuration, $tokens);
     }
     return $completion;
 }
开发者ID:bazzline,项目名称:php_component_cli_readline,代码行数:17,代码来源:Autocomplete.php

示例5: info

 function info()
 {
     $config = new Configuration();
     $core = array('PsySH version' => Shell::VERSION, 'PHP version' => PHP_VERSION, 'default includes' => $config->getDefaultIncludes(), 'require semicolons' => $config->requireSemicolons(), 'error logging level' => $config->errorLoggingLevel(), 'config file' => array('default config file' => $config->getConfigFile(), 'local config file' => $config->getLocalConfigFile(), 'PSYSH_CONFIG env' => getenv('PSYSH_CONFIG')));
     if ($config->hasReadline()) {
         $info = readline_info();
         $readline = array('readline available' => true, 'readline enabled' => $config->useReadline(), 'readline service' => get_class($config->getReadline()), 'readline library' => $info['library_version']);
         if ($info['readline_name'] !== '') {
             $readline['readline name'] = $info['readline_name'];
         }
     } else {
         $readline = array('readline available' => false);
     }
     $pcntl = array('pcntl available' => function_exists('pcntl_signal'), 'posix available' => function_exists('posix_getpid'));
     $history = array('history file' => $config->getHistoryFile(), 'history size' => $config->getHistorySize(), 'erase duplicates' => $config->getEraseDuplicates());
     $docs = array('manual db file' => $config->getManualDbFile(), 'sqlite available' => true);
     try {
         if ($db = $config->getManualDb()) {
             if ($q = $db->query('SELECT * FROM meta;')) {
                 $q->setFetchMode(\PDO::FETCH_KEY_PAIR);
                 $meta = $q->fetchAll();
                 foreach ($meta as $key => $val) {
                     switch ($key) {
                         case 'built_at':
                             $d = new \DateTime('@' . $val);
                             $val = $d->format(\DateTime::RFC2822);
                             break;
                     }
                     $key = 'db ' . str_replace('_', ' ', $key);
                     $docs[$key] = $val;
                 }
             } else {
                 $docs['db schema'] = '0.1.0';
             }
         }
     } catch (Exception\RuntimeException $e) {
         if ($e->getMessage() === 'SQLite PDO driver not found') {
             $docs['sqlite available'] = false;
         } else {
             throw $e;
         }
     }
     $autocomplete = array('tab completion enabled' => $config->getTabCompletion(), 'custom matchers' => array_map('get_class', $config->getTabCompletionMatchers()));
     return array_merge($core, compact('pcntl', 'readline', 'history', 'docs', 'autocomplete'));
 }
开发者ID:saj696,项目名称:pipe,代码行数:45,代码来源:functions.php

示例6: _rlAutoCompleteProxy

 /**
  * @brief Proxy for autocomplete calls
  * @internal
  */
 static function _rlAutoCompleteProxy($input, $index)
 {
     // Collect some information and perform the call if we have a completer
     // assigned.
     $info = readline_info();
     if (self::$completer) {
         $matches = self::$completer->complete($input, $index, $info);
     } else {
         // Maybe return true here if no data would help from the crash?
         $matches = array();
     }
     // Check the number of matches, and push a null character if empty,
     // in order to avoid the php segfault bug.
     if (count($matches) == 0) {
         $matches[] = chr(0);
     }
     // Return the data
     return $matches;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:23,代码来源:console.php

示例7: readline_completion_impl

function readline_completion_impl($string, $index)
{
    $readline_info = readline_info();
    $line = substr($readline_info['line_buffer'], 0, $readline_info['end']);
    $parts = Helper_Common::parseCommand($line);
    $candidates = array();
    if (empty($parts)) {
        // no input yet, just return list of helper functions
        $candidates += array_keys($GLOBALS['HELPERS']);
    } else {
        if (isset($GLOBALS['HELPERS'][$parts[0]])) {
            // we actually got the helper function correctly
            $PARAMS = array_slice($parts, 1);
            $IS_COMPLETION = true;
            require $GLOBALS['HELPERS'][$parts[0]];
        } else {
            // incomplete helper function...
            $candidates += array_keys($GLOBALS['HELPERS']);
        }
    }
    return $candidates;
}
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:22,代码来源:xf-helper.php

示例8: var_dump

<?php

var_dump(@readline_info());
var_dump(@readline_info(1));
var_dump(@readline_info(1, 1));
var_dump(@readline_info('line_buffer'));
var_dump(@readline_info('readline_name'));
var_dump(@readline_info('readline_name', 1));
var_dump(@readline_info('readline_name'));
var_dump(@readline_info('attempted_completion_over', 1));
var_dump(@readline_info('attempted_completion_over'));
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:libedit_info_001.php

示例9: writeln

 /**
  * prints a line to stdout
  */
 function writeln($s)
 {
     if ($this->hide) {
         return;
     }
     if ($this->promptShown && !$this->gettingInput) {
         /* something will be displayed, so remove the prompt */
         // see how long the text is
         $l = readline_info('end') + strlen($this->prompt);
         // remove it
         $this->write("\r" . str_repeat(' ', $l) . "\r");
         $this->promptShown = FALSE;
     }
     $this->write("{$s}\n");
 }
开发者ID:stegru,项目名称:pebugger,代码行数:18,代码来源:pebugger.php

示例10: autocomplete

 /**
  * Autocomplete variable names.
  *
  * This is used by `readline` for tab completion.
  *
  * @param string $text
  *
  * @return mixed Array possible completions for the given input, if any.
  */
 protected function autocomplete($text)
 {
     $info = readline_info();
     // $line = substr($info['line_buffer'], 0, $info['end']);
     // Check whether there's a command for this
     // $words = explode(' ', $line);
     // $firstWord = reset($words);
     // check whether this is a variable...
     $firstChar = substr($info['line_buffer'], max(0, $info['end'] - strlen($text) - 1), 1);
     if ($firstChar === '$') {
         return $this->getScopeVariableNames();
     }
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:22,代码来源:Shell.php

示例11: readline_predefined

function readline_predefined($prompt, $predefined_text = "")
{
    global $readline, $prompt_finished;
    readline_callback_handler_install($prompt, 'readline_callback');
    for ($i = 0; $i < strlen($predefined_text); $i++) {
        readline_info('pending_input', substr($predefined_text, $i, 1));
        readline_callback_read_char();
    }
    $readline = FALSE;
    $prompt_finished = FALSE;
    while (!$prompt_finished) {
        readline_callback_read_char();
    }
    return $readline;
}
开发者ID:Moouseer,项目名称:yetorm-structure,代码行数:15,代码来源:yetorm-build-auto.php

示例12: getVar

 /**
  * Get an internal readline variable
  *
  * @param   const name e.g. RL_LIBRARY_VERSION
  * @return  string
  */
 public function getVar($name)
 {
     return readline_info($name);
 }
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:10,代码来源:ReadLine.class.php

示例13: autocompleter

 /**
  * Tries to return autocompletion for the current entered text.
  *
  *
  * @return bool|array A list of guessed strings or true
  *                    @codeCoverageIgnore
  */
 private function autocompleter()
 {
     $info = readline_info();
     $text = substr($info['line_buffer'], 0, $info['end']);
     if ($info['point'] !== $info['end']) {
         return true;
     }
     // task name?
     if (false === strpos($text, ' ') || !$text) {
         $commands = array_keys($this->application->all());
         $commands[] = 'quit';
         $commands[] = 'all';
         return $commands;
     }
     // options and arguments?
     try {
         $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
     } catch (\Exception $e) {
         return true;
     }
     $list = array('--help');
     foreach ($command->getDefinition()->getOptions() as $option) {
         $opt = '--' . $option->getName();
         if (!in_array($opt, $list)) {
             $list[] = $opt;
         }
     }
     return $list;
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:36,代码来源:Shell.php

示例14: readline

<?php

//get 3 commands from user
for ($i = 0; $i < 3; $i++) {
    $line = readline("Command: ");
    readline_add_history($line);
}
//dump history
print_r(readline_list_history());
//dump variables
print_r(readline_info());
开发者ID:exakat,项目名称:exakat,代码行数:11,代码来源:Extreadline.01.php

示例15: readio_readline

 /**
  * 可以处理IO的readline
  */
 public function readio_readline($prompt)
 {
     readline_callback_handler_install($prompt, array($this, 'readio_handler'));
     $this->_inputLine = '';
     $this->_inputFinished = false;
     while (!$this->_inputFinished) {
         $w = NULL;
         $e = NULL;
         $r = array(STDIN);
         $n = @stream_select($r, $w, $e, null);
         // var_dump($n, $r, $w, $e);
         if ($n === false) {
             // echo "io incrupt\n";
             // exit;
         } else {
             if ($n && in_array(STDIN, $r)) {
                 // read a character, will call the callback when a newline is entered
                 readline_callback_read_char();
                 $rli = readline_info();
                 // print_r($rli);
             }
         }
     }
     return $this->_inputLine;
 }
开发者ID:kitech,项目名称:triline,代码行数:28,代码来源:htshc.php


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