Beispiel #1
0
 /**
  * Up arrow binding.
  * Go backward in the history.
  *
  * @param   \Hoa\Console\Readline  $self    Self.
  * @return  int
  */
 public function _bindArrowUp(Readline $self)
 {
     if (0 === (static::STATE_CONTINUE & static::STATE_NO_ECHO)) {
         Console\Cursor::clear('↔');
         echo $self->getPrefix();
     }
     $self->setBuffer($buffer = $self->previousHistory());
     $self->setLine($buffer);
     return static::STATE_CONTINUE;
 }
Beispiel #2
0
 /**
  * Up arrow binding.
  * Go backward in the history.
  *
  * @access  public
  * @param   \Hoa\Console\Readline  $self    Self.
  * @return  int
  */
 public function _bindArrowUp(Readline $self)
 {
     if (0 === (static::STATE_CONTINUE & static::STATE_NO_ECHO)) {
         Cursor::clear('line');
         echo $self->getPrefix();
     }
     $line = $this->getLine();
     // User is working on something new, but decides to look at history
     if ($this->_historyCurrent === $this->_historySize) {
         // Save the current line so we can resume it
         $this->workingLine = $line;
     }
     $mLines = substr_count($line, "\n");
     Cursor::move('up', $mLines);
     Cursor::clear('LEFT');
     Cursor::clear('down', $mLines + 1);
     $buffer = $self->previousHistory();
     $self->setBuffer($buffer);
     $self->setLine($buffer);
     $bufLines = array();
     foreach (explode("\n", $buffer) as $i => $bufLine) {
         if ($i !== 0) {
             $bufLines[] = $this->prefixMore . $bufLine;
         } else {
             $bufLines[] = $bufLine;
         }
     }
     echo implode("\n", $bufLines);
     return static::STATE_CONTINUE | static::STATE_NO_ECHO;
 }