1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283(*****************************************************************************
Liquidsoap, a programmable audio stream generator.
Copyright 2003-2023 Savonet team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details, fully stated in the COPYING
file at the root of the liquidsoap distribution.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************)(* Some of the code below was borrowed from opam. *)letdumb_term=lazy(trySys.getenv"TERM"="dumb"withNot_found->Sys.win32)typecolor_conf=[`Always|`Never|`Auto]letcolor_conf:color_confref=ref`Autoletcolor=letauto=lazy(tryUnix.isattyUnix.stdout&¬(Lazy.forcedumb_term)with_->false)infun()->match!color_confwith|`Always->true|`Never->false|`Auto->Lazy.forceautotypetext_style=[`bold|`underline|`crossed|`black|`red|`green|`yellow|`blue|`magenta|`cyan|`white]letstyle_code(c:text_style)=matchcwith|`bold->"01"|`underline->"04"|`crossed->"09"|`black->"30"|`red->"31"|`green->"32"|`yellow->"33"|`blue->"1;34"(* most terminals make blue unreadable unless bold *)|`magenta->"35"|`cyan->"36"|`white->"37"letcolorizestyless=ifnot(color())thenselsePrintf.sprintf"\027[%sm%s\027[0m"(String.concat";"(List.mapstyle_codestyles))sletstart_colorstyles=ifnot(color())then""elsePrintf.sprintf"\027[%sm"(String.concat";"(List.mapstyle_codestyles))letstop_color()=ifnot(color())then""else"\027[0m"