端末の出力に色を付ける
caml-listを見て,要するに端末のエスケープシーケンスをそのまま出力してやれば良いんだとわかった.
てきとーにプログラミング.
type color = DefaultColor | BrightColor | UnderLineText | FlashText | BlackText | RedText | GreenText | YelloText | BlueText | PurpleText | CyanText | WhiteText | BlackBG | RedBG | GreenBG | YelloBG | BlueBG | PurpleBG | CyanBG | WhiteBG let print_color ppf color = let col = match color with DefaultColor -> "0" | BrightColor -> "1" | UnderLineText -> "4" | FlashText -> "5" | BlackText -> "30" | RedText -> "31" | GreenText -> "32" | YelloText -> "33" | BlueText -> "34" | PurpleText -> "35" | CyanText -> "36" | WhiteText -> "37" | BlackBG -> "40" | RedBG -> "41" | GreenBG -> "42" | YelloBG -> "43" | BlueBG -> "44" | PurpleBG -> "45" | CyanBG -> "46" | WhiteBG -> "47" in Format.pp_print_string ppf col let set_color ppf tty = Format.fprintf ppf "\027[%am" print_color tty let reset_color ppf () = Format.fprintf ppf "\027[%am" print_color DefaultColor let () = Format.printf "%aHello%a World%a@." set_color RedText set_color PurpleText reset_color ()
やべーーーー楽しーーーーーー
ちゃんと色が出るかどうかとかは,Unixモジュールを使って調べればいいのかな?(ぜんぜんわかってない人)