aboutsummaryrefslogtreecommitdiff
path: root/kern/src/print.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2025-07-14 16:02:43 +0000
committerFelix Morgner <felix.morgner@ost.ch>2025-07-14 16:02:43 +0000
commit25483b7af8df6b08d460f807fda04c6d409bd44e (patch)
tree2001f9774fe179dd4a67c77f590aa7ee1406fb87 /kern/src/print.cpp
parent1b603d1145b9ee10b1b12a0f765bd2bc1ebe2b3c (diff)
downloadteachos-25483b7af8df6b08d460f807fda04c6d409bd44e.tar.xz
teachos-25483b7af8df6b08d460f807fda04c6d409bd44e.zip
ide: start large-scale restructuring
Diffstat (limited to 'kern/src/print.cpp')
-rw-r--r--kern/src/print.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/kern/src/print.cpp b/kern/src/print.cpp
new file mode 100644
index 0000000..64e2c65
--- /dev/null
+++ b/kern/src/print.cpp
@@ -0,0 +1,76 @@
+
+#include "kern/print.hpp"
+
+#include <string_view>
+
+namespace teachos
+{
+ namespace
+ {
+ print_handler * current_print_handler{};
+ println_handler * current_println_handler{};
+ print_handler * current_print_error_handler{};
+ println_handler * current_println_error_handler{};
+ } // namespace
+
+ auto print(std::string_view text) -> void
+ {
+ if (current_print_handler)
+ {
+ current_print_handler(text);
+ }
+ }
+
+ auto println(std::string_view text) -> void
+ {
+ if (current_println_handler)
+ {
+ current_println_handler(text);
+ }
+ }
+
+ auto print_error(std::string_view text) -> void
+ {
+ if (current_print_error_handler)
+ {
+ current_print_error_handler(text);
+ }
+ }
+
+ auto println_error(std::string_view text) -> void
+ {
+ if (current_println_error_handler)
+ {
+ current_println_error_handler(text);
+ }
+ }
+
+ auto set_print_handler(print_handler handler) -> print_handler *
+ {
+ auto old = current_print_handler;
+ current_print_handler = handler;
+ return old;
+ }
+
+ auto set_println_handler(println_handler handler) -> print_handler *
+ {
+ auto old = current_println_handler;
+ current_println_handler = handler;
+ return old;
+ }
+
+ auto set_print_error_handler(print_handler handler) -> print_handler *
+ {
+ auto old = current_print_error_handler;
+ current_print_error_handler = handler;
+ return old;
+ }
+
+ auto set_println_error_handler(println_handler handler) -> print_handler *
+ {
+ auto old = current_println_error_handler;
+ current_println_error_handler = handler;
+ return old;
+ }
+
+} // namespace teachos