|
1 // cmdwindow.h |
|
2 // |
|
3 // Copyright (c) 2009 - 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 #ifndef CMDWINDOW_H_ |
|
13 #define CMDWINDOW_H_ |
|
14 |
|
15 #include <e32base.h> |
|
16 #include "common.h" |
|
17 #include <fshell/cconsolebase_writer.h> |
|
18 #include <fshell/line_editor.h> |
|
19 |
|
20 class CColorConsoleBase; |
|
21 class TPoint; |
|
22 class RFs; |
|
23 class CLineEditor; |
|
24 class CDesC16Array; |
|
25 |
|
26 /* |
|
27 The purpose of this class is to handle so-called command window - a piece of of screen where different views can write their |
|
28 problems, query the user, etc. In general the command window is only one-line in height, but if it is necessary then it is |
|
29 possible to make the command window bigger. One can imagine that the user wants to open a new file and the editor allows |
|
30 to browse the directory and use auto-completion for specifying which file should be opened. That could be much better done |
|
31 if the command window was bigger than one line in height. To resize the command window CScreenManager::ResizeCommandWindowL |
|
32 should be called, which will first ensure that all open views are resized as well. |
|
33 |
|
34 The reason why there is a special class and views don't access the command window directly, is that at different times |
|
35 different classes would like to show something on the screen. For example when user wants to close an unsaved file then |
|
36 only a particular buffer (CFedBufferBase) would know it and should be able to query an user. Similarly when User enters |
|
37 an invalid char, or a combination of chars which make a complicated command, a particular View should be able to show a |
|
38 message or a text explaining the complicated command (or even the just entered command keys, like in emacs). Similarly |
|
39 when User is opening a new file and we don't know what is its type then we don't know which View should be used, |
|
40 and in that case DCommandWindow could have a function to allow the user browsing and selecting the required file. |
|
41 |
|
42 DCommandWindow is not responsible for controlling which class has access to the command window, it is only responsible |
|
43 for writing chars on the command window and holds some common function which use the command window (i.e. browsing for |
|
44 a new file). The access, which class should be allowed to access the command window, is controlled by CFed and |
|
45 CRequestHandler (which receives requests to access the command window from particular classes inheriting the |
|
46 MCommandWindowClient interface). |
|
47 */ |
|
48 class CCommandWindow : public CBase, public MConsoleProvider, public MLineEditorObserver, public MLineCompleter |
|
49 { |
|
50 public: |
|
51 static CCommandWindow* NewL(RFs& aFs, CColorConsoleBase& aConsole); |
|
52 static CCommandWindow* NewL(RFs& aFs, CConsoleBase& aConsole); |
|
53 ~CCommandWindow(); |
|
54 |
|
55 //Sets the window which the command window can use |
|
56 void SetWindow(const TWindow& aWindow) {iWindow = aWindow;} |
|
57 |
|
58 CConsoleBase& Console(); |
|
59 CColorConsoleBase* ColorConsole(); |
|
60 void WriteStatus(const TDesC& aNameToTruncate, TRefByValue<const TDesC> aFmt, ...); |
|
61 void InfoPrint(TRefByValue<const TDesC> aFmt, ...); |
|
62 TKeyCode Query(const TDesC& aPrompt, const TDesC& aValidKeys); |
|
63 TBool QueryFilename(const TDesC& aPrompt, TFileName& aFileName); |
|
64 TBool QueryText(const TDesC& aPrompt, TDes& aText); |
|
65 RFs& Fs(); |
|
66 |
|
67 private: |
|
68 CCommandWindow(RFs& aFs, CConsoleBase& aConsole); |
|
69 CCommandWindow(RFs& aFs, CColorConsoleBase& aConsole); |
|
70 void ConstructL(); |
|
71 void DoWriteLine(const TDesC& aLine, TInt aHighlightStart=0, TInt aHighlightLength=0); |
|
72 static TInt DismissInfoPrint(TAny* aSelf); |
|
73 TBool DoQueryText(const TDesC& aPrompt, TDes& aText); |
|
74 |
|
75 private: // Line editor stuff |
|
76 void LeoHandleLine(const TDesC& aLine); |
|
77 void LcCompleteLineL(TConsoleLine& aLine, const TChar& aEscapeChar); |
|
78 |
|
79 void SuggestDrivesL(CDesC16Array* aSuggestions); |
|
80 void CompleteL(TConsoleLine& aLine, const CDesC16Array& aPossibilities, const TDesC* aPrefix, const TDesC* aSuffix); |
|
81 |
|
82 |
|
83 private: |
|
84 RFs& iFs; |
|
85 CConsoleBase& iConsole; |
|
86 CColorConsoleBase* iColorConsole; |
|
87 TWindow iWindow; |
|
88 TBuf<256> iLastStatus; |
|
89 TBuf<256> iQuery; |
|
90 CPeriodic* iInfoPrintDismisser; |
|
91 CLineEditor* iGeneralLineEditor; |
|
92 CLineEditor* iFileNameLineEditor; // Have different editors because they have different histories |
|
93 CLineEditor* iLineEditor; // The current line editor (one of the above). Not owned. |
|
94 TConsoleBaseAdaptor iConsoleAdapter; // Needed by line editor |
|
95 TBool iFinished; |
|
96 TDes* iResultForQuery; |
|
97 }; |
|
98 |
|
99 #endif /*CMDWINDOW_H_*/ |