aboutsummaryrefslogtreecommitdiff
path: root/source/arch/x86_64/src/video
diff options
context:
space:
mode:
Diffstat (limited to 'source/arch/x86_64/src/video')
-rw-r--r--source/arch/x86_64/src/video/vga/text.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/source/arch/x86_64/src/video/vga/text.cpp b/source/arch/x86_64/src/video/vga/text.cpp
index 11e3b1a..df61ce6 100644
--- a/source/arch/x86_64/src/video/vga/text.cpp
+++ b/source/arch/x86_64/src/video/vga/text.cpp
@@ -5,25 +5,34 @@
#include <algorithm>
#include <string_view>
+#include <utility>
namespace teachos::arch::video::vga::text
{
namespace
{
- auto constinit text_buffer = teachos::boot::asm_pointer{boot::vga_buffer_pointer};
+ auto constexpr default_text_buffer_address = 0xb8000;
- auto write(char character, std::byte color) -> void
+ extern "C" std::pair<char, attribute> * vga_buffer_pointer;
+ auto constinit text_buffer = teachos::boot::asm_pointer{vga_buffer_pointer};
+
+ auto write(char code_point, attribute attribute) -> void
{
auto & p = *text_buffer;
- (*p++) = static_cast<std::byte>(character);
- (*p++) = color;
+ (*p++) = std::pair{code_point, attribute};
};
} // namespace
- auto write(std::string_view text, std::byte color) -> void
+ auto clear(attribute attribute) -> void
+ {
+ *text_buffer = reinterpret_cast<decltype(text_buffer)::pointer>(default_text_buffer_address);
+ std::ranges::generate_n(*text_buffer, 2000, [&]{ return std::pair{' ', attribute}; });
+ }
+
+ auto write(std::string_view code_points, attribute attribute) -> void
{
- std::ranges::for_each(text, [&](auto character) { write(character, color); });
+ std::ranges::for_each(code_points, [&](auto code_point) { write(code_point, attribute); });
}
} // namespace teachos::arch::video::vga::text \ No newline at end of file