enableRawMode method

  1. @override
void enableRawMode()
override

Enables raw mode which allows us to process each keypress as it comes in. https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode.html

Implementation

@override
void enableRawMode() {
  if (_origTermIOSPointer == nullptr) {
    _captureOrigTermIOS();
  }

  if (Platform.isMacOS) {
    final origTermIOS = _origTermIOSPointer.cast<DarwinTermIOS>().ref;
    final newTermIOSPointer = calloc<DarwinTermIOS>();
    configureDarwinRawTermIOS(origTermIOS, newTermIOSPointer.ref);
    _tcsetattr(_fd, _TCSANOW, newTermIOSPointer.cast());
    calloc.free(newTermIOSPointer);
  } else {
    final origTermIOS = _origTermIOSPointer.cast<LinuxTermIOS>().ref;
    final newTermIOSPointer = calloc<LinuxTermIOS>();
    configureLinuxRawTermIOS(origTermIOS, newTermIOSPointer.ref);
    _tcsetattr(_fd, _TCSANOW, newTermIOSPointer.cast());
    calloc.free(newTermIOSPointer);
  }
}