ReactOS  0.4.14-dev-1112-g2b067d6
CTextHistory Class Reference

#include <TextHistory.h>

Public Member Functions

 CTextHistory ()
 
virtual ~CTextHistory ()
 
BOOL Init (DWORD dwMaxHistoryLineSize, DWORD dwMaxHistoryLines)
 
const TCHARGetHistoryLine (DWORD dwIndex)
 
void AddHistoryLine (const TCHAR *pchLine)
 

Private Attributes

TCHARm_pHistoryBuffer
 
DWORD m_dwMaxHistoryLines
 
DWORD m_dwMaxHistoryLineSize
 
DWORD m_dwFirstHistoryIndex
 
DWORD m_dwLastHistoryIndex
 
DWORD m_dwHisoryFull
 

Detailed Description

Definition at line 9 of file TextHistory.h.

Constructor & Destructor Documentation

◆ CTextHistory()

CTextHistory::CTextHistory ( )

Definition at line 33 of file TextHistory.cpp.

34 {
37 }
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18
DWORD m_dwMaxHistoryLines
Definition: TextHistory.h:19

◆ ~CTextHistory()

CTextHistory::~CTextHistory ( )
virtual

Definition at line 39 of file TextHistory.cpp.

40 {
41  if (m_pHistoryBuffer) delete[] m_pHistoryBuffer;
42 }
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18

Member Function Documentation

◆ AddHistoryLine()

void CTextHistory::AddHistoryLine ( const TCHAR pchLine)

Definition at line 62 of file TextHistory.cpp.

63 {
64  if (!m_pHistoryBuffer) return;
65  if (_tcslen(pchLine) == 0) return;
66  if (_tcslen(pchLine) >= m_dwMaxHistoryLineSize)
67  {
68  ASSERT(FALSE);
69  return;
70  }
71  if (m_dwHisoryFull == m_dwMaxHistoryLines) // if buffer is full, replace last
72  {
75  }
81 }
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18
DWORD m_dwMaxHistoryLines
Definition: TextHistory.h:19
DWORD m_dwLastHistoryIndex
Definition: TextHistory.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
DWORD m_dwHisoryFull
Definition: TextHistory.h:23
DWORD m_dwMaxHistoryLineSize
Definition: TextHistory.h:20
DWORD m_dwFirstHistoryIndex
Definition: TextHistory.h:21

Referenced by CConsole::ReadLine().

◆ GetHistoryLine()

const TCHAR * CTextHistory::GetHistoryLine ( DWORD  dwIndex)

Definition at line 83 of file TextHistory.cpp.

84 {
85  if (!m_pHistoryBuffer) return NULL;
87  if (dwIndex >= m_dwHisoryFull) return NULL;
88  dwIndex = m_dwHisoryFull - dwIndex - 1;
89  dwIndex = (dwIndex+m_dwLastHistoryIndex) % m_dwMaxHistoryLines;
90  ASSERT(dwIndex < m_dwMaxHistoryLines);
92 }
smooth NULL
Definition: ftsmooth.c:416
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18
DWORD m_dwMaxHistoryLines
Definition: TextHistory.h:19
DWORD m_dwLastHistoryIndex
Definition: TextHistory.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
DWORD m_dwHisoryFull
Definition: TextHistory.h:23
DWORD m_dwMaxHistoryLineSize
Definition: TextHistory.h:20

Referenced by CConsole::ReadLine().

◆ Init()

BOOL CTextHistory::Init ( DWORD  dwMaxHistoryLineSize,
DWORD  dwMaxHistoryLines 
)

Definition at line 44 of file TextHistory.cpp.

45 {
46  if (!dwMaxHistoryLines)
47  {
48  ASSERT(FALSE);
49  return FALSE;
50  }
51  if (m_pHistoryBuffer) delete[] m_pHistoryBuffer;
54  m_dwHisoryFull = 0;
55  m_dwMaxHistoryLines = dwMaxHistoryLines;
56  m_dwMaxHistoryLineSize = dwMaxHistoryLineSize;
57  m_pHistoryBuffer = new (std::nothrow) TCHAR [m_dwMaxHistoryLines*dwMaxHistoryLineSize];
58  if (!m_pHistoryBuffer) return FALSE;
59  return TRUE;
60 }
#define TRUE
Definition: types.h:120
char TCHAR
Definition: xmlstorage.h:189
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18
DWORD m_dwMaxHistoryLines
Definition: TextHistory.h:19
DWORD m_dwLastHistoryIndex
Definition: TextHistory.h:22
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
DWORD m_dwHisoryFull
Definition: TextHistory.h:23
DWORD m_dwMaxHistoryLineSize
Definition: TextHistory.h:20
DWORD m_dwFirstHistoryIndex
Definition: TextHistory.h:21

Referenced by CConsole::Init().

Member Data Documentation

◆ m_dwFirstHistoryIndex

DWORD CTextHistory::m_dwFirstHistoryIndex
private

Definition at line 21 of file TextHistory.h.

Referenced by AddHistoryLine(), and Init().

◆ m_dwHisoryFull

DWORD CTextHistory::m_dwHisoryFull
private

Definition at line 23 of file TextHistory.h.

Referenced by AddHistoryLine(), GetHistoryLine(), and Init().

◆ m_dwLastHistoryIndex

DWORD CTextHistory::m_dwLastHistoryIndex
private

Definition at line 22 of file TextHistory.h.

Referenced by AddHistoryLine(), GetHistoryLine(), and Init().

◆ m_dwMaxHistoryLines

DWORD CTextHistory::m_dwMaxHistoryLines
private

Definition at line 19 of file TextHistory.h.

Referenced by AddHistoryLine(), CTextHistory(), GetHistoryLine(), and Init().

◆ m_dwMaxHistoryLineSize

DWORD CTextHistory::m_dwMaxHistoryLineSize
private

Definition at line 20 of file TextHistory.h.

Referenced by AddHistoryLine(), GetHistoryLine(), and Init().

◆ m_pHistoryBuffer

TCHAR* CTextHistory::m_pHistoryBuffer
private

Definition at line 18 of file TextHistory.h.

Referenced by AddHistoryLine(), CTextHistory(), GetHistoryLine(), Init(), and ~CTextHistory().


The documentation for this class was generated from the following files: