Terminal.h.in 7.0 KB

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