1 /*=========================================================================
3 Program: KWSys - Kitware System Library
4 Module: $RCSfile: Terminal.h.in,v $
6 Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
13 =========================================================================*/
14 #ifndef @KWSYS_NAMESPACE@_Terminal_h
15 #define @KWSYS_NAMESPACE@_Terminal_h
17 #include <@KWSYS_NAMESPACE@/Configure.h>
19 #include <stdio.h> /* For file stream type FILE. */
21 /* Redefine all public interface symbol names to be in the proper
22 namespace. These macros are used internally to kwsys only, and are
23 not visible to user code. Use kwsysHeaderDump.pl to reproduce
24 these macros after making changes to the interface. */
25 #if !defined(KWSYS_NAMESPACE)
26 # define kwsys_ns(x) @KWSYS_NAMESPACE@##x
27 # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
29 #define kwsysTerminal_cfprintf kwsys_ns(Terminal_cfprintf)
30 #define kwsysTerminal_Color_e kwsys_ns(Terminal_Color_e)
31 #define kwsysTerminal_Color_Normal kwsys_ns(Terminal_Color_Normal)
32 #define kwsysTerminal_Color_ForegroundBlack kwsys_ns(Terminal_Color_ForegroundBlack)
33 #define kwsysTerminal_Color_ForegroundRed kwsys_ns(Terminal_Color_ForegroundRed)
34 #define kwsysTerminal_Color_ForegroundGreen kwsys_ns(Terminal_Color_ForegroundGreen)
35 #define kwsysTerminal_Color_ForegroundYellow kwsys_ns(Terminal_Color_ForegroundYellow)
36 #define kwsysTerminal_Color_ForegroundBlue kwsys_ns(Terminal_Color_ForegroundBlue)
37 #define kwsysTerminal_Color_ForegroundMagenta kwsys_ns(Terminal_Color_ForegroundMagenta)
38 #define kwsysTerminal_Color_ForegroundCyan kwsys_ns(Terminal_Color_ForegroundCyan)
39 #define kwsysTerminal_Color_ForegroundWhite kwsys_ns(Terminal_Color_ForegroundWhite)
40 #define kwsysTerminal_Color_ForegroundMask kwsys_ns(Terminal_Color_ForegroundMask)
41 #define kwsysTerminal_Color_BackgroundBlack kwsys_ns(Terminal_Color_BackgroundBlack)
42 #define kwsysTerminal_Color_BackgroundRed kwsys_ns(Terminal_Color_BackgroundRed)
43 #define kwsysTerminal_Color_BackgroundGreen kwsys_ns(Terminal_Color_BackgroundGreen)
44 #define kwsysTerminal_Color_BackgroundYellow kwsys_ns(Terminal_Color_BackgroundYellow)
45 #define kwsysTerminal_Color_BackgroundBlue kwsys_ns(Terminal_Color_BackgroundBlue)
46 #define kwsysTerminal_Color_BackgroundMagenta kwsys_ns(Terminal_Color_BackgroundMagenta)
47 #define kwsysTerminal_Color_BackgroundCyan kwsys_ns(Terminal_Color_BackgroundCyan)
48 #define kwsysTerminal_Color_BackgroundWhite kwsys_ns(Terminal_Color_BackgroundWhite)
49 #define kwsysTerminal_Color_BackgroundMask kwsys_ns(Terminal_Color_BackgroundMask)
50 #define kwsysTerminal_Color_ForegroundBold kwsys_ns(Terminal_Color_ForegroundBold)
51 #define kwsysTerminal_Color_BackgroundBold kwsys_ns(Terminal_Color_BackgroundBold)
52 #define kwsysTerminal_Color_AssumeTTY kwsys_ns(Terminal_Color_AssumeTTY)
53 #define kwsysTerminal_Color_AssumeVT100 kwsys_ns(Terminal_Color_AssumeVT100)
54 #define kwsysTerminal_Color_AttributeMask kwsys_ns(Terminal_Color_AttributeMask)
56 #if defined(__cplusplus)
62 * Write colored and formatted text to a stream. Color is used only
63 * for streams supporting it. The color specification is constructed
64 * by bitwise-OR-ing enumeration values. At most one foreground and
65 * one background value may be given.
67 * Whether the a stream supports color is usually automatically
68 * detected, but with two exceptions:
70 * - When the stream is displayed in a terminal supporting VT100
71 * color but using an intermediate pipe for communication the
72 * detection of a tty fails. (This typically occurs for a shell
73 * running in an rxvt terminal in MSYS.) If the caller knows this
74 * to be the case, the attribute Color_AssumeTTY may be included in
75 * the color specification.
77 * - When the stream is displayed in a terminal whose TERM
78 * environment variable is not set or is set to a value that is not
79 * known to support VT100 colors. If the caller knows this to be
80 * the case, the attribute Color_AssumeVT100 may be included in the
81 * color specification.
83 kwsysEXPORT
void kwsysTerminal_cfprintf(int color
, FILE* stream
,
84 const char* format
, ...);
85 enum kwsysTerminal_Color_e
88 kwsysTerminal_Color_Normal
= 0,
90 /* Foreground Color */
91 kwsysTerminal_Color_ForegroundBlack
= 0x1,
92 kwsysTerminal_Color_ForegroundRed
= 0x2,
93 kwsysTerminal_Color_ForegroundGreen
= 0x3,
94 kwsysTerminal_Color_ForegroundYellow
= 0x4,
95 kwsysTerminal_Color_ForegroundBlue
= 0x5,
96 kwsysTerminal_Color_ForegroundMagenta
= 0x6,
97 kwsysTerminal_Color_ForegroundCyan
= 0x7,
98 kwsysTerminal_Color_ForegroundWhite
= 0x8,
99 kwsysTerminal_Color_ForegroundMask
= 0xF,
101 /* Background Color */
102 kwsysTerminal_Color_BackgroundBlack
= 0x10,
103 kwsysTerminal_Color_BackgroundRed
= 0x20,
104 kwsysTerminal_Color_BackgroundGreen
= 0x30,
105 kwsysTerminal_Color_BackgroundYellow
= 0x40,
106 kwsysTerminal_Color_BackgroundBlue
= 0x50,
107 kwsysTerminal_Color_BackgroundMagenta
= 0x60,
108 kwsysTerminal_Color_BackgroundCyan
= 0x70,
109 kwsysTerminal_Color_BackgroundWhite
= 0x80,
110 kwsysTerminal_Color_BackgroundMask
= 0xF0,
113 kwsysTerminal_Color_ForegroundBold
= 0x100,
114 kwsysTerminal_Color_BackgroundBold
= 0x200,
115 kwsysTerminal_Color_AssumeTTY
= 0x400,
116 kwsysTerminal_Color_AssumeVT100
= 0x800,
117 kwsysTerminal_Color_AttributeMask
= 0xF00
120 #if defined(__cplusplus)
124 /* If we are building a kwsys .c or .cxx file, let it use these macros.
125 Otherwise, undefine them to keep the namespace clean. */
126 #if !defined(KWSYS_NAMESPACE)
129 # undef kwsysTerminal_cfprintf
130 # undef kwsysTerminal_Color_e
131 # undef kwsysTerminal_Color_Normal
132 # undef kwsysTerminal_Color_ForegroundBlack
133 # undef kwsysTerminal_Color_ForegroundRed
134 # undef kwsysTerminal_Color_ForegroundGreen
135 # undef kwsysTerminal_Color_ForegroundYellow
136 # undef kwsysTerminal_Color_ForegroundBlue
137 # undef kwsysTerminal_Color_ForegroundMagenta
138 # undef kwsysTerminal_Color_ForegroundCyan
139 # undef kwsysTerminal_Color_ForegroundWhite
140 # undef kwsysTerminal_Color_ForegroundMask
141 # undef kwsysTerminal_Color_BackgroundBlack
142 # undef kwsysTerminal_Color_BackgroundRed
143 # undef kwsysTerminal_Color_BackgroundGreen
144 # undef kwsysTerminal_Color_BackgroundYellow
145 # undef kwsysTerminal_Color_BackgroundBlue
146 # undef kwsysTerminal_Color_BackgroundMagenta
147 # undef kwsysTerminal_Color_BackgroundCyan
148 # undef kwsysTerminal_Color_BackgroundWhite
149 # undef kwsysTerminal_Color_BackgroundMask
150 # undef kwsysTerminal_Color_ForegroundBold
151 # undef kwsysTerminal_Color_BackgroundBold
152 # undef kwsysTerminal_Color_AssumeTTY
153 # undef kwsysTerminal_Color_AssumeVT100
154 # undef kwsysTerminal_Color_AttributeMask