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() {
  final origTermIOS = _origTermIOSPointer.ref;
  final newTermIOSPointer = calloc<TermIOS>()
    ..ref.c_iflag =
        origTermIOS.c_iflag & ~(_BRKINT | _ICRNL | _INPCK | _ISTRIP | _IXON)
    ..ref.c_oflag = origTermIOS.c_oflag & ~_OPOST
    ..ref.c_cflag = (origTermIOS.c_cflag & ~_CSIZE) | _CS8
    ..ref.c_lflag = origTermIOS.c_lflag & ~(_ECHO | _ICANON | _IEXTEN | _ISIG)
    ..ref.c_cc = origTermIOS.c_cc
    ..ref.c_cc[_VMIN] = 0
    ..ref.c_cc[_VTIME] = 1
    ..ref.c_ispeed = origTermIOS.c_ispeed
    ..ref.c_oflag = origTermIOS.c_ospeed;

  _tcsetattr(_STDIN_FILENO, _TCSANOW, newTermIOSPointer);
  calloc.free(newTermIOSPointer);
}