1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

LibVT: Rename VT::BufferPosition to VT::Position and move to own file

This commit is contained in:
Andreas Kling 2019-08-13 12:48:54 +02:00
parent e8eadd19a5
commit 4fb02c78a9
4 changed files with 59 additions and 53 deletions

View file

@ -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 };
};
}

View file

@ -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&);