1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

term: fix v run cmd/tools/check_os_api_parity.v term, for term.clear

This commit is contained in:
Delyan Angelov 2023-07-31 10:39:28 +03:00
parent 32114a679a
commit 30d4e25385
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 5 additions and 3 deletions

View File

@ -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
}

View File

@ -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
}