From b52f4ee7e7d6deccc64576d8ab7daa056451cebf Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Mon, 6 Feb 2023 01:14:33 -0800 Subject: actually works now --- conio.c | 15 --------------- conio.h | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 conio.c diff --git a/conio.c b/conio.c deleted file mode 100644 index 9b87cc9..0000000 --- a/conio.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "./conio.h" -#include -#include -#include -int getch(void) { - struct termios oldattr, newattr; - int ch; - tcgetattr(STDIN_FILENO, &oldattr); - newattr = oldattr; - newattr.c_lflag &= ~(ICANON | ECHO); - tcsetattr(STDIN_FILENO, TCSANOW, &newattr); - ch = getchar(); - tcsetattr(STDIN_FILENO, TCSANOW, &oldattr); - return ch; -} diff --git a/conio.h b/conio.h index eee033c..fa866f2 100644 --- a/conio.h +++ b/conio.h @@ -1,4 +1,14 @@ -#ifndef CONIO_H -#define CONIO_H -int getch(void); -#endif +#include +#include +#include +int getch(void) { + struct termios oldattr, newattr; + int ch; + tcgetattr(STDIN_FILENO, &oldattr); + newattr = oldattr; + newattr.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newattr); + ch = getchar(); + tcsetattr(STDIN_FILENO, TCSANOW, &oldattr); + return ch; +} -- cgit v1.3.1