kernel/TextConsole: Add a write() function that accepts a fixed-size buffer instead of relying on null terminators

This commit is contained in:
apio 2023-03-18 20:09:10 +01:00
parent 629ed9e43b
commit d01ba20749
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 7 additions and 0 deletions

View File

@ -172,6 +172,12 @@ namespace TextConsole
return {};
}
Result<void> write(const char* str, usize len)
{
while (len--) TRY(putchar(*str++));
return {};
}
void wprint(const wchar_t* str)
{
while (*str) putwchar(*str++);

View File

@ -14,6 +14,7 @@ namespace TextConsole
u32 background();
void move_to(u32 x, u32 y);
Result<void> print(const char* str);
Result<void> write(const char* str, usize len);
void wprint(const wchar_t* str);
Result<void> println(const char* str);
void wprintln(const wchar_t* str);