plugins/consoles/win32cons/src/win32cons.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // win32cons.h
       
     2 // 
       
     3 // Copyright (c) 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #ifndef __win32cons_h__
       
    14 #define __win32cons_h__
       
    15 
       
    16 #define WIN32_LEAN_AND_MEAN
       
    17 #include <windows.h>
       
    18 #include <e32keys.h>
       
    19 
       
    20 class TWin32Console
       
    21 	{
       
    22 public:	
       
    23 	/**
       
    24 	Return non-zero on success.
       
    25 	*/
       
    26 	int AttachConsole();
       
    27 	void FreeConsole();
       
    28 	int Write(const char* aText, int aLen);
       
    29 	int Write(const WCHAR* aText, int aLen);
       
    30 	int WriteStdErr(const char* aText, int aLen);
       
    31 	int WriteStdErr(const WCHAR* aText, int aLen);
       
    32 	int Read(void* buf, int len, int& bytesRead);
       
    33 	int ReadKey(TKeyCode& aCode, TUint& aModifiers);
       
    34 	int GetCursorPos(int& aX, int& aY) const;
       
    35 	int SetCursorPos(int aX, int aY);
       
    36 	int SetCursorPosRel(int aX, int aY);
       
    37 	int SetCursorHeight(int aPercentage);
       
    38 	int SetTitle(const char* aTitle);
       
    39 	int ClearScreen();
       
    40 	int ClearToEndOfLine();
       
    41 	int GetScreenSize(int& aWidth, int& aHeight) const;
       
    42 
       
    43 	// Copied from consoleextensions.h
       
    44 	enum TAttribute
       
    45 		{
       
    46 		ENone			= 0x0001,
       
    47 		EBold			= 0x0002,
       
    48 		EUnderscore		= 0x0004,
       
    49 		EBlink			= 0x0008,
       
    50 		EInverse		= 0x0010,
       
    51 		EConceal		= 0x0020
       
    52 		};
       
    53 	enum TColor
       
    54 		{
       
    55 		EBlack,
       
    56 		ERed,
       
    57 		EGreen,
       
    58 		EYellow,
       
    59 		EBlue,
       
    60 		EMagenta,
       
    61 		ECyan,
       
    62 		EWhite,
       
    63 		EReset,
       
    64 		EUnchanged
       
    65 		};
       
    66 	int SetAttributes(unsigned aAttributes, TWin32Console::TColor aForegroundColor, TWin32Console::TColor aBackgroundColor);
       
    67 
       
    68 private:
       
    69 	int AttachOrAllocConsole();
       
    70 private:
       
    71 	bool iHaveConsole;
       
    72 	void* iStdOutHandle;
       
    73 	void* iStdErrHandle;
       
    74 	void* iStdinHandle;
       
    75 	unsigned long iOldConsMode;
       
    76 	bool iConsModeSet;
       
    77 	KEY_EVENT_RECORD iCachedKey;
       
    78 	WORD iOrigAttributes;
       
    79 	};
       
    80 	
       
    81 void DebugMsg(const char* aMsg, ...);
       
    82 void DebugMsg(const unsigned short int* aMsg, ...);
       
    83 
       
    84 #endif //__win32cons_h__
       
    85 
       
    86