2020-01-29 05:12:12 +01:00
|
|
|
module term
|
|
|
|
|
2021-10-15 09:10:40 +02:00
|
|
|
#const $tty = require('tty');
|
2020-01-29 05:12:12 +01:00
|
|
|
// get_terminal_size returns a number of colums and rows of terminal window.
|
|
|
|
pub fn get_terminal_size() (int, int) {
|
2021-10-15 09:10:40 +02: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.
|
|
|
|
pub fn clear() {
|
|
|
|
print('\x1b[2J')
|
|
|
|
print('\x1b[H')
|
2020-01-29 05:12:12 +01:00
|
|
|
}
|