summaryrefslogtreecommitdiff
path: root/src/conio.c
blob: b69f087c3c219e66fc58061d52668da8edb13a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "conio.h"
#include <termios.h>
#include <unistd.h> 
#include <stdio.h> 

int getch() {
	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;
}