plugins/consoles/rcons/server/win32/TextBuffer.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // TextBuffer.h
       
     2 // 
       
     3 // Copyright (c) 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 __TEXTBUFFER_H__
       
    14 #define __TEXTBUFFER_H__
       
    15 
       
    16 #if _MSC_VER > 1000
       
    17 #pragma once
       
    18 #endif // _MSC_VER > 1000
       
    19 
       
    20 #include "base.h"
       
    21 
       
    22 
       
    23 class MTextBufferObserver
       
    24 	{
       
    25 public:
       
    26 	virtual void HandleTextBufferChange(int aPosX, int aPosY, PTCHAR aPtr, int aLength) = 0;
       
    27 	virtual void HandleTextBufferScroll() = 0;
       
    28 	virtual void HandleTextBufferCursorChange() = 0;
       
    29 	virtual void HandleTextBufferCleared() = 0;
       
    30 	};
       
    31 
       
    32 
       
    33 class CTextBuffer : public CBase
       
    34 	{
       
    35 public:
       
    36 	static CTextBuffer* New(int aWidth, int aHeight, int aMaxNumOverflowLines);
       
    37 	virtual ~CTextBuffer();
       
    38 	void SetObserver(MTextBufferObserver* aObserver);
       
    39 	void Write(LPCTSTR aString, int aLength);
       
    40 	void GetCursorPos(int& aX, int& aY) const;
       
    41 	void SetAbsCursorPos(int aX, int aY);
       
    42 	void SetRelCursorPos(int aX, int aY);
       
    43 	void GetSize(int& aWidth, int& aHeight) const;
       
    44 	int NumOverflowLines() const;
       
    45 	void Clear();
       
    46 	void ClearToEndOfLine();
       
    47 	LPCTSTR GetLine(int aPos) const;
       
    48 	void CaptureToFile(LPCTSTR aFileName);
       
    49 	void StopCaptureToFile();
       
    50 	bool IsCapturingToFile() const;
       
    51 private:
       
    52 	CTextBuffer(int aWidth, int aHeight, int aMaxNumOverflowLines);
       
    53 	void Construct();
       
    54 	void MoveCursor(int aNewX, int aNewY);
       
    55 	PTCHAR CursorPtr() const;
       
    56 	PTCHAR LineEndPtr() const;
       
    57 	PTCHAR BufEndPtr() const;
       
    58 	void WriteSpecialChar(TCHAR aChar);
       
    59 	void WriteBlock(LPCTSTR aString, int aLength);
       
    60 	bool IsOrdinaryChar(TCHAR aChar) const;
       
    61 	int NumCharsToLineEnd() const;
       
    62 	void ClearBuffer();
       
    63 	void CursorLeft();
       
    64 	void CursorRight();
       
    65 	void FormFeed();
       
    66 	void LineFeed();
       
    67 	void CarriageReturn();
       
    68 	void BackSpace();
       
    69 	void HorizontalTab();
       
    70 	void ScrollUp();
       
    71 	void WriteLineToCaptureFile(LPCTSTR aLinePtr);
       
    72 	void WriteOverflowLinesToCaptureFile();
       
    73 	void WriteBufferToCaptureFile();
       
    74 private:
       
    75 	MTextBufferObserver* iObserver;
       
    76 	PTCHAR iBuffer;
       
    77 	const int iWidth;
       
    78 	const int iHeight;
       
    79 	const int iMaxNumOverflowLines;
       
    80 	int iNumOverflowLines;
       
    81 	int iCursorPosX;
       
    82 	int iCursorPosY;
       
    83 	int iCaptureFile;
       
    84 	};
       
    85 
       
    86 #endif // __TEXTBUFFER_H__