aboutsummaryrefslogtreecommitdiff
path: root/source/arch/x86_64/include
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2023-10-11 15:37:06 +0200
committerFelix Morgner <felix.morgner@ost.ch>2023-10-11 15:37:06 +0200
commit6e1d10528b1c04c34c57995c85b45448715767f2 (patch)
tree08531be2d19fc666a23d96371c8e91aab97ce53f /source/arch/x86_64/include
parent74eaee0fcc7390d4290b41a2a92ee34346e2f7c2 (diff)
downloadteachos-6e1d10528b1c04c34c57995c85b45448715767f2.tar.xz
teachos-6e1d10528b1c04c34c57995c85b45448715767f2.zip
x86_64: vga: improve text printing code
Diffstat (limited to 'source/arch/x86_64/include')
-rw-r--r--source/arch/x86_64/include/arch/boot/pointers.hpp1
-rw-r--r--source/arch/x86_64/include/arch/video/vga/text.hpp53
2 files changed, 50 insertions, 4 deletions
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 <cstddef>
+#include <cstdint>
#include <string_view>
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