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:
@@ -17,7 +17,8 @@ pub fn get_terminal_size() (int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clear clears current terminal screen.
|
// clear clears current terminal screen.
|
||||||
pub fn clear() {
|
pub fn clear() bool {
|
||||||
print('\x1b[2J')
|
print('\x1b[2J')
|
||||||
print('\x1b[H')
|
print('\x1b[H')
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ pub fn set_tab_title(title string) bool {
|
|||||||
|
|
||||||
// clear clears current terminal screen.
|
// clear clears current terminal screen.
|
||||||
// Implementation taken from https://docs.microsoft.com/en-us/windows/console/clearing-the-screen#example-2.
|
// 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)
|
hconsole := C.GetStdHandle(C.STD_OUTPUT_HANDLE)
|
||||||
mut csbi := C.CONSOLE_SCREEN_BUFFER_INFO{}
|
mut csbi := C.CONSOLE_SCREEN_BUFFER_INFO{}
|
||||||
mut scrollrect := C.SMALL_RECT{}
|
mut scrollrect := C.SMALL_RECT{}
|
||||||
@@ -106,7 +106,7 @@ pub fn clear() {
|
|||||||
|
|
||||||
// Get the number of character cells in the current buffer.
|
// Get the number of character cells in the current buffer.
|
||||||
if !C.GetConsoleScreenBufferInfo(hconsole, &csbi) {
|
if !C.GetConsoleScreenBufferInfo(hconsole, &csbi) {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
// Scroll the rectangle of the entire buffer.
|
// Scroll the rectangle of the entire buffer.
|
||||||
scrollrect.Left = 0
|
scrollrect.Left = 0
|
||||||
@@ -130,4 +130,5 @@ pub fn clear() {
|
|||||||
csbi.dwCursorPosition.Y = 0
|
csbi.dwCursorPosition.Y = 0
|
||||||
|
|
||||||
C.SetConsoleCursorPosition(hconsole, csbi.dwCursorPosition)
|
C.SetConsoleCursorPosition(hconsole, csbi.dwCursorPosition)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user