I am trying to use the atexit()
in C++ with a class method as the parameter. Is this possible or should I try using something else.
void Editor::disableRawMode(){
if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &this->conf.orig_termios) == -1){
makeError(ErrorType::RawModeErr, "tcgetattr");
}
}
void Editor::enableRawMode(){
if(tcgetattr(STDIN_FILENO, &this->conf.orig_termios) == -1){
makeError(ErrorType::RawModeErr, "tcgetattr");
}
std::atexit(disableRawMode);
struct termios raw = this->conf.orig_termios;
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~(OPOST);
raw.c_cflag |= (CS8);
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
raw.c_cc[VMIN] = 0;
raw.c_cc[VTIME] = 1;
if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1){
makeError(ErrorType::RawModeErr, "tcgetattr");
}
}