1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47:44 +00:00

Kernel+LibVT: Add function for deleting a range of characters

Previously, this was done by telling the client to put a space at each
character in the range. This was inefficient, because a large number of
function calls took place and incorrect, as the ANSI standard dictates
that character attributes should be cleared as well.

The newly added `clear_in_line` function solves this issue. It performs
just one bounds check when it's called and can be implemented as a
pretty tight loop.
This commit is contained in:
Daniel Bertalan 2021-06-05 11:12:00 +02:00 committed by Andreas Kling
parent 8f8fd9c5a8
commit 7419569a2b
7 changed files with 60 additions and 53 deletions

View file

@ -33,7 +33,11 @@ public:
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&);
void clear(const Attribute& attribute = Attribute())
{
clear_range(0, m_cells.size() - 1, attribute);
}
void clear_range(size_t first_column, size_t last_column, const Attribute& attribute = Attribute());
bool has_only_one_background_color() const;
size_t length() const { return m_cells.size(); }