Trying to translate `NewSettings.c_lflag &= ~(...
# kotlin-native
n
Trying to translate
NewSettings.c_lflag &= ~( ICANON | ECHO );
(C language) to Kotlin, and have hit a brick wall 🧱 with the bit manipulation since there appears to be some bit manipulation operations that can't be done in Kotlin, unless there are some workarounds available. Below is the full C code I am trying to translate into Kotlin:
Copy code
#include <termios.h>
static struct termios OriginalSettings, NewSettings;
void terminal_setup()
{
    tcgetattr(STDIN_FILENO, &OriginalSettings);
    NewSettings = OriginalSettings;
    NewSettings.c_lflag &= ~( ICANON | ECHO );
    tcsetattr(STDIN_FILENO, TCSANOW, &NewSettings);
    printf("\e[?25l");
}
void terminal_reset()
{
    tcsetattr (STDIN_FILENO, TCSAFLUSH, &OriginalSettings);
}
m
I'd do something like:
Copy code
val settings = alloc<termios>()
      settings.c_cflag = settings.c_cflag.and(ICANON.or(ECHO).inv().toULong())
That's modulo the
toULong()
not overflowing or so but it should work?