From c762a0c4d68bfc7de9dc4dea9afdad6870bd4d58 Mon Sep 17 00:00:00 2001 From: Tyler Lanphear Date: Fri, 8 Jan 2021 01:32:30 -0500 Subject: [PATCH] LibC: Implement tgoto(). --- Libraries/LibC/termcap.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Libraries/LibC/termcap.cpp b/Libraries/LibC/termcap.cpp index 47f88a7fe5..1dcc73df68 100644 --- a/Libraries/LibC/termcap.cpp +++ b/Libraries/LibC/termcap.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -140,9 +141,17 @@ int tgetnum(const char* id) ASSERT_NOT_REACHED(); } +static Vector s_tgoto_buffer; char* tgoto([[maybe_unused]] const char* cap, [[maybe_unused]] int col, [[maybe_unused]] int row) { - ASSERT_NOT_REACHED(); + auto cap_str = String(cap); + cap_str.replace("%p1%d", String::format("%d", col)); + cap_str.replace("%p2%d", String::format("%d", row)); + + s_tgoto_buffer.clear_with_capacity(); + s_tgoto_buffer.ensure_capacity(cap_str.length()); + (void)cap_str.copy_characters_to_buffer(s_tgoto_buffer.data(), cap_str.length()); + return s_tgoto_buffer.data(); } int tputs(const char* str, [[maybe_unused]] int affcnt, int (*putc)(int))