mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-07-15 00:08:07 -04:00
Added TaskManager app
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
// TaskManager.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstTaskManager.h"
|
||||
#include "Console.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <curses.h>
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
struct SetBufferMode
|
||||
{
|
||||
SetBufferMode();
|
||||
~SetBufferMode() {};
|
||||
};
|
||||
|
||||
SetBufferMode::SetBufferMode()
|
||||
{
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const char Console::getNextChar()
|
||||
{
|
||||
static SetBufferMode setBufferMode;
|
||||
char result = 0;
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(STDIN_FILENO, &rfds);
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
int ready = select(1, &rfds, 0, 0, &tv);
|
||||
if(ready)
|
||||
{
|
||||
result = static_cast<char>(getchar());
|
||||
if(result < 1)
|
||||
result = 0;
|
||||
}
|
||||
/*
|
||||
if(_kbhit())
|
||||
result = static_cast<char>(_getche());
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user