adding ansi color codes

This commit is contained in:
Kbz-8
2024-01-20 19:22:18 +01:00
parent 12bb54b2fd
commit d9d6bb3a8c
10 changed files with 122 additions and 19 deletions

View File

@@ -6,17 +6,19 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/20 09:27:04 by maldavid #+# #+# */
/* Updated: 2024/01/20 13:16:21 by maldavid ### ########.fr */
/* Updated: 2024/01/20 19:19:39 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <unstd/unique_ptr.h>
#include <unstd/shared_ptr.h>
#include <unstd/weak_ptr.h>
#include <unstd/unique_ptr.hpp>
#include <unstd/shared_ptr.hpp>
#include <unstd/weak_ptr.hpp>
#include <ansi.hpp>
int main(int ac, char** av)
{
(void)ac;
(void)av;
std::cout << AnsiColor::red << "this" << AnsiColor::blue << " is" << AnsiColor::green << " a" << AnsiColor::yellow << " test" << AnsiColor::reset << std::endl;
return 0;
}

19
srcs/utils/ansi.cpp Normal file
View File

@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ansi.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/20 19:08:31 by maldavid #+# #+# */
/* Updated: 2024/01/20 19:18:41 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include <ansi.hpp>
#include <unstd/string.hpp>
std::ostream& operator<<(std::ostream& os, const AnsiColor::Codes code)
{
return os << "\033[1;" << unstd::toString(static_cast<int>(code)) << "m";
}