ReactOS 0.4.15-dev-6656-gbbb33a6
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}
DWORD m_dwMaxHistoryLines
Definition: TextHistory.h:19
TCHAR * m_pHistoryBuffer
Definition: TextHistory.h:18
#define NULL
Definition: types.h:112

◆ ~CTextHistory()

CTextHistory::~CTextHistory ( )
virtual

Definition at line 39 of file TextHistory.cpp.

40{
42}

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 {
69 return;
70 }
71 if (m_dwHisoryFull == m_dwMaxHistoryLines) // if buffer is full, replace last
72 {
75 }
81}
DWORD m_dwHisoryFull
Definition: TextHistory.h:23
DWORD m_dwMaxHistoryLineSize
Definition: TextHistory.h:20
DWORD m_dwLastHistoryIndex
Definition: TextHistory.h:22
DWORD m_dwFirstHistoryIndex
Definition: TextHistory.h:21
#define FALSE
Definition: types.h:117
#define _tcscpy
Definition: tchar.h:623
#define ASSERT(a)
Definition: mode.c:44
#define _tcslen
Definition: xmlstorage.h:198

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}

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 {
49 return FALSE;
50 }
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

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: