v/vlib/term/term.js.v

24 lines
487 B
V
Raw Normal View History

2020-01-29 05:12:12 +01:00
module term
#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) {
$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
}