xref: /haiku/src/apps/terminal/TermPos.h (revision 3369e03d5cde9709c8aa70c99bfe6ce24ba65bf9)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef TERM_POS_H
6 #define TERM_POS_H
7 
8 #include <SupportDefs.h>
9 
10 
11 class TermPos {
12 public:
13 	int32	x;
14 	int32	y;
15 
16 	inline TermPos()						: x(0), y(0) { }
17 	inline TermPos(int32 x, int32 y)		: x(x), y(y) { }
18 	inline TermPos(const TermPos& other)	: x(other.x), y(other.y) { }
19 
20 	inline void SetTo(int32 x, int32 y)
21 	{
22 		this->x = x;
23 		this->y = y;
24 	}
25 
26 	inline bool operator==(const TermPos& other) const
27 	{
28 		return x == other.x && y == other.y;
29 	}
30 
31 	inline bool operator!=(const TermPos& other) const
32 	{
33 		return x != other.x || y != other.y;
34 	}
35 
36 	inline bool operator<=(const TermPos& other) const
37 	{
38 		return y < other.y || (y == other.y && x <= other.x);
39 	}
40 
41 	inline bool operator>=(const TermPos& other) const
42 	{
43 		return other <= *this;
44 	}
45 
46 	inline bool operator<(const TermPos& other) const
47 	{
48 		return !(*this >= other);
49 	}
50 
51 	inline bool operator>(const TermPos& other) const
52 	{
53 		return !(*this <= other);
54 	}
55 
56 	inline TermPos& operator=(const TermPos& other)
57 	{
58 		x = other.x;
59 		y = other.y;
60 		return *this;
61 	}
62 };
63 
64 
65 #endif	// TERM_POS_H
66