TuttleOFX
1
|
00001 #ifndef _TUTTLE_COMMON_COLOR_HPP_ 00002 #define _TUTTLE_COMMON_COLOR_HPP_ 00003 00004 #include <tuttle/common/system/system.hpp> 00005 00006 #include <boost/utility.hpp> 00007 #include <boost/shared_ptr.hpp> 00008 00009 #include <string> 00010 00011 namespace tuttle { 00012 namespace common { 00013 00014 namespace details { 00015 #if defined __LINUX__ || defined __MACOS__ 00016 static const std::string kColorBlack ( "\E[1;30m" ); 00017 static const std::string kColorWhite ( "\E[1;37m" ); 00018 static const std::string kColorBlue ( "\E[1;34m" ); 00019 static const std::string kColorGreen ( "\E[0;32m" ); 00020 static const std::string kColorRed ( "\E[1;31m" ); 00021 static const std::string kColorCyan ( "\E[1;36m" ); 00022 static const std::string kColorMagenta ( "\E[1;35m" ); 00023 static const std::string kColorYellow ( "\E[0;33m" );//yellow isn't visible on light background, that's why a darker color is used here 00024 00025 static const std::string kColorStd ( "\E[0;0m" ); 00026 static const std::string kColorFolder ( kColorBlue ); 00027 static const std::string kColorFile ( kColorGreen ); 00028 static const std::string kColorSequence ( kColorGreen ); 00029 static const std::string kColorError ( kColorRed ); 00030 #else 00031 static const std::string kColorBlack ( "" ); 00032 static const std::string kColorWhite ( "" ); 00033 static const std::string kColorBlue ( "" ); 00034 static const std::string kColorGreen ( "" ); 00035 static const std::string kColorRed ( "" ); 00036 static const std::string kColorCyan ( "" ); 00037 static const std::string kColorMagenta ( "" ); 00038 static const std::string kColorYellow ( "" ); 00039 00040 static const std::string kColorStd ( "" ); 00041 static const std::string kColorFolder ( "" ); 00042 static const std::string kColorFile ( "" ); 00043 static const std::string kColorSequence ( "" ); 00044 static const std::string kColorError ( "" ); 00045 #endif 00046 } 00047 00048 class Color : boost::noncopyable 00049 { 00050 private: 00051 Color( ) { } 00052 00053 public: 00054 00055 static boost::shared_ptr<Color> get(); 00056 00057 ~Color(){} 00058 00059 std::string _blue; 00060 std::string _green; 00061 std::string _yellow; 00062 std::string _red; 00063 00064 std::string _folder; 00065 std::string _file; 00066 00067 std::string _std; 00068 std::string _error; 00069 00070 void disable() 00071 { 00072 _blue.clear(); 00073 _green.clear(); 00074 _red.clear(); 00075 _yellow.clear(); 00076 00077 _folder.clear(); 00078 _file.clear(); 00079 00080 _std.clear(); 00081 _error.clear(); 00082 } 00083 void enable() 00084 { 00085 using namespace common::details; 00086 _blue = kColorBlue; 00087 _green = kColorGreen; 00088 _red = kColorRed; 00089 _yellow = kColorYellow; 00090 00091 _folder = kColorFolder; 00092 _file = kColorFile; 00093 00094 _std = kColorStd; 00095 _error = kColorError; 00096 } 00097 00098 public: 00099 static boost::shared_ptr<Color> color; 00100 }; 00101 00102 } 00103 } 00104 00105 #endif 00106