aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src/vga/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/src/vga/text.cpp')
-rw-r--r--arch/x86_64/src/vga/text.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index 5c94b84..af089fd 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -13,19 +13,24 @@ namespace teachos::x86_64::vga::text
{
namespace
{
- auto buffer_offset = std::ptrdiff_t{};
+ auto constinit buffer_offset = std::ptrdiff_t{};
auto constexpr DEFAULT_TEXT_BUFFER_WIDTH = 80U;
auto constexpr DEFAULT_TEXT_BUFFER_HEIGHT = 25U;
+
+ auto write_char(char code_point, attribute attribute) -> void
+ {
+ vga_buffer_pointer[buffer_offset++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
+ };
} // namespace
- auto clear(attribute attribute) -> void
+ auto device::clear(attribute attribute) -> void
{
buffer_offset = 0;
std::ranges::fill_n(vga_buffer_pointer.get(), 2000, std::pair{' ', std::bit_cast<std::byte>(attribute)});
}
- auto cursor(bool enabled) -> void
+ auto device::cursor(bool enabled) -> void
{
auto cursor_disable_byte = std::byte{!enabled} << 5;
@@ -33,7 +38,7 @@ namespace teachos::x86_64::vga::text
crtc::data::write(crtc::data::read() | cursor_disable_byte);
}
- auto newline() -> void
+ auto device::newline() -> void
{
auto current_line = buffer_offset / DEFAULT_TEXT_BUFFER_WIDTH;
auto next_line = current_line + 1;
@@ -51,13 +56,15 @@ namespace teachos::x86_64::vga::text
}
}
- auto write_char(char code_point, attribute attribute) -> void
+ auto device::write(std::string_view code_points, attribute attribute) -> void
{
- vga_buffer_pointer[buffer_offset++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
- };
+ std::ranges::for_each(code_points, [&](auto code_point) { write_char(code_point, attribute); });
+ }
- auto write(std::string_view code_points, attribute attribute) -> void
+ auto device::writeln(std::string_view code_points, attribute attribute) -> void
{
std::ranges::for_each(code_points, [&](auto code_point) { write_char(code_point, attribute); });
+ newline();
}
+
} // namespace teachos::x86_64::vga::text