Optimized the terminal clear screen

This commit is contained in:
Markus Gans 2016-11-26 18:40:50 +01:00
parent 1895dc001b
commit 33c03cf6fc
1 changed files with 10 additions and 3 deletions

View File

@ -9,7 +9,7 @@
static FVTerm* terminal;
// function prototype
void keyPressed();
bool keyPressed();
void term_boundaries (int&, int&);
void move (int, int, int, int);
@ -17,18 +17,25 @@ void move (int, int, int, int);
//----------------------------------------------------------------------
// functions
//----------------------------------------------------------------------
void keyPressed()
bool keyPressed()
{
// Waiting for keypress
struct termios save, t;
bool ret;
std::cout << "\nPress any key to continue...";
fflush(stdout);
tcgetattr (STDIN_FILENO, &save);
t = save;
t.c_lflag &= uInt(~(ICANON | ECHO));
tcsetattr (STDIN_FILENO, TCSANOW, &t);
getchar();
if ( std::getchar() != EOF )
ret = true;
else
ret = false;
tcsetattr (STDIN_FILENO, TCSADRAIN, &save);
return ret;
}
//----------------------------------------------------------------------