2 * @brief Function prototypes for the console driver.
4 * This contains the prototypes and global variables for the console
7 * @author Michael Berman (mberman)
14 #include <video_defines.h>
16 /** @brief Prints character ch at the current location
19 * If the character is a newline ('\n'), the cursor is
20 * be moved to the beginning of the next line (scrolling if necessary). If
21 * the character is a carriage return ('\r'), the cursor
22 * is immediately reset to the beginning of the current
23 * line, causing any future output to overwrite any existing
24 * output on the line. If backsapce ('\b') is encountered,
25 * the previous character is erased. See the main console.c description
26 * for more backspace behavior.
28 * @param ch the character to print
29 * @return The input character
31 int putbyte( char ch );
33 /** @brief Prints the string s, starting at the current
34 * location of the cursor.
36 * If the string is longer than the current line, the
37 * string fills up the current line and then
38 * continues on the next line. If the string exceeds
39 * available space on the entire console, the screen
40 * scrolls up one line, and then the string
41 * continues on the new line. If '\n', '\r', and '\b' are
42 * encountered within the string, they are handled
43 * as per putbyte. If len is not a positive integer or s
44 * is null, the function has no effect.
46 * @param s The string to be printed.
47 * @param len The length of the string s.
50 void putbytes(const char* s, int len);
52 /** @brief Changes the foreground and background color
53 * of future characters printed on the console.
55 * If the color code is invalid, the function has no effect.
57 * @param color The new color code.
58 * @return 0 on success or integer error code less than 0 if
59 * color code is invalid.
61 int set_term_color(int color);
63 /** @brief Writes the current foreground and background
64 * color of characters printed on the console
65 * into the argument color.
66 * @param color The address to which the current color
67 * information will be written.
70 void get_term_color(int* color);
72 /** @brief Sets the position of the cursor to the
73 * position (row, col).
75 * Subsequent calls to putbytes should cause the console
76 * output to begin at the new position. If the cursor is
77 * currently hidden, a call to set_cursor() does not show
80 * @param row The new row for the cursor.
81 * @param col The new column for the cursor.
82 * @return 0 on success or integer error code less than 0 if
83 * cursor location is invalid.
85 int set_cursor(int row, int col);
87 /** @brief Writes the current position of the cursor
88 * into the arguments row and col.
89 * @param row The address to which the current cursor
90 * row will be written.
91 * @param col The address to which the current cursor
92 * column will be written.
95 void get_cursor(int* row, int* col);
97 /** @brief Hides the cursor.
99 * Subsequent calls to putbytes do not cause the
100 * cursor to show again.
106 /** @brief Shows the cursor.
108 * If the cursor is already shown, the function has no effect.
114 /** @brief Clears the entire console.
116 * The cursor is reset to the first row and column
120 void clear_console();
122 /** @brief Prints character ch with the specified color
123 * at position (row, col).
125 * If any argument is invalid, the function has no effect.
127 * @param row The row in which to display the character.
128 * @param col The column in which to display the character.
129 * @param ch The character to display.
130 * @param color The color to use to display the character.
133 void draw_char(int row, int col, int ch, int color);
135 /** @brief Returns the character displayed at position (row, col).
136 * @param row Row of the character.
137 * @param col Column of the character.
138 * @return The character at (row, col).
140 char get_char(int row, int col);
142 #endif /* _CONSOLE_H */