1 /* 2 * 3 * This program is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU General Public License as 5 * published by the Free Software Foundation; either version 2 of the 6 * License, or (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, but 9 * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied 10 * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and 11 * NON-INFRINGEMENT. See the GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 16 * MA 02110-1301, USA. 17 * 18 * In addition, as a special exception, the copyright holders give 19 * permission to link the code of portions of this program with the 20 * OpenSSL library under certain conditions as described in each 21 * individual source file, and distribute linked combinations 22 * including the two. 23 * You must obey the GNU General Public License in all respects 24 * for all of the code used other than OpenSSL. If you modify 25 * file(s) with this exception, you may extend this exception to your 26 * version of the file(s), but you are not obligated to do so. If you 27 * do not wish to do so, delete this exception statement from your 28 * version. If you delete this exception statement from all source 29 * files in the program, then also delete it here. 30 */ 31 32 #ifndef AIRCRACK_NG_CONSOLE_H 33 #define AIRCRACK_NG_CONSOLE_H 34 35 /** 36 * Styling attributes for \a textstyle function. 37 */ 38 #define TEXT_RESET 0 39 #define TEXT_BRIGHT 1 40 #define TEXT_DIM 2 41 #define TEXT_UNDERLINE 3 42 #define TEXT_BLINK 4 43 #define TEXT_REVERSE 7 44 #define TEXT_HIDDEN 8 45 #define TEXT_MAX_STYLE 8 46 47 /** 48 * Color definitions for \a textcolor functions. 49 */ 50 #define TEXT_BLACK 0 51 #define TEXT_RED 1 52 #define TEXT_GREEN 2 53 #define TEXT_YELLOW 3 54 #define TEXT_BLUE 4 55 #define TEXT_MAGENTA 5 56 #define TEXT_CYAN 6 57 #define TEXT_WHITE 7 58 #define TEXT_MAX_COLOR 7 59 60 /** 61 * Movement direction definitions for \a move function. 62 */ 63 #define CURSOR_UP 0 64 #define CURSOR_DOWN 1 65 #define CURSOR_FORWARD 2 66 #define CURSOR_BACK 3 67 68 /** 69 * Character codes for common keyboard keys. 70 */ 71 #define KEY_TAB 0x09 72 #define KEY_SPACE 0x20 73 #define KEY_ARROW_UP 0x41 74 #define KEY_ARROW_DOWN 0x42 75 #define KEY_ARROW_RIGHT 0x43 76 #define KEY_ARROW_LEFT 0x44 77 #define KEY_a 0x61 78 #define KEY_c 0x63 79 #define KEY_d 0x64 80 #define KEY_i 0x69 81 #define KEY_m 0x6D 82 #define KEY_n 0x6E 83 #define KEY_r 0x72 84 #define KEY_s 0x73 85 86 /// Changes the styling, foreground, and background 87 /// character color, as shown in the user's terminal 88 /// console. 89 void textcolor(int attr, int fg, int bg); 90 91 /// Changes the foreground character color, as shown in the 92 /// user's terminal console. 93 void textcolor_fg(int fg); 94 95 /// Changes the background character color, as shown in the 96 /// user's terminal console. 97 void textcolor_bg(int bg); 98 99 /// Switch to normal color or intensity, as shown in the 100 /// user's terminal console. 101 void textcolor_normal(void); 102 103 /// Switches the styling applied to future written characters to 104 /// the user's terminal console. 105 void textstyle(int attr); 106 107 /// Moves the cursor to specified column and row, 1-based. 108 void moveto(int x, int y); 109 110 /// Move the cursor a specified number of positions, in the specified 111 /// direction. 112 void move(int which, int n); 113 114 /// \brief Erase a subset of the terminal console. 115 /** 116 * From Wikipedia: 117 * 118 * Clears part of the screen. If n {\displaystyle n} n is 0 (or missing), 119 * clear from cursor to end of screen. If n {\displaystyle n} n is 1, 120 * clear from cursor to beginning of the screen. If n {\displaystyle n} n 121 * is 2, clear entire screen (and moves cursor to upper left on DOS 122 * ANSI.SYS). If n {\displaystyle n} n is 3, clear entire screen and 123 * delete all lines saved in the scrollback buffer (this feature was 124 * added for xterm and is supported by other terminal applications). 125 */ 126 void erase_display(int n); 127 128 /// \brief Erase part of the line; of the user's terminal console. 129 void erase_line(int n); 130 131 /// Hide the cursor within the terminal console. 132 void hide_cursor(void); 133 134 /// Show the cursor within the terminal console. 135 void show_cursor(void); 136 137 /// Reset the terminal console display back to a known working state. 138 void reset_term(void); 139 140 /// Wrapper around \a getch to avoid displaying the character on the terminal 141 /// console. 142 int mygetch(void); 143 144 #endif // AIRCRACK_NG_CONSOLE_H 145