enabled raw mode with no echo, character input rather than line input, ignore to stop build files being pushed
This commit is contained in:
30
kilo.c
30
kilo.c
@@ -1,8 +1,28 @@
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main() {
|
||||
char c;
|
||||
while (read(STDIN_FILENO, &c, 1) == 1)
|
||||
;
|
||||
return 0;
|
||||
struct termios orig_termios;
|
||||
|
||||
void disableRawMode() {
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
|
||||
}
|
||||
|
||||
void enableRawMode() {
|
||||
tcgetattr(STDIN_FILENO, &orig_termios);
|
||||
atexit(disableRawMode);
|
||||
|
||||
struct termios raw = orig_termios;
|
||||
raw.c_lflag &= ~(ECHO);
|
||||
raw.c_lflag &= ~(ICANON);
|
||||
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
|
||||
}
|
||||
|
||||
int main() {
|
||||
enableRawMode();
|
||||
|
||||
char c;
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != 'q');
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user