2020-01-29 07:12:12 +03:00
|
|
|
module term
|
|
|
|
|
2021-10-15 10:10:40 +03:00
|
|
|
#const $tty = require('tty');
|
2020-01-29 07:12:12 +03:00
|
|
|
// get_terminal_size returns a number of colums and rows of terminal window.
|
|
|
|
pub fn get_terminal_size() (int, int) {
|
2021-10-15 10:10:40 +03:00
|
|
|
$if js_node {
|
|
|
|
colums := 0
|
|
|
|
rows := 0
|
|
|
|
#let sizes = $tty.WriteStream(1).getWindowSize();
|
|
|
|
#colums.val = sizes[0];
|
|
|
|
#rows.val = sizes[1];
|
|
|
|
|
|
|
|
return colums, rows
|
|
|
|
} $else {
|
|
|
|
return default_columns_size, default_rows_size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear clears current terminal screen.
|
2023-07-31 10:39:28 +03:00
|
|
|
pub fn clear() bool {
|
2021-10-15 10:10:40 +03:00
|
|
|
print('\x1b[2J')
|
|
|
|
print('\x1b[H')
|
2023-07-31 10:39:28 +03:00
|
|
|
return true
|
2020-01-29 07:12:12 +03:00
|
|
|
}
|