From: Joshua Wise Date: Wed, 10 Sep 2008 20:59:04 +0000 (-0400) Subject: add console.h X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/f16f4f1e99d1b45e7f0ba828616c1afdd1b50721 add console.h --- diff --git a/grubload/console.h b/grubload/console.h new file mode 100644 index 0000000..dd15d47 --- /dev/null +++ b/grubload/console.h @@ -0,0 +1,142 @@ +/** @file console.h + * @brief Function prototypes for the console driver. + * + * This contains the prototypes and global variables for the console + * driver + * + * @author Michael Berman (mberman) + * @bug No known bugs. + */ + +#ifndef _CONSOLE_H +#define _CONSOLE_H + +#include + +/** @brief Prints character ch at the current location + * of the cursor. + * + * If the character is a newline ('\n'), the cursor is + * be moved to the beginning of the next line (scrolling if necessary). If + * the character is a carriage return ('\r'), the cursor + * is immediately reset to the beginning of the current + * line, causing any future output to overwrite any existing + * output on the line. If backsapce ('\b') is encountered, + * the previous character is erased. See the main console.c description + * for more backspace behavior. + * + * @param ch the character to print + * @return The input character + */ +int putbyte( char ch ); + +/** @brief Prints the string s, starting at the current + * location of the cursor. + * + * If the string is longer than the current line, the + * string fills up the current line and then + * continues on the next line. If the string exceeds + * available space on the entire console, the screen + * scrolls up one line, and then the string + * continues on the new line. If '\n', '\r', and '\b' are + * encountered within the string, they are handled + * as per putbyte. If len is not a positive integer or s + * is null, the function has no effect. + * + * @param s The string to be printed. + * @param len The length of the string s. + * @return Void. + */ +void putbytes(const char* s, int len); + +/** @brief Changes the foreground and background color + * of future characters printed on the console. + * + * If the color code is invalid, the function has no effect. + * + * @param color The new color code. + * @return 0 on success or integer error code less than 0 if + * color code is invalid. + */ +int set_term_color(int color); + +/** @brief Writes the current foreground and background + * color of characters printed on the console + * into the argument color. + * @param color The address to which the current color + * information will be written. + * @return Void. + */ +void get_term_color(int* color); + +/** @brief Sets the position of the cursor to the + * position (row, col). + * + * Subsequent calls to putbytes should cause the console + * output to begin at the new position. If the cursor is + * currently hidden, a call to set_cursor() does not show + * the cursor. + * + * @param row The new row for the cursor. + * @param col The new column for the cursor. + * @return 0 on success or integer error code less than 0 if + * cursor location is invalid. + */ +int set_cursor(int row, int col); + +/** @brief Writes the current position of the cursor + * into the arguments row and col. + * @param row The address to which the current cursor + * row will be written. + * @param col The address to which the current cursor + * column will be written. + * @return Void. + */ +void get_cursor(int* row, int* col); + +/** @brief Hides the cursor. + * + * Subsequent calls to putbytes do not cause the + * cursor to show again. + * + * @return Void. + */ +void hide_cursor(); + +/** @brief Shows the cursor. + * + * If the cursor is already shown, the function has no effect. + * + * @return Void. + */ +void show_cursor(); + +/** @brief Clears the entire console. + * + * The cursor is reset to the first row and column + * + * @return Void. + */ +void clear_console(); + +/** @brief Prints character ch with the specified color + * at position (row, col). + * + * If any argument is invalid, the function has no effect. + * + * @param row The row in which to display the character. + * @param col The column in which to display the character. + * @param ch The character to display. + * @param color The color to use to display the character. + * @return Void. + */ +void draw_char(int row, int col, int ch, int color); + +/** @brief Returns the character displayed at position (row, col). + * @param row Row of the character. + * @param col Column of the character. + * @return The character at (row, col). + */ +char get_char(int row, int col); + +#endif /* _CONSOLE_H */