Answer the question
In order to leave comments, you need to log in
How to disable input buffering and echo output (termios.h, stdin)?
I want to make a console slider for a set of information, i.e. Need immediate response to key presses to switch slides.
Calling the setbuf(stdin, NULL) and setvbuf(stdin, NULL, _IONBF, 0) functions did not help me.
Prat's book talked about the ioctl function for unix-like systems. help me figure it out?
Thank you.
Answer the question
In order to leave comments, you need to log in
As far as I understand, you need to switch the terminal to raw mode.
To do this, you need to set a bunch of flags in struct termios and call tcsetattr (().
Here's how it is implemented in libuv:
struct termios tmp;
tmp.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
tmp.c_oflag |= (ONLCR);
tmp.c_cflag |= (CS8);
tmp.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
tmp.c_cc[VMIN] = 1;
tmp.c_cc[VTIME] = 0;
tcsetattr(fd, TCSADRAIN, &tmp);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question