Initial Commit
This commit is contained in:
89
common/CONSOLE.HPP
Normal file
89
common/CONSOLE.HPP
Normal file
@@ -0,0 +1,89 @@
|
||||
#if defined(__FLAT__)
|
||||
#ifndef _COMMON_CONSOLE_HPP_
|
||||
#define _COMMON_CONSOLE_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_SCREENBUFFERINFO_HPP_
|
||||
#include <common/scrnbuff.hpp>
|
||||
#endif
|
||||
|
||||
class Coord;
|
||||
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
enum Attribute{ForegroundBlue=FOREGROUND_BLUE,ForegroundGreen=FOREGROUND_GREEN,
|
||||
ForegroundRed=FOREGROUND_RED,ForegroundIntensity=FOREGROUND_INTENSITY,
|
||||
BackgroundBlue=BACKGROUND_BLUE,BackgroundGreen=BACKGROUND_GREEN,
|
||||
BackgroundRed=BACKGROUND_RED,BackgroundIntensity=BACKGROUND_INTENSITY};
|
||||
enum ConsoleType{Read=GENERIC_READ,Write=GENERIC_WRITE,ReadWrite=GENERIC_READ|GENERIC_WRITE};
|
||||
// Console(ConsoleType consoleType=(ConsoleType)((int)Write|(int)Read),bool forceCreate=false);
|
||||
Console();
|
||||
Console(ConsoleType consoleType,bool forceCreate);
|
||||
virtual ~Console();
|
||||
WORD write(const String &consoleString);
|
||||
WORD write(const BYTE consoleBYTE);
|
||||
WORD writeLine(const String &consoleString);
|
||||
WORD read(void);
|
||||
WORD read(String &consoleString);
|
||||
BOOL readBufferLine(int row,String &lineString);
|
||||
WORD setConsoleMode(DWORD consoleMode);
|
||||
WORD setConsoleAttribute(WORD consoleAttributes);
|
||||
WORD fillConsoleOutputAttribute(WORD colorAttr,DWORD numChars,const Coord &writeCoord);
|
||||
WORD fillConsoleOutputCharacter(TCHAR outChar,DWORD nLength,const Coord &writeCoord);
|
||||
const ConsoleScreenBufferInfo &getConsoleScreenBufferInfo(void)const;
|
||||
operator HANDLE(void);
|
||||
private:
|
||||
HANDLE mhConsole;
|
||||
WORD mHasConsole;
|
||||
DWORD mGenericResult;
|
||||
ConsoleScreenBufferInfo mConsoleScreenBufferInfo;
|
||||
bool mIsSystemConsole;
|
||||
};
|
||||
|
||||
inline
|
||||
WORD Console::write(const String &consoleString)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
if(consoleString.isNull())return FALSE;
|
||||
::WriteConsole(mhConsole,consoleString,consoleString.length(),&mGenericResult,0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::write(const BYTE consoleBYTE)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
::WriteConsole(mhConsole,&consoleBYTE,sizeof(consoleBYTE),&mGenericResult,0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::writeLine(const String &consoleString)
|
||||
{
|
||||
if(!write(consoleString))return FALSE;
|
||||
return write("\n");
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::setConsoleMode(DWORD consoleMode)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::SetConsoleMode(mhConsole,consoleMode);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD Console::setConsoleAttribute(WORD consoleAttributes)
|
||||
{
|
||||
if(!mhConsole)return FALSE;
|
||||
return ::SetConsoleTextAttribute(mhConsole,consoleAttributes);
|
||||
}
|
||||
|
||||
inline
|
||||
const ConsoleScreenBufferInfo &Console::getConsoleScreenBufferInfo(void)const
|
||||
{
|
||||
return mConsoleScreenBufferInfo;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user