Loading [MathJax]/extensions/TeX/AMSsymbols.js
All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Modules Pages
console_color.h
1 /* This file is part of the Gudhi Library. The Gudhi library
2  * (Geometric Understanding in Higher Dimensions) is a generic C++
3  * library for computational topology.
4  *
5  * Author(s): Clement Jamin
6  *
7  * Copyright (C) 2016 Inria
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef CONSOLE_COLOR_H_
24 #define CONSOLE_COLOR_H_
25 
26 #include <iostream>
27 
28 #if defined(WIN32)
29 #include <windows.h>
30 #endif
31 
32 inline std::ostream& blue(std::ostream &s) {
33 #if defined(WIN32)
34  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
35  SetConsoleTextAttribute(hStdout,
36  FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
37 #else
38  s << "\x1b[0;34m";
39 #endif
40  return s;
41 }
42 
43 inline std::ostream& red(std::ostream &s) {
44 #if defined(WIN32)
45  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
46  SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
47 #else
48  s << "\x1b[0;31m";
49 #endif
50  return s;
51 }
52 
53 inline std::ostream& green(std::ostream &s) {
54 #if defined(WIN32)
55  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
56  SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
57 #else
58  s << "\x1b[0;32m";
59 #endif
60  return s;
61 }
62 
63 inline std::ostream& yellow(std::ostream &s) {
64 #if defined(WIN32)
65  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
66  SetConsoleTextAttribute(hStdout,
67  FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
68 #else
69  s << "\x1b[0;33m";
70 #endif
71  return s;
72 }
73 
74 inline std::ostream& white(std::ostream &s) {
75 #if defined(WIN32)
76  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
77  SetConsoleTextAttribute(hStdout,
78  FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
79 #else
80  s << "\x1b[0;37m";
81 #endif
82  return s;
83 }
84 
85 inline std::ostream& black_on_white(std::ostream &s) {
86 #if defined(WIN32)
87  HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
88  SetConsoleTextAttribute(hStdout,
89  BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
90 #else
91  s << "\x1b[0;33m";
92 #endif
93  return s;
94 }
95 
96 
97 #endif // CONSOLE_COLOR_H_
GUDHI  Version 2.2.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Thu Jun 14 2018 15:00:54 for GUDHI by Doxygen 1.8.13