enableRawMode method

  1. @override
void enableRawMode()
override

Switches the terminal into raw mode, disabling line buffering and echo so individual key presses can be read immediately.

Implementation

@override
void enableRawMode() {
  if (!_stdin.hasTerminal) return;
  // On Windows, Dart's stdin does not deliver arrow keys, Escape, etc. unless
  // the console is put into virtual-terminal input mode. Manage the console
  // mode directly there; fall back to the line/echo toggles if that fails.
  if (Platform.isWindows) {
    final previous = WindowsConsole.enableRawVirtualTerminal();
    if (previous != null) {
      _previousWindowsModes = previous;
      return;
    }
  }
  _previousEchoMode = _stdin.echoMode;
  _previousLineMode = _stdin.lineMode;
  // Disabling line mode also disables echo on Windows; set echo first to
  // avoid a transient state where input is echoed.
  _stdin.echoMode = false;
  _stdin.lineMode = false;
}