|
1 // vtc_controller.h |
|
2 // |
|
3 // Copyright (c) 2008 - 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 __VTC_CONTROLLER_H__ |
|
14 #define __VTC_CONTROLLER_H__ |
|
15 |
|
16 #include <e32keys.h> |
|
17 #include <fshell/settings.h> |
|
18 #include <fshell/consoleextensions.h> |
|
19 #include <fshell/abstract_console_writer.h> |
|
20 #include <fshell/common.mmh> |
|
21 #include <fshell/descriptorutils.h> |
|
22 |
|
23 class TCursorTracker; |
|
24 class TEscapeMapping; |
|
25 |
|
26 class MConsoleOutput |
|
27 { |
|
28 public: |
|
29 virtual TInt Output(const TDesC8& aDes) = 0; |
|
30 }; |
|
31 |
|
32 NONSHARABLE_CLASS(CVtConsoleOutputController) : public CBase, public MAbstractConsoleWriter |
|
33 { |
|
34 public: |
|
35 IMPORT_C static CVtConsoleOutputController* NewL(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize); |
|
36 IMPORT_C static CVtConsoleOutputController* New(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile, const TSize& aScreenSize); |
|
37 IMPORT_C ~CVtConsoleOutputController(); |
|
38 IMPORT_C TInt ResetAttributes(); |
|
39 IMPORT_C TInt SetAttributes(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor = ConsoleAttributes::EUnchanged, ConsoleAttributes::TColor aBackgroundColor = ConsoleAttributes::EUnchanged); |
|
40 void SetMode(ConsoleMode::TMode aMode); |
|
41 |
|
42 public: // From MAbstractConsoleWriter. |
|
43 virtual TInt GetCursorPos(TPoint& aPos) const; |
|
44 virtual TInt SetCursorPosAbs(const TPoint& aPos); |
|
45 virtual TInt SetCursorPosRel(const TPoint& aPos); |
|
46 virtual TInt SetCursorHeight(TInt aPercentage); |
|
47 virtual TInt SetTitle(const TDesC& aTitle); |
|
48 virtual TInt ClearScreen(); |
|
49 virtual TInt ClearToEndOfLine(); |
|
50 virtual TInt GetScreenSize(TSize& aSize) const; |
|
51 virtual TInt Write(const TDesC& aDes); |
|
52 virtual TInt Write(const TDesC8& aDes); |
|
53 private: |
|
54 CVtConsoleOutputController(MConsoleOutput& aOutput, LtkUtils::CIniFile& aIniFile); |
|
55 TInt Construct(const TSize& aScreenSize); |
|
56 private: |
|
57 MConsoleOutput& iOutput; |
|
58 LtkUtils::CIniFile& iIniFile; |
|
59 TCursorTracker* iCursorTracker; |
|
60 LtkUtils::RLtkBuf8 iOutputBuf; |
|
61 ConsoleMode::TMode iMode; |
|
62 }; |
|
63 |
|
64 class TKeyPress |
|
65 { |
|
66 public: |
|
67 IMPORT_C TKeyPress(); |
|
68 IMPORT_C TKeyPress(TKeyCode aCode, TUint aModifiers); |
|
69 public: |
|
70 TKeyCode iCode; |
|
71 TUint iModifiers; |
|
72 }; |
|
73 |
|
74 class MConsoleInput |
|
75 { |
|
76 public: |
|
77 virtual void Input(TDes8& aDes, TRequestStatus& aStatus) = 0; |
|
78 virtual void CancelInput(TRequestStatus& aStatus) = 0; |
|
79 }; |
|
80 |
|
81 NONSHARABLE_CLASS(CVtConsoleInputController) : public CActive |
|
82 { |
|
83 public: |
|
84 IMPORT_C static CVtConsoleInputController* New(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile); |
|
85 IMPORT_C static CVtConsoleInputController* NewL(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile); |
|
86 IMPORT_C static CVtConsoleInputController* NewLC(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile); |
|
87 IMPORT_C void GetKeyPress(TKeyPress& aKeyPress, TRequestStatus& aStatus); |
|
88 IMPORT_C void CancelGetKeyPress(); |
|
89 IMPORT_C void SetMode(ConsoleMode::TMode aMode); |
|
90 public: |
|
91 virtual ~CVtConsoleInputController(); |
|
92 private: |
|
93 void ConstructL(); |
|
94 CVtConsoleInputController(MConsoleInput& aConsoleInput, LtkUtils::CIniFile& aIniFile); |
|
95 void DoEscapeKeyL(TUint8 aChar, const TEscapeMapping* iMappings, TInt aMappingCount); |
|
96 void DoExtendedEscapeKey(); |
|
97 static TInt EscapeTimeoutS(TAny* aSelf); |
|
98 TInt EscapeTimeout(); |
|
99 void ReadKeyPress(); |
|
100 void CompleteKeyPressRequest(TInt aError); |
|
101 void CompleteKeyPressRequest(TKeyCode aKeyCode); |
|
102 void CompleteKeyPressRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2); |
|
103 void Reset(); |
|
104 void ReadInput(); |
|
105 private: // From CActive. |
|
106 virtual void RunL(); |
|
107 virtual void DoCancel(); |
|
108 private: |
|
109 enum TState |
|
110 { |
|
111 ENormal, |
|
112 EWaitingForEscapeChar2, |
|
113 EWaitingForEscapeChar3, |
|
114 EWaitingForEscapeChar3Func, |
|
115 EWaitingForExtendedFunc, // Chars 4 and later |
|
116 }; |
|
117 private: |
|
118 MConsoleInput& iConsoleInput; |
|
119 LtkUtils::CIniFile& iIniFile; |
|
120 TState iState; |
|
121 CPeriodic* iEscapeTimer; |
|
122 ConsoleMode::TMode iMode; |
|
123 TBuf8<1024> iBuf; |
|
124 TInt iBufPos; |
|
125 TKeyPress* iClientKeyPress; |
|
126 TRequestStatus* iClientRequestStatus; |
|
127 TBool iKeyCodePending; |
|
128 TKeyCode iPendingKeyCode; |
|
129 TInt iInputError; |
|
130 TBuf8<4> iExtendedEscapeBuf; |
|
131 }; |
|
132 |
|
133 #endif //__VTC_CONTROLLER_H__ |