aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-12-17 16:20:53 +0100
committerFelix Morgner <felix.morgner@ost.ch>2025-12-17 16:21:16 +0100
commit801710fbce45bbe14d4bc927afc45a973bbf286f (patch)
treebacf835d7242d879a7b52ee03a220e95358aed9a /arch/x86_64/include
parent81a434499424f432a576469aad402ff18e05e6b4 (diff)
downloadteachos-801710fbce45bbe14d4bc927afc45a973bbf286f.tar.xz
teachos-801710fbce45bbe14d4bc927afc45a973bbf286f.zip
x86_64/vga: fix scrolling implementation
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/x86_64/boot/boot.hpp2
-rw-r--r--arch/x86_64/include/x86_64/vga/text.hpp19
2 files changed, 19 insertions, 2 deletions
diff --git a/arch/x86_64/include/x86_64/boot/boot.hpp b/arch/x86_64/include/x86_64/boot/boot.hpp
index 2c44659..0db2396 100644
--- a/arch/x86_64/include/x86_64/boot/boot.hpp
+++ b/arch/x86_64/include/x86_64/boot/boot.hpp
@@ -60,7 +60,7 @@ namespace teachos::boot
multiboot2::information_view const * mbi;
//! The index of the next character to be written in the VGA text buffer after handoff.
- std::size_t vga_buffer_index;
+ std::ptrdiff_t vga_buffer_index;
};
} // namespace teachos::boot
diff --git a/arch/x86_64/include/x86_64/vga/text.hpp b/arch/x86_64/include/x86_64/vga/text.hpp
index bb593e7..9f80f94 100644
--- a/arch/x86_64/include/x86_64/vga/text.hpp
+++ b/arch/x86_64/include/x86_64/vga/text.hpp
@@ -3,9 +3,11 @@
#include "kapi/cio.hpp"
+#include <cstddef>
#include <cstdint>
#include <span>
#include <string_view>
+#include <utility>
namespace teachos::vga::x86_64::text
{
@@ -123,14 +125,17 @@ namespace teachos::vga::x86_64::text
{
write(text, common_attributes::green_on_black);
}
+
auto writeln(std::string_view text) -> void override
{
writeln(text, common_attributes::green_on_black);
}
+
auto write_error(std::string_view text) -> void override
{
write(text, common_attributes::red_on_black);
}
+
auto writeln_error(std::string_view text) -> void override
{
writeln(text, common_attributes::red_on_black);
@@ -139,11 +144,19 @@ namespace teachos::vga::x86_64::text
private:
using glyph = std::pair<char, std::byte>;
+ [[nodiscard]] auto column() const noexcept -> std::ptrdiff_t;
+ [[nodiscard]] auto line() const noexcept -> std::ptrdiff_t;
+
/**
* @brief Move the cursor to a new line, scrolling the buffer if necessary.
*/
auto newline() -> void;
+ //! Scroll the screen by a number of lines.
+ //!
+ //! @param nof_lines The number of lines to scroll up.
+ auto scroll(std::ptrdiff_t nof_lines = 1) -> void;
+
/**
* @brief Write a string of code points to the VGA text buffer.
*
@@ -155,6 +168,10 @@ namespace teachos::vga::x86_64::text
*/
auto write(std::string_view code_points, attribute attribute) -> void;
+ //! Write a single code point to the VGA text buffer.
+ //!
+ //! @param code_point A single (8-bit) code point
+ //! @param attribute The #attribute to apply to the code point.
auto write(char code_point, attribute attribute) -> void;
/**
@@ -170,7 +187,7 @@ namespace teachos::vga::x86_64::text
std::span<glyph> static const buffer;
- std::size_t m_position{};
+ std::ptrdiff_t m_position{};
};
} // namespace teachos::vga::x86_64::text