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

Function getch

sdk/samples/tutorial/source/main.cpp:36–50  ·  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, with out the need of the curses library.

Source from the content-addressed store, hash-verified

34// work like it does on DOS. So this does the same thing, with out the need
35// of the curses library.
36int getch()
37{
38 struct termios oldt, newt;
39 int ch;
40
41 tcgetattr(STDIN_FILENO, &oldt);
42 newt = oldt;
43 newt.c_lflag &= ~( ICANON | ECHO );
44 tcsetattr( STDIN_FILENO, TCSANOW, &newt );
45
46 ch = getchar();
47
48 tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
49 return ch;
50}
51
52#endif
53

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected