From 6e1d10528b1c04c34c57995c85b45448715767f2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 11 Oct 2023 15:37:06 +0200 Subject: x86_64: vga: improve text printing code --- source/arch/x86_64/include/arch/boot/pointers.hpp | 1 - source/arch/x86_64/include/arch/video/vga/text.hpp | 53 ++++++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) (limited to 'source/arch/x86_64/include') diff --git a/source/arch/x86_64/include/arch/boot/pointers.hpp b/source/arch/x86_64/include/arch/boot/pointers.hpp index 052b115..dcd14fe 100644 --- a/source/arch/x86_64/include/arch/boot/pointers.hpp +++ b/source/arch/x86_64/include/arch/boot/pointers.hpp @@ -6,7 +6,6 @@ namespace teachos::arch::boot { extern "C" std::byte const multiboot_information_pointer; - extern "C" std::byte * vga_buffer_pointer; } // namespace teachos::arch::boot #endif \ No newline at end of file diff --git a/source/arch/x86_64/include/arch/video/vga/text.hpp b/source/arch/x86_64/include/arch/video/vga/text.hpp index 04b74d1..c9a79b8 100644 --- a/source/arch/x86_64/include/arch/video/vga/text.hpp +++ b/source/arch/x86_64/include/arch/video/vga/text.hpp @@ -1,12 +1,59 @@ #ifndef TEACHOS_ARCH_X86_64_VIDEO_VGA_TEXT_HPP #define TEACHOS_ARCH_X86_64_VIDEO_VGA_TEXT_HPP -#include +#include #include namespace teachos::arch::video::vga::text { - auto write(std::string_view text, std::byte color) -> void; -} + enum struct color : std::uint8_t + { + black, + blue, + green, + cyan, + red, + purple, + brown, + gray, + }; + + enum struct foreground_flag : bool + { + none, + intense, + }; + + enum struct background_flag : bool + { + none, + blink_or_bright, + }; + + struct attribute + { + color foreground_color : 3; + enum foreground_flag foreground_flag : 1; + color bacground_color : 3; + enum background_flag background_flag : 1; + }; + + static_assert(sizeof(attribute) == 1); + + namespace common_attributes + { + [[maybe_unused]] + auto constexpr gray_on_black = attribute{color::gray, foreground_flag::none, color::black, background_flag::none}; + + [[maybe_unused]] + auto constexpr green_on_black = attribute{color::green, foreground_flag::none, color::black, background_flag::none}; + + [[maybe_unused]] + auto constexpr white_on_red = attribute{color::gray, foreground_flag::intense, color::red, background_flag::none}; + } + + auto clear(attribute attribute = common_attributes::gray_on_black) -> void; + auto write(std::string_view code_points, attribute attribute) -> void; +} // namespace teachos::arch::video::vga::text #endif \ No newline at end of file -- cgit v1.2.3