2020-05-15 18:57:50 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-15 18:57:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Noncopyable.h>
|
|
|
|
|
#include <AK/String.h>
|
2021-02-26 20:28:22 +01:00
|
|
|
#include <AK/Vector.h>
|
2021-04-16 22:58:51 +03:00
|
|
|
#include <LibVT/Attribute.h>
|
2020-05-15 18:57:50 +02:00
|
|
|
#include <LibVT/XtermColors.h>
|
|
|
|
|
|
|
|
|
|
namespace VT {
|
|
|
|
|
|
|
|
|
|
class Line {
|
|
|
|
|
AK_MAKE_NONCOPYABLE(Line);
|
|
|
|
|
AK_MAKE_NONMOVABLE(Line);
|
|
|
|
|
|
|
|
|
|
public:
|
2021-02-26 20:28:22 +01:00
|
|
|
explicit Line(size_t length);
|
2020-05-15 18:57:50 +02:00
|
|
|
~Line();
|
|
|
|
|
|
2021-02-26 20:28:22 +01:00
|
|
|
struct Cell {
|
2021-03-01 11:05:31 +01:00
|
|
|
u32 code_point { ' ' };
|
2021-02-26 20:28:22 +01:00
|
|
|
Attribute attribute;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const Attribute& attribute_at(size_t index) const { return m_cells[index].attribute; }
|
|
|
|
|
Attribute& attribute_at(size_t index) { return m_cells[index].attribute; }
|
|
|
|
|
|
|
|
|
|
Cell& cell_at(size_t index) { return m_cells[index]; }
|
|
|
|
|
const Cell& cell_at(size_t index) const { return m_cells[index]; }
|
|
|
|
|
|
|
|
|
|
void clear(const Attribute&);
|
2020-05-15 18:57:50 +02:00
|
|
|
bool has_only_one_background_color() const;
|
|
|
|
|
|
2021-02-26 20:28:22 +01:00
|
|
|
size_t length() const { return m_cells.size(); }
|
|
|
|
|
void set_length(size_t);
|
2020-05-15 18:57:50 +02:00
|
|
|
|
2020-08-05 16:31:20 -04:00
|
|
|
u32 code_point(size_t index) const
|
2020-05-17 11:32:31 +02:00
|
|
|
{
|
2021-02-26 20:28:22 +01:00
|
|
|
return m_cells[index].code_point;
|
2020-05-17 11:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-08-05 16:31:20 -04:00
|
|
|
void set_code_point(size_t index, u32 code_point)
|
2020-05-17 11:32:31 +02:00
|
|
|
{
|
2021-02-26 20:28:22 +01:00
|
|
|
m_cells[index].code_point = code_point;
|
2020-05-17 11:32:31 +02:00
|
|
|
}
|
2020-05-15 18:57:50 +02:00
|
|
|
|
|
|
|
|
bool is_dirty() const { return m_dirty; }
|
|
|
|
|
void set_dirty(bool b) { m_dirty = b; }
|
|
|
|
|
|
|
|
|
|
private:
|
2021-02-26 20:28:22 +01:00
|
|
|
Vector<Cell> m_cells;
|
2020-05-15 18:57:50 +02:00
|
|
|
bool m_dirty { false };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|