xref: /haiku/src/apps/terminal/TermPos.h (revision d12bb8b14803d030b4a8fba91131e4bb96c4f406)
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 
19 	inline void SetTo(int32 x, int32 y)
20 	{
21 		this->x = x;
22 		this->y = y;
23 	}
24 
25 	inline bool operator==(const TermPos& other) const
26 	{
27 		return x == other.x && y == other.y;
28 	}
29 
30 	inline bool operator!=(const TermPos& other) const
31 	{
32 		return x != other.x || y != other.y;
33 	}
34 
35 	inline bool operator<=(const TermPos& other) const
36 	{
37 		return y < other.y || (y == other.y && x <= other.x);
38 	}
39 
40 	inline bool operator>=(const TermPos& other) const
41 	{
42 		return other <= *this;
43 	}
44 
45 	inline bool operator<(const TermPos& other) const
46 	{
47 		return !(*this >= other);
48 	}
49 
50 	inline bool operator>(const TermPos& other) const
51 	{
52 		return !(*this <= other);
53 	}
54 };
55 
56 
57 #endif	// TERM_POS_H
58