Esempio n. 1
0
 /**
  * Control-W binding.
  * Delete first backward word.
  *
  * @access  public
  * @param   \Hoa\Console\Readline  $self    Self.
  * @return  int
  */
 public function _bindControlW(Readline $self)
 {
     $current = $self->getLineCurrent();
     if (0 === $current) {
         return static::STATE_CONTINUE;
     }
     $words = preg_split('#\\b#u', $self->getLine(), -1, PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_NO_EMPTY);
     for ($i = 0, $max = count($words) - 1; $i < $max && $words[$i + 1][1] < $current; ++$i) {
     }
     for ($j = $words[$i][1] + 1; $current >= $j; ++$j) {
         $self->_bindBackspace($self);
     }
     return static::STATE_CONTINUE;
 }