-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathterminal.cpp
More file actions
44 lines (33 loc) · 778 Bytes
/
terminal.cpp
File metadata and controls
44 lines (33 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "terminal.h"
#include <stdio.h>
#include <termios.h>
using namespace std;
termios termSettings;
void initStdin(termios &settings)
{
tcgetattr(0, &settings);
termios newSettings = settings;
newSettings.c_lflag &= (~ICANON);
newSettings.c_lflag &= (~ECHO);
//newSettings.c_lflag &= (~ISIG);
newSettings.c_cc[VTIME] = 0;//1; // timeout (tenths of a second)
newSettings.c_cc[VMIN] = 0; // minimum number of characters
// apply the new settings
tcsetattr(0, TCSANOW, &newSettings);
}
void deinitStdin(const termios &settings)
{
tcsetattr(0, TCSANOW, &settings);
}
void initTerminal()
{
initStdin(termSettings);
}
void uninitTerminal()
{
deinitStdin(termSettings);
}
int getTerminalChar()
{
return getchar();
}