plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.h
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Thu, 26 Aug 2010 00:49:35 +0100
changeset 37 534b01198c2d
parent 35 f8e05215af4a
child 39 e7ccdc7f7dbe
permissions -rw-r--r--
Added ENotifyKeypresses and ECaptureCtrlC flags to CCommandBase. Commands can now get keypresses and handle ctrl-C via callbacks instead of having to implement custom active objects. As part of this extended the CCommandBase extension interface to MCommandExtensionsV2 for the new virtual functions KeyPressed(TUint aKeyCode, TUint aModifiers) and CtrlCPressed(). sudo now cleans up correctly by using ECaptureCtrlC.

// terminalkeyboardcons.h
// 
// Copyright (c) 2010 Accenture. All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
// 
// Initial Contributors:
// Accenture - Initial contribution
//
#ifndef TERMINALKEYBOARDCONS_H
#define TERMINALKEYBOARDCONS_H

#include <e32std.h>
#include <e32cons.h>
#include <TcDriverIf.h>
#include <fshell/consoleextensions.h>
#include "vtc_cursor_tracker.h"
class CMessageWatcher;

//#define SHOW_TEXTSHELL_BORDERS

NONSHARABLE_CLASS(CTerminalKeyboardCons) : public CConsoleBase, public MIosrvConsoleHelper, public MConsoleScrollHandler
	{
public:
	CTerminalKeyboardCons();
	virtual ~CTerminalKeyboardCons();

public: // From CConsoleBase
	virtual TInt Create(const TDesC& aTitle, TSize aSize);
	virtual void Read(TRequestStatus& aStatus);
	virtual void ReadCancel();
	virtual void Write(const TDesC& aDes);
	virtual TPoint CursorPos() const;
	virtual void SetCursorPosAbs(const TPoint& aPoint);
	virtual void SetCursorPosRel(const TPoint& aPoint);
	virtual void SetCursorHeight(TInt aPercentage);
	virtual void SetTitle(const TDesC& aTitle);
	virtual void ClearScreen();
	virtual void ClearToEndOfLine();
	virtual TSize ScreenSize() const;
	virtual TKeyCode KeyCode() const;
	virtual TUint KeyModifiers() const;
	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);

private: // From MConsoleScrollHandler
	void ConsoleScrolled(TInt aNumberOfLines);

private:
	virtual void ConstructL(const TDesC& aTitle, const TSize& aSize);
	void Update();
	void DoUpdate();
	void MessageReceived(TInt aError);
	void Transmit(const TDesC& aBuf, TInt aWidth, TInt aHeight);
	static TInt UpdateCallback(TAny* aSelf);

protected:
	TRequestStatus* iClientStatus;
	TBool iGotKey;
	TKeyCode iKeyCode;
	TUint iKeyModifiers;
	CConsoleBase* iUnderlyingConsole;
	RTcDriver iDriver;

	RBuf iTextBuffer;
	RBuf iMungedTextBuffer; // With the borders
	TCursorTracker iTracker;
	CMessageWatcher* iWatcher;
	friend class CMessageWatcher;
	TBool iBacktickModifierDown;
	CPeriodic* iIdleUpdateTimer;
	};

#endif // TERMINALKEYBOARDCONS_H