Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TerminalCodes.h 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief ANSI terminal special escape code macros.
  28. *
  29. * ANSI terminal compatible escape sequences. These escape sequences are designed to be concatenated with existing
  30. * strings to modify their display on a compatible terminal application.
  31. */
  32. /** \ingroup Group_MiscDrivers
  33. * \defgroup Group_Terminal ANSI Terminal Escape Codes - LUFA/Drivers/Misc/TerminalCodes.h
  34. * \brief ANSI terminal special escape code macros.
  35. *
  36. * \section Sec_Terminal_Dependencies Module Source Dependencies
  37. * The following files must be built with any user project that uses this module:
  38. * - None
  39. *
  40. * \section Sec_Terminal_ModDescription Module Description
  41. * Escape code macros for ANSI compliant text terminals.
  42. *
  43. * \note If desired, the macro \c DISABLE_TERMINAL_CODES can be defined in the project makefile and passed to the GCC
  44. * compiler via the -D switch to disable the terminal codes without modifying the source, for use with non
  45. * compatible terminals (any terminal codes then equate to empty strings).
  46. *
  47. * \section Sec_Terminal_ExampleUsage Example Usage
  48. * The following snippet is an example of how this module may be used within a typical
  49. * application.
  50. *
  51. * \code
  52. * printf("Normal String, "
  53. * ESC_BOLD_ON "Bold String, "
  54. * ESC_UNDERLINE_ON "Bold and Underlined String"
  55. * ESC_RESET ESC_FG_BLUE ESC_BG_YELLOW "Normal Blue-on-Yellow String");
  56. * \endcode
  57. *
  58. * @{
  59. */
  60. #ifndef __TERMINALCODES_H__
  61. #define __TERMINALCODES_H__
  62. /* Public Interface - May be used in end-application: */
  63. /* Macros: */
  64. #if !defined(DISABLE_TERMINAL_CODES)
  65. /** Creates an ANSI escape sequence with the specified payload.
  66. *
  67. * \param[in] EscapeSeq Payload to encode as an ANSI escape sequence, a \c ESC_* mask.
  68. */
  69. #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) "\33[" EscapeSeq
  70. #else
  71. #define ANSI_ESCAPE_SEQUENCE(EscapeSeq)
  72. #endif
  73. /** \name Text Display Modifier Control Sequences */
  74. //@{
  75. /** Turns on bold so that any following text is printed to the terminal in bold. */
  76. #define ESC_BOLD_ON ANSI_ESCAPE_SEQUENCE("1m")
  77. /** Turns on italics so that any following text is printed to the terminal in italics. */
  78. #define ESC_ITALICS_ON ANSI_ESCAPE_SEQUENCE("3m")
  79. /** Turns on underline so that any following text is printed to the terminal underlined. */
  80. #define ESC_UNDERLINE_ON ANSI_ESCAPE_SEQUENCE("4m")
  81. /** Turns on inverse so that any following text is printed to the terminal in inverted colours. */
  82. #define ESC_INVERSE_ON ANSI_ESCAPE_SEQUENCE("7m")
  83. /** Turns on strike-through so that any following text is printed to the terminal with a line through the
  84. * center.
  85. */
  86. #define ESC_STRIKETHROUGH_ON ANSI_ESCAPE_SEQUENCE("9m")
  87. /** Turns off bold so that any following text is printed to the terminal in non bold. */
  88. #define ESC_BOLD_OFF ANSI_ESCAPE_SEQUENCE("22m")
  89. /** Turns off italics so that any following text is printed to the terminal in non italics. */
  90. #define ESC_ITALICS_OFF ANSI_ESCAPE_SEQUENCE("23m")
  91. /** Turns off underline so that any following text is printed to the terminal non underlined. */
  92. #define ESC_UNDERLINE_OFF ANSI_ESCAPE_SEQUENCE("24m")
  93. /** Turns off inverse so that any following text is printed to the terminal in non inverted colours. */
  94. #define ESC_INVERSE_OFF ANSI_ESCAPE_SEQUENCE("27m")
  95. /** Turns off strike-through so that any following text is printed to the terminal without a line through
  96. * the center.
  97. */
  98. #define ESC_STRIKETHROUGH_OFF ANSI_ESCAPE_SEQUENCE("29m")
  99. //@}
  100. /** \name Text Colour Control Sequences */
  101. //@{
  102. /** Sets the foreground (text) colour to black. */
  103. #define ESC_FG_BLACK ANSI_ESCAPE_SEQUENCE("30m")
  104. /** Sets the foreground (text) colour to red. */
  105. #define ESC_FG_RED ANSI_ESCAPE_SEQUENCE("31m")
  106. /** Sets the foreground (text) colour to green. */
  107. #define ESC_FG_GREEN ANSI_ESCAPE_SEQUENCE("32m")
  108. /** Sets the foreground (text) colour to yellow. */
  109. #define ESC_FG_YELLOW ANSI_ESCAPE_SEQUENCE("33m")
  110. /** Sets the foreground (text) colour to blue. */
  111. #define ESC_FG_BLUE ANSI_ESCAPE_SEQUENCE("34m")
  112. /** Sets the foreground (text) colour to magenta. */
  113. #define ESC_FG_MAGENTA ANSI_ESCAPE_SEQUENCE("35m")
  114. /** Sets the foreground (text) colour to cyan. */
  115. #define ESC_FG_CYAN ANSI_ESCAPE_SEQUENCE("36m")
  116. /** Sets the foreground (text) colour to white. */
  117. #define ESC_FG_WHITE ANSI_ESCAPE_SEQUENCE("37m")
  118. /** Sets the foreground (text) colour to the terminal's default. */
  119. #define ESC_FG_DEFAULT ANSI_ESCAPE_SEQUENCE("39m")
  120. /** Sets the text background colour to black. */
  121. #define ESC_BG_BLACK ANSI_ESCAPE_SEQUENCE("40m")
  122. /** Sets the text background colour to red. */
  123. #define ESC_BG_RED ANSI_ESCAPE_SEQUENCE("41m")
  124. /** Sets the text background colour to green. */
  125. #define ESC_BG_GREEN ANSI_ESCAPE_SEQUENCE("42m")
  126. /** Sets the text background colour to yellow. */
  127. #define ESC_BG_YELLOW ANSI_ESCAPE_SEQUENCE("43m")
  128. /** Sets the text background colour to blue. */
  129. #define ESC_BG_BLUE ANSI_ESCAPE_SEQUENCE("44m")
  130. /** Sets the text background colour to magenta. */
  131. #define ESC_BG_MAGENTA ANSI_ESCAPE_SEQUENCE("45m")
  132. /** Sets the text background colour to cyan. */
  133. #define ESC_BG_CYAN ANSI_ESCAPE_SEQUENCE("46m")
  134. /** Sets the text background colour to white. */
  135. #define ESC_BG_WHITE ANSI_ESCAPE_SEQUENCE("47m")
  136. /** Sets the text background colour to the terminal's default. */
  137. #define ESC_BG_DEFAULT ANSI_ESCAPE_SEQUENCE("49m")
  138. //@}
  139. /** \name Cursor Positioning Control Sequences */
  140. //@{
  141. /** Saves the current cursor position so that it may be restored with \ref ESC_CURSOR_POS_RESTORE. */
  142. #define ESC_CURSOR_POS_SAVE ANSI_ESCAPE_SEQUENCE("s")
  143. /** Restores the cursor position to the last position saved with \ref ESC_CURSOR_POS_SAVE. */
  144. #define ESC_CURSOR_POS_RESTORE ANSI_ESCAPE_SEQUENCE("u")
  145. /** Sets the cursor position to the given line and column.
  146. *
  147. * \param[in] Line Line number to position the cursor at.
  148. * \param[in] Column Column number to position the cursor at.
  149. */
  150. #define ESC_CURSOR_POS(Line, Column) ANSI_ESCAPE_SEQUENCE(#Line ";" #Column "H")
  151. /** Moves the cursor up the given number of lines.
  152. *
  153. * \param[in] Lines Number of lines to move the cursor position
  154. */
  155. #define ESC_CURSOR_UP(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "A")
  156. /** Moves the cursor down the given number of lines.
  157. *
  158. * \param[in] Lines Number of lines to move the cursor position
  159. */
  160. #define ESC_CURSOR_DOWN(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "B")
  161. /** Moves the cursor to the right the given number of columns.
  162. *
  163. * \param[in] Columns Number of columns to move the cursor position
  164. */
  165. #define ESC_CURSOR_FORWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "C")
  166. /** Moves the cursor to the left the given number of columns.
  167. *
  168. * \param[in] Columns Number of columns to move the cursor position
  169. */
  170. #define ESC_CURSOR_BACKWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "D")
  171. //@}
  172. /** \name Miscellaneous Control Sequences */
  173. //@{
  174. /** Resets any escape sequence modifiers back to their defaults. */
  175. #define ESC_RESET ANSI_ESCAPE_SEQUENCE("0m")
  176. /** Erases the entire display, returning the cursor to the top left. */
  177. #define ESC_ERASE_DISPLAY ANSI_ESCAPE_SEQUENCE("2J")
  178. /** Erases the current line, returning the cursor to the far left. */
  179. #define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K")
  180. //@}
  181. #endif
  182. /** @} */