terminalsizewidthvlang

is there any way to get terminal width in v?


is There any way to get terminal width in V language? I want to get terminal size (or just columns). this is my code:

fn get_terminal_width() int {
    // help me
}
fn main() {
    width := get_terminal_width() - 5
    for _ in 0 .. width {
        print('=')
    }
    println('done')
}

Solution

  • You can use term.get_terminal_size().

    You can check out the documentation here (even if it is pretty empty for the moment): https://modules.vlang.io/term.html#get_terminal_size