summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-02-06 01:14:33 -0800
committerPreston Pan <preston@nullring.xyz>2023-02-06 01:14:33 -0800
commitb52f4ee7e7d6deccc64576d8ab7daa056451cebf (patch)
tree012962b05d0c968ebf1e56d41f4828f4d0fdcc9c
parent6c543f17f2ce8474955673e0fff7d26a90446a0a (diff)
actually works now
-rw-r--r--conio.c15
-rw-r--r--conio.h18
2 files changed, 14 insertions, 19 deletions
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 <termios.h>
-#include <unistd.h>
-#include <stdio.h>
-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 <termios.h>
+#include <unistd.h>
+#include <stdio.h>
+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;
+}