aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/video/vga/text.hpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/arch/x86_64/include/arch/video/vga/text.hpp b/arch/x86_64/include/arch/video/vga/text.hpp
index 1e584d6..97344da 100644
--- a/arch/x86_64/include/arch/video/vga/text.hpp
+++ b/arch/x86_64/include/arch/video/vga/text.hpp
@@ -3,6 +3,7 @@
#include <cstdint>
#include <string_view>
+#include <type_traits>
namespace teachos::arch::video::vga::text
{
@@ -108,6 +109,55 @@ namespace teachos::arch::video::vga::text
* @see vga::text::attribute
*/
auto write(std::string_view code_points, attribute attribute) -> void;
+
+ /**
+ * @brief Write a single character to the VGA text buffer.
+ *
+ * @note This function also updates the text mode buffer pointer.
+ *
+ * @param code_point A code point to write to the VGA text mode buffer.
+ * @param attribute The attribute to apply to the written sequence of code points.
+ * @see vga::text::attribute
+ */
+ auto write_char(char code_point, attribute attribute) -> void;
+
+ // TODO: Move concepts to their own file/folder
+ template<typename T>
+ concept Integral = std::is_integral_v<T>;
+
+ /**
+ * @brief Write a integral value to the VGA text buffer.
+ *
+ * @note This function also updates the text mode buffer pointer.
+ *
+ * @param code_points A integral value to write to the VGA text mode buffer.
+ * @param attribute The attribute to apply to the written sequence of code points.
+ * @see vga::text::attribute
+ */
+ template<Integral T>
+ auto write_number(T value, attribute attribute) -> void
+ {
+ T current_value = value;
+
+ T divisor = 1;
+ while (current_value > 9)
+ {
+ divisor *= 10;
+ current_value = current_value / 10;
+ }
+
+ current_value = value;
+ while (divisor > 0)
+ {
+ uint8_t quotient = current_value / divisor;
+ char ascii_digit = quotient + '0';
+
+ write_char(ascii_digit, attribute);
+ current_value %= divisor;
+
+ divisor /= 10;
+ }
+ }
} // namespace teachos::arch::video::vga::text
#endif \ No newline at end of file