sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\ewsrv\co_cli.cpp sl@0: // sl@0: // sl@0: sl@0: #include "ws_std.h" sl@0: sl@0: TInt RConsole::Connect() sl@0: { sl@0: return CreateSession(KE32WindowServer,Version(),KMessageSlots); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Create() sl@0: // sl@0: // Connect with the window server if connection not already made, sl@0: // then create a default console window without displaying it sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: } sl@0: return SendReceive(CWsSession::EConsoleCreate, TIpcArgs()); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Init(const TDesC &aName,const TSize &aSize) sl@0: // sl@0: // Connect with the window server if connection not already made, sl@0: // then open/display a console window on with the specified title. sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: } sl@0: TPckgC size(aSize); sl@0: return SendReceive(CWsSession::EConsoleSet, TIpcArgs(&aName, &size)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetTitle(const TDesC &aName) sl@0: // sl@0: // Change the title of the window sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleSetTitle, TIpcArgs(&aName)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetSize(const TSize &aSize) sl@0: // sl@0: // Change the underlying size of the window sl@0: // sl@0: { sl@0: sl@0: TPckgC size(aSize); sl@0: return SendReceive(CWsSession::EConsoleSetSize, TIpcArgs(&size)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Size(TSize &aSize) const sl@0: // sl@0: // Read the current window size sl@0: // sl@0: { sl@0: sl@0: TPckg size(aSize); sl@0: return SendReceive(CWsSession::EConsoleSize, TIpcArgs( (TDes8*)&size )); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::ScreenSize(TSize &aSize) const sl@0: // sl@0: // Read the screen size in characters sl@0: // sl@0: { sl@0: sl@0: TPckg size(aSize); sl@0: return SendReceive(CWsSession::EConsoleScreenSize, TIpcArgs( (TDes8*)&size )); sl@0: } sl@0: sl@0: EXPORT_C TVersion RConsole::Version() sl@0: // sl@0: // Return the client side version number. sl@0: // sl@0: { sl@0: sl@0: return TVersion(KW32MajorVersionNumber,KW32MinorVersionNumber,KE32BuildVersionNumber); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Write(const TDesC &aDes) sl@0: // sl@0: // Write to the console. sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleWrite, TIpcArgs(&aDes)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::ClearScreen() sl@0: // sl@0: // Clear window sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleClearScreen, TIpcArgs()); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::ClearToEndOfLine() sl@0: // sl@0: // Clear window from current cursor position to the end of the line sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleClearToEndOfLine, TIpcArgs()); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Destroy() sl@0: // sl@0: // Remove and close down the window sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleDestroy, TIpcArgs()); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetWindowPosAbs(const TPoint &aPosition) sl@0: // sl@0: // Position the window sl@0: // sl@0: { sl@0: sl@0: TPckgC point(aPosition); sl@0: return SendReceive(CWsSession::EConsoleSetWindowPosAbs, TIpcArgs(&point)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetCursorHeight(TInt aPercentage) sl@0: // sl@0: // Set the percentage height of the cursor sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleSetCursorHeight, TIpcArgs(aPercentage)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetCursorPosAbs(const TPoint &aPosition) sl@0: // sl@0: // Position the cursor in the window buffer sl@0: // sl@0: { sl@0: sl@0: TPckgC point(aPosition); sl@0: return SendReceive(CWsSession::EConsoleSetCursorPosAbs, TIpcArgs(&point)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetCursorPosRel(const TPoint &aVector) sl@0: // sl@0: // Position the cursor in the window buffer sl@0: // sl@0: { sl@0: sl@0: TPckg point(aVector); sl@0: return SendReceive(CWsSession::EConsoleSetCursorPosRel, TIpcArgs(&point)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::CursorPos(TPoint &aPosition) const sl@0: // sl@0: // Read current cursor position relative to the window sl@0: // sl@0: { sl@0: sl@0: TPckg point(aPosition); sl@0: return SendReceive(CWsSession::EConsoleCursorPos, TIpcArgs( (TDes8*)&point )); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Control(const TDesC &aDes) sl@0: // sl@0: // Control window properties sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleControl, TIpcArgs(&aDes)); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::Read(TConsoleKey &aKeystroke) sl@0: // sl@0: // Synchronous get keystroke from window sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke )); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::Read(TConsoleKey &aKeystroke,TRequestStatus &aStatus) sl@0: // sl@0: // Asynchronous get keystroke from window sl@0: // sl@0: { sl@0: sl@0: SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ), aStatus); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::ReadCancel() sl@0: // sl@0: // Cancel asynchronous read request sl@0: // sl@0: { sl@0: sl@0: return SendReceive(CWsSession::EConsoleReadCancel, TIpcArgs()); sl@0: } sl@0: sl@0: EXPORT_C TInt RConsole::SetMode(TVideoMode aMode) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return r; sl@0: } sl@0: return SendReceive(CWsSession::EConsoleSetMode, TIpcArgs(aMode)); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::SetPaletteEntry(TUint aIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return; sl@0: } sl@0: SendReceive(CWsSession::EConsoleSetPaletteEntry, TIpcArgs(aIndex,aRed,aGreen,aBlue)); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::GetPaletteEntry(TUint aIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return; sl@0: } sl@0: TPckg r(aRed); sl@0: TPckg g(aGreen); sl@0: TPckg b(aBlue); sl@0: SendReceive(CWsSession::EConsoleGetPaletteEntry, TIpcArgs(aIndex, &r, &g, &b)); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::SetTextColors(TUint aFgColor,TUint aBgColor) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return; sl@0: } sl@0: SendReceive(CWsSession::EConsoleSetTextColors, TIpcArgs(aFgColor, aBgColor)); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::SetUIColors(TUint aWindowBgColor,TUint aBorderColor,TUint aScreenColor) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return; sl@0: } sl@0: SendReceive(CWsSession::EConsoleSetUIColors, TIpcArgs(aWindowBgColor, aBorderColor, aScreenColor)); sl@0: } sl@0: sl@0: EXPORT_C void RConsole::SetTextAttribute(TTextAttribute aAttr) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: sl@0: if (Handle()==KNullHandle) sl@0: { sl@0: TInt r = Connect(); sl@0: if (r!=KErrNone) sl@0: return; sl@0: } sl@0: SendReceive(CWsSession::EConsoleSetTextAttribute, TIpcArgs(aAttr)); sl@0: }