serenity/Userland/Libraries/LibVT/Line.h
Liav A 20743e8aed Kernel/Graphics + SystemServer: Support text mode properly
As we removed the support of VBE modesetting that was done by GRUB early
on boot, we need to determine if we can modeset the resolution with our
drivers, and if not, we should enable text mode and ensure that
SystemServer knows about it too.

Also, SystemServer should first check if there's a framebuffer device
node, which is an indication that text mode was not even if it was
requested. Then, if it doesn't find it, it should check what boot_mode
argument the user specified (in case it's self-test). This way if we
try to use bochs-display device (which is not VGA compatible) and
request a text mode, it will not honor the request and will continue
with graphical mode.

Also try to print critical messages with mininum memory allocations
possible.

In LibVT, We make the implementation flexible for kernel-specific
methods that are implemented in ConsoleImpl class.
2021-05-16 19:58:33 +02:00

60 lines
1.3 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibVT/Attribute.h>
#include <LibVT/XtermColors.h>
namespace VT {
class Line {
AK_MAKE_NONCOPYABLE(Line);
AK_MAKE_NONMOVABLE(Line);
public:
explicit Line(size_t length);
~Line();
struct Cell {
u32 code_point { ' ' };
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&);
bool has_only_one_background_color() const;
size_t length() const { return m_cells.size(); }
void set_length(size_t);
u32 code_point(size_t index) const
{
return m_cells[index].code_point;
}
void set_code_point(size_t index, u32 code_point)
{
m_cells[index].code_point = code_point;
}
bool is_dirty() const { return m_dirty; }
void set_dirty(bool b) { m_dirty = b; }
private:
Vector<Cell> m_cells;
bool m_dirty { false };
};
}