summaryrefslogtreecommitdiff
path: root/410guests/tick_tock/kern/inc/console.h
diff options
context:
space:
mode:
authorHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
committerHanjie Wu <hanjiew@andrew.cmu.edu>2023-04-18 02:21:10 -0400
commitc71294cdd3581c3738d24ffd65414f8644a1094d (patch)
treec86245d50fad9eee4163dbba169bd1839edbf88f /410guests/tick_tock/kern/inc/console.h
initial commit
Diffstat (limited to '410guests/tick_tock/kern/inc/console.h')
-rw-r--r--410guests/tick_tock/kern/inc/console.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/410guests/tick_tock/kern/inc/console.h b/410guests/tick_tock/kern/inc/console.h
new file mode 100644
index 0000000..e763057
--- /dev/null
+++ b/410guests/tick_tock/kern/inc/console.h
@@ -0,0 +1,159 @@
+/*
+ *
+ * # #
+ * ## # #### ##### # #### ######
+ * # # # # # # # # # #
+ * # # # # # # # # #####
+ * # # # # # # # # #
+ * # ## # # # # # # #
+ * # # #### # # #### ######
+ *
+ * Now that it's P3 instead of P1 you are allowed
+ * to edit this file if it suits you.
+ *
+ * Please delete this notice.
+ *
+ */
+
+/** @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 <video_defines.h>
+
+/** @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 */