MCPcopy Create free account
hub / github.com/anjo76/angelscript / getch

Function getch

sdk/samples/include/source/main.cpp:43–57  ·  view source on GitHub ↗

Linux does have a getch() function in the curses library, but it doesn't work like it does on DOS. So this does the same thing, without the need of the curses library.

Source from the content-addressed store, hash-verified

41// work like it does on DOS. So this does the same thing, without the need
42// of the curses library.
43int getch()
44{
45 struct termios oldt, newt;
46 int ch;
47
48 tcgetattr(STDIN_FILENO, &oldt);
49 newt = oldt;
50 newt.c_lflag &= ~( ICANON | ECHO );
51 tcsetattr( STDIN_FILENO, TCSANOW, &newt );
52
53 ch = getchar();
54
55 tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
56 return ch;
57}
58
59#endif
60

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected