Austin Schuh | 41baf20 | 2022-01-01 14:33:40 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * The MIT License (MIT) |
| 3 | * |
| 4 | * Copyright (c) 2019 Ha Thach (tinyusb.org) |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | * |
| 24 | * This file is part of the TinyUSB stack. |
| 25 | */ |
| 26 | |
| 27 | /** \ingroup group_board |
| 28 | * \defgroup group_ansi_esc ANSI Esacpe Code |
| 29 | * @{ */ |
| 30 | |
| 31 | #ifndef _TUSB_ANSI_ESC_CODE_H_ |
| 32 | #define _TUSB_ANSI_ESC_CODE_H_ |
| 33 | |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | #define CSI_CODE(seq) "\33[" seq |
| 40 | #define CSI_SGR(x) CSI_CODE(#x) "m" |
| 41 | |
| 42 | //------------- Cursor movement -------------// |
| 43 | /** \defgroup group_ansi_cursor Cursor Movement |
| 44 | * @{ */ |
| 45 | #define ANSI_CURSOR_UP(n) CSI_CODE(#n "A") ///< Move cursor up |
| 46 | #define ANSI_CURSOR_DOWN(n) CSI_CODE(#n "B") ///< Move cursor down |
| 47 | #define ANSI_CURSOR_FORWARD(n) CSI_CODE(#n "C") ///< Move cursor forward |
| 48 | #define ANSI_CURSOR_BACKWARD(n) CSI_CODE(#n "D") ///< Move cursor backward |
| 49 | #define ANSI_CURSOR_LINE_DOWN(n) CSI_CODE(#n "E") ///< Move cursor to the beginning of the line (n) down |
| 50 | #define ANSI_CURSOR_LINE_UP(n) CSI_CODE(#n "F") ///< Move cursor to the beginning of the line (n) up |
| 51 | #define ANSI_CURSOR_POSITION(n, m) CSI_CODE(#n ";" #m "H") ///< Move cursor to position (n, m) |
| 52 | /** @} */ |
| 53 | |
| 54 | //------------- Screen -------------// |
| 55 | /** \defgroup group_ansi_screen Screen Control |
| 56 | * @{ */ |
| 57 | #define ANSI_ERASE_SCREEN(n) CSI_CODE(#n "J") ///< Erase the screen |
| 58 | #define ANSI_ERASE_LINE(n) CSI_CODE(#n "K") ///< Erase the line (n) |
| 59 | #define ANSI_SCROLL_UP(n) CSI_CODE(#n "S") ///< Scroll the whole page up (n) lines |
| 60 | #define ANSI_SCROLL_DOWN(n) CSI_CODE(#n "T") ///< Scroll the whole page down (n) lines |
| 61 | /** @} */ |
| 62 | |
| 63 | //------------- Text Color -------------// |
| 64 | /** \defgroup group_ansi_text Text Color |
| 65 | * @{ */ |
| 66 | #define ANSI_TEXT_BLACK CSI_SGR(30) |
| 67 | #define ANSI_TEXT_RED CSI_SGR(31) |
| 68 | #define ANSI_TEXT_GREEN CSI_SGR(32) |
| 69 | #define ANSI_TEXT_YELLOW CSI_SGR(33) |
| 70 | #define ANSI_TEXT_BLUE CSI_SGR(34) |
| 71 | #define ANSI_TEXT_MAGENTA CSI_SGR(35) |
| 72 | #define ANSI_TEXT_CYAN CSI_SGR(36) |
| 73 | #define ANSI_TEXT_WHITE CSI_SGR(37) |
| 74 | #define ANSI_TEXT_DEFAULT CSI_SGR(39) |
| 75 | /** @} */ |
| 76 | |
| 77 | //------------- Background Color -------------// |
| 78 | /** \defgroup group_ansi_background Background Color |
| 79 | * @{ */ |
| 80 | #define ANSI_BG_BLACK CSI_SGR(40) |
| 81 | #define ANSI_BG_RED CSI_SGR(41) |
| 82 | #define ANSI_BG_GREEN CSI_SGR(42) |
| 83 | #define ANSI_BG_YELLOW CSI_SGR(43) |
| 84 | #define ANSI_BG_BLUE CSI_SGR(44) |
| 85 | #define ANSI_BG_MAGENTA CSI_SGR(45) |
| 86 | #define ANSI_BG_CYAN CSI_SGR(46) |
| 87 | #define ANSI_BG_WHITE CSI_SGR(47) |
| 88 | #define ANSI_BG_DEFAULT CSI_SGR(49) |
| 89 | /** @} */ |
| 90 | |
| 91 | #ifdef __cplusplus |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | #endif /* _TUSB_ANSI_ESC_CODE_H_ */ |
| 96 | |
| 97 | /** @} */ |