isMultilineMode()) { $buffer->clear(); return true; } if ($buffer->isEmpty()) { $now = \time(); $timeSinceLastCtrlC = $now - self::$lastEmptyCtrlCTime; // If Ctrl-C pressed twice within timeout, show exit hint if (self::$lastEmptyCtrlCTime > 0 && $timeSinceLastCtrlC <= self::HINT_TIMEOUT) { $terminal->write("\r"); $terminal->clearToEndOfLine(); $terminal->writeFormatted('(Press Ctrl-D to exit, or type \'exit\')'); $terminal->write("\n"); self::$lastEmptyCtrlCTime = 0; // Reset to avoid showing hint repeatedly } else { $terminal->bell(); self::$lastEmptyCtrlCTime = $now; } return true; } $buffer->clear(); self::$lastEmptyCtrlCTime = 0; return true; } /** * {@inheritdoc} */ public function getName(): string { return 'clear-buffer'; } }