summaryrefslogtreecommitdiff
path: root/conio.h
diff options
context:
space:
mode:
Diffstat (limited to 'conio.h')
-rw-r--r--conio.h18
1 files changed, 14 insertions, 4 deletions
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;
+}