000
16.08.2003, 18:25 Uhr
Pablo
Supertux (Operator)
|
Ich hab eine Header Datei mit den Escape Sequenzen für die Farben erstellt.
Hier der Code dafür:
colors.h
C++: |
/*************************************************************************** color.h - description ------------------- begin : 16.08.2003 copyright : (C) 2003 by Pablo email : pabloy@pcpool.mathematik.uni-freiburg.de ***************************************************************************/
/*************************************************************************** * * * 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 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/
#ifndef LS_COLORS_CONST #define LS_COLORS_CONST
#define BLACK "\033[0;30m" #define DARK_RED "\033[0;31m" #define DARK_GREEN "\033[0;32m" #define BROWNE "\033[0;33m" #define DARK_BLUE "\033[0;34m" #define DARK_PURPLE "\033[0;35m" #define DARK_CYAN "\033[0;36m" #define GRAY "\033[0;37m"
#define LIGHT_BLACK "\033[1;30m" #define LIGHT_RED "\033[1;31m" #define LIGHT_GREEN "\033[1;32m" #define YELLOW "\033[1;33m" #define LIGHT_BLUE "\033[1;34m" #define LIGHT_PURPLE "\033[1;35m" #define LIGHT_CYAN "\033[1;36m" #define WHITE "\033[1;37m"
#define BG_BLACK "\033[0;40m" #define BG_RED "\033[0;41m" #define BG_GREEN "\033[0;42m" #define BG_BROWNE "\033[0;43m" #define BG_BLUE "\033[0;44m" #define BG_PURPLE "\033[0;45m" #define BG_CYAN "\033[0;46m" #define BG_GRAY "\033[0;47m"
#define DEFAULT_COLOR "\033[0m" #define NORMAL_COLOR "\033[0m" #define DARK_TEXT "\033[0m" #define LIGHT_TEXT "\033[1m" #define UNDERLINED_TEXT "\033[4m" #define BLINKING_TEXT "\033[5m" // BLINKING_TEXT doesn't function on simple terminals such xterm // on KDE Terminal and on console use only. #endif
|
Mann kann sie auch von http://pcpool.mathematik.uni-freiburg.de/~pabloy/cpp/colors.h runterladen.
Usage:
C++: |
#include <stdio.h> #include "colors.h" int main() { printf("%sDer Text ist rot%s, aber nicht mehr.\n",DARK_RED, NORMAL_COLOR); printf("%s%s%sRoter Text, blauer heller Hintergrund%s\n", LIGHT_TEXT, BG_BLUE, LIGHT_RED,NORMAL_COLOR); }
|
-- A! Elbereth Gilthoniel! silivren penna míriel o menel aglar elenath, Gilthoniel, A! Elbereth! Dieser Post wurde am 07.10.2003 um 02:06 Uhr von Pablo Yanez Trujillo editiert. |