HaikuDepot: notify work status from main window
[haiku.git] / src / apps / terminal / HistoryBuffer.h
bloba8dbf98358b3af5e7ef222a983240bd21f197cc2
1 /*
2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef HISTORY_BUFFER_H
6 #define HISTORY_BUFFER_H
8 #include <SupportDefs.h>
10 #include "TerminalLine.h"
13 struct HistoryLine;
14 struct TerminalLine;
17 class HistoryBuffer {
18 public:
19 HistoryBuffer();
20 ~HistoryBuffer();
22 status_t Init(int32 width, int32 capacity);
24 void Clear();
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);
38 private:
39 HistoryLine* _AllocateLine(int32 attributesRuns,
40 int32 byteLength);
41 inline HistoryLine* _LineAt(int32 index) const;
43 private:
44 HistoryLine* fLines;
45 int32 fWidth;
46 int32 fCapacity;
47 int32 fNextLine;
48 int32 fSize;
49 uint8* fBuffer;
50 int32 fBufferSize;
51 int32 fBufferAllocationOffset;
55 inline HistoryLine*
56 HistoryBuffer::_LineAt(int32 index) const
58 return &fLines[(fCapacity + fNextLine - index - 1) % fCapacity];
62 inline HistoryLine*
63 HistoryBuffer::LineAt(int32 index) const
65 return index >= 0 && index < fSize ? _LineAt(index) : NULL;
69 #endif // HISTORY_BUFFER_H