commands/fed/inc/lrtextview.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // lrtextview.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 LRTEXTVIEW_H_
       
    13 #define LRTEXTVIEW_H_
       
    14 
       
    15 #include "textview.h"
       
    16 
       
    17 class CColorConsoleBase;
       
    18 class CLineData;
       
    19 
       
    20 //Main class reading/writing normal (not-unicode) text arranged left-to-right on the screen.
       
    21 class CLRTextView : public CTextView
       
    22 {
       
    23 public:
       
    24 	static CLRTextView* NewL(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer);
       
    25 	~CLRTextView();
       
    26 
       
    27 protected:
       
    28 	CLRTextView(MConsoleProvider& aConsoleProvider, CFedBufferBase& aBuffer);
       
    29 	void ConstructL();
       
    30 
       
    31 public:
       
    32 	//MDeferredClose
       
    33 	TBool TryCloseL();
       
    34 
       
    35 	//MKeyConsumer
       
    36 	TBool ConsumeKeyL(const TKeyCode& aCode);
       
    37 
       
    38 	//CTextView
       
    39 	void DoResizeL(const TWindow& aOldWindow);
       
    40 	void DoRedrawL();
       
    41 	void DoDrawL();
       
    42 
       
    43 protected:
       
    44 	void ValidateCursor();
       
    45 	void UpdateCursor(const TPoint& aNewPos);
       
    46 	void HandleControlChar();
       
    47 	void AppendChar(TUint16 aChar);
       
    48 	void WriteLine();
       
    49 	void WriteChars();
       
    50 	void GoToNextLine();
       
    51 	void WriteLineContinue();
       
    52 	void LineFinished();
       
    53 	TInt DocumentPosition() const;
       
    54 	void MoveCursor(TInt aX, TInt aY);
       
    55 	void InsertTextL(const TDesC& aText);
       
    56 	void DeleteTextL(TInt aNumChars);
       
    57 	void DeleteCurrentLineL();
       
    58 	void UpdateStatus();
       
    59 	TInt Save();
       
    60 	TInt SaveAs();
       
    61 	void HandleSaveResult(TInt aError, TBool aWasOpen, const TDesC& aName);
       
    62 	void GoToLine();
       
    63 	void GoToLine(TInt aLine);
       
    64 	void DoDrawL(TBool aUpdateCursorAndStatus); // Occasionally we want to do a draw without updating
       
    65 	void CenterDocPosOnScreen(TInt aDocumentPosition);
       
    66 	TPoint WindowLocationForDocumentPosition(TInt aDocPos) const; // Assuming the doc pos is on screen in an area that's been drawn
       
    67 	void RedrawFromPositionToEndOfLine(TInt aDocumentPosition, TInt aNumCharsInserted);
       
    68 	void Find();
       
    69 	void CopyOrCutL(TBool aCut);
       
    70 	void PasteL();
       
    71 	void CopyToClipboardL(const TDesC& aBuf);
       
    72 	HBufC* GetFromClipboardL();
       
    73 	void SetMark();
       
    74 	void CancelMark();
       
    75 	static TInt FlashMark(TAny* aSelf);
       
    76 	void DoFlashMark();
       
    77 	TBool MarkActive() const;
       
    78 	void UpdateDocumentPositionsStartingAtLine(TInt aLine, TInt aDelta);
       
    79 
       
    80 private:
       
    81 	CLineData* iLineData;
       
    82 	TInt iCurrentDrawDocIndex; // Used while drawing to construct iLineData document positions, has no meaning outside of there
       
    83 	TBool iLineIsErrorMessage;
       
    84 	TBuf<256> iFindText;
       
    85 	CPeriodic* iMarkFlasher;
       
    86 	TInt iMarkDocPos;
       
    87 	TBool iMarkShown;
       
    88 	TInt iOldNextLine; // Used to limit how much redrawing we need to do
       
    89 	TInt iOldNextLineDocPos; // Ditto
       
    90 	TInt iPredictedOldNextLineDocPosDelta; // Ditto
       
    91 	TBool* iRecursiveUpdateFlag; // For times when DoDrawL's aUpdateStatusAndCursor flag needs tracking through calls to RequestData
       
    92 };
       
    93 
       
    94 class CLineData : public CBase
       
    95 	{
       
    96 public:
       
    97 	void EnsureCapacityL(TInt aWidth, TInt aHeight);
       
    98 	TInt DocumentPosition(TInt aLine) const;
       
    99 	TInt FileLineNumber(TInt aLine) const;
       
   100 	TBool IsScreenPositionValid(TInt aLine, TInt aCol) const;
       
   101 	TInt LastValidPosition(TInt aLine) const;
       
   102 
       
   103 	void SetDocumentPositionForLine(TInt aLine, TInt aDocumentPosition);
       
   104 	void SetFileLineNumberForLine(TInt aLine, TInt aDocumentPosition);
       
   105 	void SetPositionIsValid(TInt aLine, TInt aCol, TBool aValid);
       
   106 	void LineFinishedAt(TInt aLine, TInt aCol);
       
   107 
       
   108 	~CLineData();
       
   109 
       
   110 private:
       
   111 	const TUint8& ByteForPos(TInt aLine, TInt aCol, TInt& aOffset) const;
       
   112 	TUint8& ByteForPos(TInt aLine, TInt aCol, TInt& aOffset);
       
   113 
       
   114 private:
       
   115 	TInt iLineLen;
       
   116 	TInt* iDocPosAndLine;
       
   117 	TUint8* iScreenIndexes;
       
   118 	};
       
   119 
       
   120 
       
   121 #endif /*LRTEXTVIEW_H_*/