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.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/arch/x86_64/src/vga/text.cpp b/arch/x86_64/src/vga/text.cpp
index d4548a2..8f6214e 100644
--- a/arch/x86_64/src/vga/text.cpp
+++ b/arch/x86_64/src/vga/text.cpp
@@ -1,6 +1,7 @@
#include "x86_64/vga/text.hpp"
#include "kapi/boot.hpp"
+#include "kapi/cio.hpp"
#include "x86_64/boot/boot.hpp"
#include "x86_64/boot/ld.hpp"
@@ -76,6 +77,20 @@ namespace teachos::vga::x86_64::text
m_position = (line() - scroll_count) * DEFAULT_TEXT_BUFFER_WIDTH;
}
+ auto device::write(cio::output_stream stream, std::string_view text) -> void
+ {
+ auto attributes = [&] -> attribute {
+ switch (stream)
+ {
+ case cio::output_stream::stderr:
+ return common_attributes::red_on_black;
+ default:
+ return common_attributes::green_on_black;
+ }
+ }();
+ write(text, attributes);
+ }
+
auto device::write(std::string_view code_points, attribute attribute) -> void
{
std::ranges::for_each(code_points, [&](auto code_point) -> void { write(code_point, attribute); });
@@ -87,16 +102,17 @@ namespace teachos::vga::x86_64::text
{
scroll();
}
- buffer[m_position++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
- };
- auto device::writeln(std::string_view code_points, attribute attribute) -> void
- {
- std::ranges::for_each(code_points, [&](auto code_point) -> void { write(code_point, attribute); });
- if (column())
+ if (code_point == '\n')
{
- newline();
+ if (column())
+ {
+ newline();
+ }
+ return;
}
- }
+
+ buffer[m_position++] = std::pair{code_point, std::bit_cast<std::byte>(attribute)};
+ };
} // namespace teachos::vga::x86_64::text