diff options
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibVT/Position.h | 48 | ||||
-rw-r--r-- | Libraries/LibVT/Terminal.h | 44 |
2 files changed, 49 insertions, 43 deletions
diff --git a/Libraries/LibVT/Position.h b/Libraries/LibVT/Position.h new file mode 100644 index 0000000000..d6766029f7 --- /dev/null +++ b/Libraries/LibVT/Position.h @@ -0,0 +1,48 @@ +#pragma once + +namespace VT { + +class Position { +public: + Position() {} + Position(int row, int column) + : m_row(row) + , m_column(column) + { + } + + bool is_valid() const { return m_row >= 0 && m_column >= 0; } + int row() const { return m_row; } + int column() const { return m_column; } + + bool operator<(const Position& other) const + { + return m_row < other.m_row || (m_row == other.m_row && m_column < other.m_column); + } + + bool operator<=(const Position& other) const + { + return *this < other || *this == other; + } + + bool operator>=(const Position& other) const + { + return !(*this < other); + } + + bool operator==(const Position& other) const + { + return m_row == other.m_row && m_column == other.m_column; + } + + bool operator!=(const Position& other) const + { + return !(*this == other); + } + +private: + int m_row { -1 }; + int m_column { -1 }; +}; + +} diff --git a/Libraries/LibVT/Terminal.h b/Libraries/LibVT/Terminal.h index ca523ebbc7..d0cc82ca1e 100644 --- a/Libraries/LibVT/Terminal.h +++ b/Libraries/LibVT/Terminal.h @@ -3,6 +3,7 @@ #include <AK/AKString.h> #include <AK/NonnullOwnPtrVector.h> #include <AK/Vector.h> +#include <LibVT/Position.h> namespace VT { @@ -56,49 +57,6 @@ struct Attribute { } }; -class BufferPosition { -public: - BufferPosition() {} - BufferPosition(int row, int column) - : m_row(row) - , m_column(column) - { - } - - bool is_valid() const { return m_row >= 0 && m_column >= 0; } - int row() const { return m_row; } - int column() const { return m_column; } - - bool operator<(const BufferPosition& other) const - { - return m_row < other.m_row || (m_row == other.m_row && m_column < other.m_column); - } - - bool operator<=(const BufferPosition& other) const - { - return *this < other || *this == other; - } - - bool operator>=(const BufferPosition& other) const - { - return !(*this < other); - } - - bool operator==(const BufferPosition& other) const - { - return m_row == other.m_row && m_column == other.m_column; - } - - bool operator!=(const BufferPosition& other) const - { - return !(*this == other); - } - -private: - int m_row { -1 }; - int m_column { -1 }; -}; - class Terminal { public: explicit Terminal(TerminalClient&); |