2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef HISTORY_BUFFER_H
6 #define HISTORY_BUFFER_H
8 #include <SupportDefs.h>
10 #include "TerminalLine.h"
22 status_t
Init(int32 width
, int32 capacity
);
26 int32
Width() const { return fWidth
; }
27 int32
Capacity() const { return fCapacity
; }
28 int32
Size() const { return fSize
; }
30 inline HistoryLine
* LineAt(int32 index
) const;
31 TerminalLine
* GetTerminalLineAt(int32 index
,
32 TerminalLine
* buffer
) const;
34 void AddLine(const TerminalLine
* line
);
35 void AddEmptyLines(int32 count
);
36 void DropLines(int32 count
);
39 HistoryLine
* _AllocateLine(int32 attributesRuns
,
41 inline HistoryLine
* _LineAt(int32 index
) const;
51 int32 fBufferAllocationOffset
;
56 HistoryBuffer::_LineAt(int32 index
) const
58 return &fLines
[(fCapacity
+ fNextLine
- index
- 1) % fCapacity
];
63 HistoryBuffer::LineAt(int32 index
) const
65 return index
>= 0 && index
< fSize
? _LineAt(index
) : NULL
;
69 #endif // HISTORY_BUFFER_H