예제 #1
0
 public function bindBackspace(Readline $self)
 {
     $cursor = '';
     if ($self->getLineCurrent() > 0) {
         if ($self->getLineLength() == ($current = $self->getLineCurrent())) {
             $self->setLine(mb_substr($self->getLine(), 0, -1));
         } else {
             $line = $self->getLine();
             $current = $self->getLineCurrent();
             $tail = mb_substr($line, $current);
             $movecursor = $self->getLineLength() - $current;
             $cursor = "[{$movecursor}D";
             $self->setLine(mb_substr($line, 0, $current - 1) . $tail);
             $self->setLineCurrent($current - 1);
         }
     }
     $prefix = $self->getPrefix();
     $self->clearTerminalLine();
     $self->setBuffer("\r" . $prefix . $self->getLine() . $cursor);
     return $self::READ_CONTINUE;
 }