display: message with color
This commit is contained in:
parent
8d0bfeb839
commit
e05126e1e1
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
||||
*
|
||||
* 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 3 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "display.hpp"
|
||||
|
||||
#define KNRM "\x1B[0m"
|
||||
#define KRED "\x1B[31m"
|
||||
#define KGRN "\x1B[32m"
|
||||
#define KYEL "\x1B[33m"
|
||||
#define KBLU "\x1B[34m"
|
||||
#define KMAG "\x1B[35m"
|
||||
#define KCYN "\x1B[36m"
|
||||
#define KWHT "\x1B[37m"
|
||||
|
||||
void printError(std::string err, bool eol)
|
||||
{
|
||||
std::cerr << KRED << err << "\e[0m" << std::flush;
|
||||
if (eol)
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void printInfo(std::string info, bool eol)
|
||||
{
|
||||
std::cout << KBLU << info << "\e[0m" << std::flush;
|
||||
if (eol)
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void printSuccess(std::string success, bool eol)
|
||||
{
|
||||
std::cout << KGRN << success << "\e[0m" << std::flush;
|
||||
if (eol)
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
||||
*
|
||||
* 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 3 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_HPP_
|
||||
#define DISPLAY_HPP_
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void printError(std::string err, bool eol = true);
|
||||
void printInfo(std::string info, bool eol = true);
|
||||
void printSuccess(std::string success, bool eol = true);
|
||||
|
||||
#endif // DISPLAY_HPP_
|
||||
Loading…
Reference in New Issue