xref: /haiku/src/apps/terminal/TerminalLine.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TERMINAL_LINE_H
6 #define TERMINAL_LINE_H
7 
8 #include <SupportDefs.h>
9 
10 #include "TermConst.h"
11 
12 #include "UTF8Char.h"
13 
14 
15 struct TerminalCell {
16 	UTF8Char		character;
17 	uint32			attributes;
18 };
19 
20 
21 struct TerminalLine {
22 	uint16			length;
23 	bool			softBreak;	// soft line break
24 	uint32			attributes;
25 	TerminalCell	cells[1];
26 
27 	inline void Clear()
28 	{
29 		length = 0;
30 		attributes = 0;
31 		softBreak = false;
32 	}
33 };
34 
35 
36 struct AttributesRun {
37 	uint32	attributes;
38 	uint16	offset;			// character offset
39 	uint16	length;			// length of the run in characters
40 };
41 
42 
43 struct HistoryLine {
44 	AttributesRun*	attributesRuns;
45 	uint16			attributesRunCount;	// number of attribute runs
46 	uint16			byteLength : 15;	// number of bytes in the line
47 	bool			softBreak : 1;		// soft line break;
48 	uint32			attributes;
49 
50 	AttributesRun* AttributesRuns() const
51 	{
52 		return attributesRuns;
53 	}
54 
55 	char* Chars() const
56 	{
57 		return (char*)(attributesRuns + attributesRunCount);
58 	}
59 
60 	int32 BufferSize() const
61 	{
62 		return attributesRunCount * sizeof(AttributesRun) + byteLength;
63 	}
64 };
65 
66 
67 #endif	// TERMINAL_LINE_H
68