stop method

void stop()

Stops input handling, restores terminal to normal state, and exits the process.

This disables mouse reporting, restores console modes (Windows or POSIX), shows the cursor, and cancels the input subscription.

Implementation

void stop() {
  stdout.write('\x1B[?1006l\x1B[?1003l');

  if (Platform.isWindows) {
    _restoreWindowsConsoleMode();
  } else {
    if (stdin.hasTerminal) {
      stdin
        ..echoMode = true
        ..lineMode = true;
    }
  }

  stdout.write(
    '\x1B[?1049l',
  ); // TODO: make sure ONLY to handle this in full screen mode
  stdout.write('\x1B[?25h');
  stdout.write('\x1B[$returnedCursorPositionY;${returnedCursorPositionX}H');
  _stdinSubscription?.cancel();
  exit(0);
}