示例#1
0
 public function pause()
 {
     if (!$this->listening) {
         return;
     }
     readline_callback_handler_remove();
     $this->loop->removeReadStream(STDIN);
 }
示例#2
0
 function rl_callback($ret)
 {
     if ($ret != "") {
         $this->command($ret);
         readline_add_history($ret);
         array_push($this->history, $ret);
     }
     if ($ret == "exit") {
         $this->prompting = false;
         readline_callback_handler_remove();
     } else {
         $this->install_handler();
     }
 }
示例#3
0
 /**
  * Remove readline callback handler on destruct.
  */
 public function __destruct()
 {
     // PHP didn't implement the whole readline API when they first switched
     // to libedit. And they still haven't.
     //
     // So this is a thing to make PsySH work on 5.3.x:
     if (function_exists('readline_callback_handler_remove')) {
         readline_callback_handler_remove();
     }
 }
function readline_callback($ret)
{
    global $readline, $prompt_finished;
    $readline = $ret;
    $prompt_finished = TRUE;
    readline_callback_handler_remove();
}
示例#5
0
 public function run()
 {
     if ($this->readline) {
         readline_callback_handler_install("Genisys> ", [$this, "readline_callback"]);
         $this->logger->setConsoleCallback("readline_redisplay");
     }
     while (!$this->shutdown) {
         $r = [$this->stdin];
         $w = null;
         $e = null;
         if (stream_select($r, $w, $e, 0, 200000) > 0) {
             // PHP on Windows sucks
             if (feof($this->stdin)) {
                 if (Utils::getOS() == "win") {
                     $this->stdin = fopen("php://stdin", "r");
                     if (!is_resource($this->stdin)) {
                         break;
                     }
                 } else {
                     break;
                 }
             }
             $this->readLine();
         }
     }
     if ($this->readline) {
         $this->logger->setConsoleCallback(null);
         readline_callback_handler_remove();
     }
 }
function getInput()
{
    readline_callback_handler_remove();
    return readline();
}
示例#7
0
 /**
  * Restore the default readline handler
  *
  * @return $this
  */
 protected function restoreReadlineHandler()
 {
     readline_callback_handler_remove();
     return $this;
 }
示例#8
0
文件: iphp.php 项目: bermi/akelos
 private function realReadline()
 {
     $this->inReadline = true;
     while ($this->inReadline) {
         $w = NULL;
         $e = NULL;
         $r = array(STDIN);
         $n = @stream_select($r, $w, $e, NULL);
         // @ to silence warning on ctl-c
         // detect ctl-c or other signal (causes stream_select to exit with FALSE)
         if ($n === false) {
             readline_callback_handler_remove();
             print "\n";
             readline_callback_handler_install($this->inputPrompt, array($this, 'doCommand'));
         }
         if (in_array(STDIN, $r)) {
             readline_callback_read_char();
         }
     }
 }
function foo()
{
    readline_callback_handler_remove();
}
示例#10
0
 /**
  * @codeCoverageIgnore
  */
 public function unsetStreamBlocking()
 {
     // normalize console behavior first
     stream_set_blocking(STDIN, 1);
     if ($this->hasReadline) {
         readline_callback_handler_remove();
     }
 }
<?php

var_dump(readline_callback_handler_remove());
var_dump(readline_callback_handler_install('testing: ', 'foo'));
function foo()
{
}
var_dump(readline_callback_handler_install('testing: ', 'foo'));
var_dump(readline_callback_handler_remove());
示例#12
0
 public static function getLine()
 {
     readline_callback_handler_remove();
     return readline();
 }
示例#13
0
 /**
  * call-back for readline
  */
 function gotInput($in)
 {
     $in = trim($in);
     if ($in == '') {
         return;
     }
     $this->gettingInput = TRUE;
     $this->cmd->callCommand($in);
     if ($GLOBALS['DIE']) {
         readline_callback_handler_remove();
         return;
     }
     readline_add_history($in);
     readline_callback_handler_install($this->prompt, array($this, "gotInput"));
     $this->gettingInput = FALSE;
 }