1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/term/can_show_color.v
vitalyster e64609387d term: colors on Windows console
* isConsole moved to builtin is_atty function
* Windows console initialization moved to builtin.init
2019-10-10 20:08:36 +03:00

30 lines
475 B
V

module term
import os
pub fn can_show_color_on_stdout() bool {
return is_atty(1) && os.getenv('TERM') != 'dumb'
}
pub fn can_show_color_on_stderr() bool {
return is_atty(2) && os.getenv('TERM') != 'dumb'
}
//////////////////////////////////////////////
pub fn ok_message(s string) string {
return if can_show_color_on_stdout() {
green( s )
}else{
s
}
}
pub fn fail_message(s string) string {
return if can_show_color_on_stdout() {
red( s )
}else{
s
}
}