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