mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
term: fix too long h_divider lines in CI
This commit is contained in:
parent
78c96fe989
commit
9ac0c54eb0
@ -1,15 +1,12 @@
|
|||||||
module term
|
module term
|
||||||
|
|
||||||
// h_divider will return a horizontal divider line with a dynamic width,
|
// h_divider will return a horizontal divider line with a dynamic width,
|
||||||
// that depends on the current terminal settings
|
// that depends on the current terminal settings
|
||||||
pub fn h_divider(divider string) string {
|
pub fn h_divider(divider string) string {
|
||||||
mut cols := 76
|
mut cols := 76
|
||||||
term_cols, _ := get_terminal_size()
|
term_cols,_ := get_terminal_size()
|
||||||
|
|
||||||
if term_cols > 0 {
|
if term_cols > 0 {
|
||||||
cols = term_cols
|
cols = term_cols
|
||||||
}
|
}
|
||||||
|
|
||||||
result := divider.repeat(1 + (cols / divider.len))
|
result := divider.repeat(1 + (cols / divider.len))
|
||||||
return result[0..cols]
|
return result[0..cols]
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
module term
|
module term
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
pub struct C.winsize {
|
||||||
struct C.winsize{
|
pub:
|
||||||
pub:
|
ws_row u16
|
||||||
ws_row int
|
ws_col u16
|
||||||
ws_col int
|
ws_xpixel u16
|
||||||
|
ws_ypixel u16
|
||||||
}
|
}
|
||||||
|
|
||||||
fn C.ioctl() int
|
fn C.ioctl(fd int, request u64, arg voidptr) int
|
||||||
|
|
||||||
pub fn get_terminal_size() (int, int) {
|
|
||||||
// TODO: check for resize events
|
|
||||||
|
|
||||||
mut w := C.winsize{}
|
pub fn get_terminal_size() (int,int) {
|
||||||
|
if is_atty(1) <= 0 || os.getenv('TERM') == 'dumb' {
|
||||||
|
return 80,25
|
||||||
|
}
|
||||||
|
w := C.winsize{}
|
||||||
C.ioctl(0, C.TIOCGWINSZ, &w)
|
C.ioctl(0, C.TIOCGWINSZ, &w)
|
||||||
|
return int(w.ws_col),int(w.ws_row)
|
||||||
return w.ws_col, w.ws_row
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user