Terminal.h.in 7.1 KB

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