diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-10 22:53:50 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-10 22:53:50 +0200 |
commit | 6f54758123abe9f137922df1e8d7e33835e9a9f2 (patch) | |
tree | e21b553a826c7ae67cc4b41ffde921e39ed4022b /libk/stdlib.h | |
parent | Add some compiler warnings (diff) | |
download | kernel.cpp-6f54758123abe9f137922df1e8d7e33835e9a9f2.tar.xz |
Update VGA cursor position on printk
Diffstat (limited to 'libk/stdlib.h')
-rw-r--r-- | libk/stdlib.h | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/libk/stdlib.h b/libk/stdlib.h index 7d89a0c..a336586 100644 --- a/libk/stdlib.h +++ b/libk/stdlib.h @@ -7,33 +7,40 @@ class Console { virtual ~Console() = default; virtual void write(char c) = 0; virtual void write(ViewIterator& msg) = 0; + virtual void update_cursor() = 0; static void set(Console* ptr); static Console* get(); }; template <typename T> -void printk(const T& a) { - if (auto* c = Console::get()) { - if constexpr (is_same<T, char>()) { - c->write(a); - } else if constexpr (requires { StringView(a); }) { - StringView v(a); - auto iter = v.begin(); - c->write(iter); - } else if constexpr (requires { IntegerView(a); }) { - IntegerView v(a); - auto iter = v.begin(); - c->write(iter); - } else - c->write(a); - } +void print_c(Console* c, const T& a) { + if constexpr (is_same<T, char>()) { + c->write(a); + } else if constexpr (requires { StringView(a); }) { + StringView v(a); + auto iter = v.begin(); + c->write(iter); + } else if constexpr (requires { IntegerView(a); }) { + IntegerView v(a); + auto iter = v.begin(); + c->write(iter); + } else + c->write(a); +} + +template <typename T, typename... Args> +void print_c(Console* console, const T& a, const Args&... x) { + print_c(console, a); + print_c(console, x...); } template <typename T, typename... Args> void printk(const T& a, const Args&... x) { - printk(a); - printk(x...); + if (auto* c = Console::get()) { + print_c(c, a, x...); + c->update_cursor(); + } } extern "C" __attribute__((__noreturn__)) void abort(); |