]>
git.saurik.com Git - apple/system_cmds.git/blob - CPPUtil/UtilTerminalColor.cpp
2 // UtilTerminalColor.cpp
5 // Created by James McIlree on 4/26/13.
6 // Copyright (c) 2013 Apple. All rights reserved.
13 #define COLOR(FGBG, CODE, BOLD) "\033[0;" BOLD FGBG CODE "m"
15 #define ALLCOLORS(FGBG,BOLD) {\
16 COLOR(FGBG, "0", BOLD),\
17 COLOR(FGBG, "1", BOLD),\
18 COLOR(FGBG, "2", BOLD),\
19 COLOR(FGBG, "3", BOLD),\
20 COLOR(FGBG, "4", BOLD),\
21 COLOR(FGBG, "5", BOLD),\
22 COLOR(FGBG, "6", BOLD),\
23 COLOR(FGBG, "7", BOLD)\
26 static const char colorcodes
[2][2][8][10] = {
27 { ALLCOLORS("3",""), ALLCOLORS("3","1;") },
28 { ALLCOLORS("4",""), ALLCOLORS("4","1;") }
31 const char* TerminalColorStringFor(kTerminalColor code
, bool is_bold
, bool is_background
) {
32 return colorcodes
[is_background
? 1 : 0][is_bold
? 1 : 0][(uint32_t)code
& 7];
35 const char* TerminalColorResetString(void) {