From 30d4e25385d9abde7a2a7738351f9307efcc44d9 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 31 Jul 2023 10:39:28 +0300 Subject: [PATCH] term: fix `v run cmd/tools/check_os_api_parity.v term`, for term.clear --- vlib/term/term.js.v | 3 ++- vlib/term/term_windows.c.v | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/term/term.js.v b/vlib/term/term.js.v index eb24a6d903..078275d020 100644 --- a/vlib/term/term.js.v +++ b/vlib/term/term.js.v @@ -17,7 +17,8 @@ pub fn get_terminal_size() (int, int) { } // clear clears current terminal screen. -pub fn clear() { +pub fn clear() bool { print('\x1b[2J') print('\x1b[H') + return true } diff --git a/vlib/term/term_windows.c.v b/vlib/term/term_windows.c.v index a1632252bb..89cf26d224 100644 --- a/vlib/term/term_windows.c.v +++ b/vlib/term/term_windows.c.v @@ -97,7 +97,7 @@ pub fn set_tab_title(title string) bool { // clear clears current terminal screen. // Implementation taken from https://docs.microsoft.com/en-us/windows/console/clearing-the-screen#example-2. -pub fn clear() { +pub fn clear() bool { hconsole := C.GetStdHandle(C.STD_OUTPUT_HANDLE) mut csbi := C.CONSOLE_SCREEN_BUFFER_INFO{} mut scrollrect := C.SMALL_RECT{} @@ -106,7 +106,7 @@ pub fn clear() { // Get the number of character cells in the current buffer. if !C.GetConsoleScreenBufferInfo(hconsole, &csbi) { - return + return false } // Scroll the rectangle of the entire buffer. scrollrect.Left = 0 @@ -130,4 +130,5 @@ pub fn clear() { csbi.dwCursorPosition.Y = 0 C.SetConsoleCursorPosition(hconsole, csbi.dwCursorPosition) + return true }