/** * Down arrow binding. * Go forward in the history. * * @param \Hoa\Console\Readline $self Self. * @return int */ public function _bindArrowDown(Readline $self) { if (0 === (static::STATE_CONTINUE & static::STATE_NO_ECHO)) { Console\Cursor::clear('↔'); echo $self->getPrefix(); } $self->setBuffer($buffer = $self->nextHistory()); $self->setLine($buffer); return static::STATE_CONTINUE; }
/** * Down arrow binding. * Go forward in the history. * * @access public * @param \Hoa\Console\Readline $self Self. * @return int */ public function _bindArrowDown(Readline $self) { $line = $this->getLine(); // User is already at the newest line and must be confused if ($this->_historyCurrent === $this->_historySize) { $buffer = $this->workingLine = $this->getLine(); // User wants to resume where they left off before looking at history } else { if ($this->_historyCurrent + 1 === $this->_historySize) { $this->_historyCurrent++; $buffer = $this->workingLine; // User wants to venture into the past } else { $buffer = $self->nextHistory(); } } $self->setLine($buffer); $self->setBuffer($buffer); $mLines = substr_count($line, "\n"); Cursor::move('up', $mLines); Cursor::clear('line'); Cursor::clear('down', $mLines); if (0 === (static::STATE_CONTINUE & static::STATE_NO_ECHO)) { echo $self->getPrefix(); } $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; }