adding ansi color codes
This commit is contained in:
3
Makefile
3
Makefile
@@ -6,13 +6,14 @@
|
|||||||
# By: vavaas <vvaas@student.42.fr> +#+ +:+ +#+ #
|
# By: vavaas <vvaas@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2023/08/09 15:08:49 by vavaas #+# #+# #
|
# Created: 2023/08/09 15:08:49 by vavaas #+# #+# #
|
||||||
# Updated: 2024/01/20 10:01:26 by maldavid ### ########.fr #
|
# Updated: 2024/01/20 19:16:37 by maldavid ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
NAME = ircserv
|
NAME = ircserv
|
||||||
|
|
||||||
SRCS = srcs/main.cpp \
|
SRCS = srcs/main.cpp \
|
||||||
|
srcs/utils/ansi.cpp \
|
||||||
|
|
||||||
OBJ_DIR = objs
|
OBJ_DIR = objs
|
||||||
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.cpp=.o))
|
||||||
|
|||||||
52
includes/ansi.hpp
Normal file
52
includes/ansi.hpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ansi.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/01/20 19:05:23 by maldavid #+# #+# */
|
||||||
|
/* Updated: 2024/01/20 19:09:18 by maldavid ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef __ANSI__
|
||||||
|
#define __ANSI__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace AnsiColor
|
||||||
|
{
|
||||||
|
enum Codes
|
||||||
|
{
|
||||||
|
red = 31,
|
||||||
|
green = 32,
|
||||||
|
blue = 34,
|
||||||
|
def = 0,
|
||||||
|
black = 30,
|
||||||
|
yellow = 33,
|
||||||
|
magenta = 35,
|
||||||
|
cyan = 36,
|
||||||
|
white = 37,
|
||||||
|
bg_red = 41,
|
||||||
|
bg_green = 42,
|
||||||
|
bg_blue = 44,
|
||||||
|
bg_def = 0,
|
||||||
|
bg_black = 40,
|
||||||
|
bg_yellow = 43,
|
||||||
|
bg_magenta = 45,
|
||||||
|
bg_cyan = 46,
|
||||||
|
bg_white = 47,
|
||||||
|
reset = 0,
|
||||||
|
bold = 1,
|
||||||
|
underline = 4,
|
||||||
|
inverse = 7,
|
||||||
|
bold_off = 21,
|
||||||
|
underline_off = 24,
|
||||||
|
inverse_off = 27
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const AnsiColor::Codes code);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* array.h :+: :+: :+: */
|
/* array.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 09:31:30 by maldavid #+# #+# */
|
/* Created: 2024/01/20 09:31:30 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 09:40:29 by maldavid ### ########.fr */
|
/* Updated: 2024/01/20 19:12:36 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ref_counter.h :+: :+: :+: */
|
/* ref_counter.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 12:54:09 by maldavid #+# #+# */
|
/* Created: 2024/01/20 12:54:09 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 12:55:02 by maldavid ### ########.fr */
|
/* Updated: 2024/01/20 19:12:33 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* shared_ptr.h :+: :+: :+: */
|
/* shared_ptr.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 10:09:02 by maldavid #+# #+# */
|
/* Created: 2024/01/20 10:09:02 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 13:08:04 by maldavid ### ########.fr */
|
/* Updated: 2024/01/20 19:12:42 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef __UNSTD_SHARED_PTR__
|
#ifndef __UNSTD_SHARED_PTR__
|
||||||
#define __UNSTD_SHARED_PTR__
|
#define __UNSTD_SHARED_PTR__
|
||||||
|
|
||||||
#include <unstd/bits/ref_counter.h>
|
#include <unstd/bits/ref_counter.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
29
includes/unstd/string.hpp
Normal file
29
includes/unstd/string.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* string.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2024/01/20 19:13:26 by maldavid #+# #+# */
|
||||||
|
/* Updated: 2024/01/20 19:14:55 by maldavid ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef __UNSTD_STRING__
|
||||||
|
#define __UNSTD_STRING__
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace unstd
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
std::string toString(T n)
|
||||||
|
{
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << n;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* unique_ptr.h :+: :+: :+: */
|
/* unique_ptr.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 09:40:56 by maldavid #+# #+# */
|
/* Created: 2024/01/20 09:40:56 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 10:06:54 by maldavid ### ########.fr */
|
/* Updated: 2024/01/20 19:12:51 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* weak_ptr.h :+: :+: :+: */
|
/* weak_ptr.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 11:17:07 by maldavid #+# #+# */
|
/* Created: 2024/01/20 11:17:07 by maldavid #+# #+# */
|
||||||
/* Updated: 2024/01/20 13:16:14 by maldavid ### ########.fr */
|
/* Updated: 2024/01/20 19:13:13 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef __UNSTD_WEAK_PTR__
|
#ifndef __UNSTD_WEAK_PTR__
|
||||||
#define __UNSTD_WEAK_PTR__
|
#define __UNSTD_WEAK_PTR__
|
||||||
|
|
||||||
#include <unstd/bits/ref_counter.h>
|
#include <unstd/bits/ref_counter.hpp>
|
||||||
#include <unstd/shared_ptr.h>
|
#include <unstd/shared_ptr.hpp>
|
||||||
|
|
||||||
namespace unstd
|
namespace unstd
|
||||||
{
|
{
|
||||||
@@ -46,6 +46,6 @@ namespace unstd
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <unstd/weak_ptr.h>
|
#include <unstd/weak_ptr.ipp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -6,17 +6,19 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/01/20 09:27:04 by maldavid #+# #+# */
|
/* 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/unique_ptr.hpp>
|
||||||
#include <unstd/shared_ptr.h>
|
#include <unstd/shared_ptr.hpp>
|
||||||
#include <unstd/weak_ptr.h>
|
#include <unstd/weak_ptr.hpp>
|
||||||
|
#include <ansi.hpp>
|
||||||
|
|
||||||
int main(int ac, char** av)
|
int main(int ac, char** av)
|
||||||
{
|
{
|
||||||
(void)ac;
|
(void)ac;
|
||||||
(void)av;
|
(void)av;
|
||||||
|
std::cout << AnsiColor::red << "this" << AnsiColor::blue << " is" << AnsiColor::green << " a" << AnsiColor::yellow << " test" << AnsiColor::reset << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
19
srcs/utils/ansi.cpp
Normal file
19
srcs/utils/ansi.cpp
Normal 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";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user