From c0dc531ebefd8912819f3b6c8bda1fed3c7e750c Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 31 Jan 2024 06:11:00 +0300 Subject: make it simple, but not simpler --- lib/ansi.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/ansi.php (limited to 'lib/ansi.php') diff --git a/lib/ansi.php b/lib/ansi.php new file mode 100644 index 0000000..9e0a425 --- /dev/null +++ b/lib/ansi.php @@ -0,0 +1,32 @@ +value + ($fg_bright ? 90 : 30); + if (!is_null($bg)) + $codes[] = $bg->value + ($bg_bright ? 100 : 40); + if ($bold) + $codes[] = 1; + + if (empty($codes)) + return $text; + + return "\033[".implode(';', $codes)."m".$text."\033[0m"; +} \ No newline at end of file -- cgit v1.2.3