Optimized the terminal clear screen
This commit is contained in:
parent
1895dc001b
commit
33c03cf6fc
|
@ -9,7 +9,7 @@
|
||||||
static FVTerm* terminal;
|
static FVTerm* terminal;
|
||||||
|
|
||||||
// function prototype
|
// function prototype
|
||||||
void keyPressed();
|
bool keyPressed();
|
||||||
void term_boundaries (int&, int&);
|
void term_boundaries (int&, int&);
|
||||||
void move (int, int, int, int);
|
void move (int, int, int, int);
|
||||||
|
|
||||||
|
@ -17,18 +17,25 @@ void move (int, int, int, int);
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// functions
|
// functions
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void keyPressed()
|
bool keyPressed()
|
||||||
{
|
{
|
||||||
// Waiting for keypress
|
// Waiting for keypress
|
||||||
struct termios save, t;
|
struct termios save, t;
|
||||||
|
bool ret;
|
||||||
std::cout << "\nPress any key to continue...";
|
std::cout << "\nPress any key to continue...";
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
tcgetattr (STDIN_FILENO, &save);
|
tcgetattr (STDIN_FILENO, &save);
|
||||||
t = save;
|
t = save;
|
||||||
t.c_lflag &= uInt(~(ICANON | ECHO));
|
t.c_lflag &= uInt(~(ICANON | ECHO));
|
||||||
tcsetattr (STDIN_FILENO, TCSANOW, &t);
|
tcsetattr (STDIN_FILENO, TCSANOW, &t);
|
||||||
getchar();
|
|
||||||
|
if ( std::getchar() != EOF )
|
||||||
|
ret = true;
|
||||||
|
else
|
||||||
|
ret = false;
|
||||||
|
|
||||||
tcsetattr (STDIN_FILENO, TCSADRAIN, &save);
|
tcsetattr (STDIN_FILENO, TCSADRAIN, &save);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue