summaryrefslogtreecommitdiff
path: root/kern/inc/console.h
diff options
context:
space:
mode:
Diffstat (limited to 'kern/inc/console.h')
-rw-r--r--kern/inc/console.h94
1 files changed, 40 insertions, 54 deletions
diff --git a/kern/inc/console.h b/kern/inc/console.h
index a3649de..0d65922 100644
--- a/kern/inc/console.h
+++ b/kern/inc/console.h
@@ -26,12 +26,43 @@
#ifndef _CONSOLE_H
#define _CONSOLE_H
-#include <video_defines.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <x86/asm.h>
+#include <x86/video_defines.h>
+
+#include <common.h>
#include <sync.h>
-/** mutex for console operations */
-extern mutex_t console_lock;
+/**
+ * Someone is not satisfied with the type name char_t so we use this
+ * to reperesent a char on screen so that nobody will mistake it with 'char'
+ */
+typedef struct a_char_on_screen_s {
+ uint8_t ch; /** char */
+ uint8_t color; /** color */
+} a_char_on_screen_t;
+
+typedef struct pts_s {
+ queue_t pts_link;
+ int refcount;
+ mutex_t lock;
+ a_char_on_screen_t mem[CONSOLE_HEIGHT][CONSOLE_WIDTH];
+ int cur_x;
+ int cur_y;
+ char cur_color;
+ int cur_shown;
+} pts_t;
+
+extern pts_t* active_pts;
+extern spl_t pts_lock;
+
+void pts_init(pts_t* pts);
+
+int putbyte(char ch);
/** @brief Prints character ch at the current location
* of the cursor.
@@ -48,7 +79,7 @@ extern mutex_t console_lock;
* @param ch the character to print
* @return The input character
*/
-int putbyte(char ch);
+int pts_putbyte(pts_t* pts, char ch);
/** @brief Prints the string s, starting at the current
* location of the cursor.
@@ -67,7 +98,7 @@ int putbyte(char ch);
* @param len The length of the string s.
* @return Void.
*/
-void putbytes(const char* s, int len);
+void pts_putbytes(pts_t* pts, const char* s, int len);
/** @brief Changes the foreground and background color
* of future characters printed on the console.
@@ -78,7 +109,7 @@ void putbytes(const char* s, int len);
* @return 0 on success or integer error code less than 0 if
* color code is invalid.
*/
-int set_term_color(int color);
+int pts_set_term_color(pts_t* pts, int color);
/** @brief Writes the current foreground and background
* color of characters printed on the console
@@ -87,7 +118,7 @@ int set_term_color(int color);
* information will be written.
* @return Void.
*/
-void get_term_color(int* color);
+void pts_get_term_color(pts_t* pts, int* color);
/** @brief Sets the position of the cursor to the
* position (row, col).
@@ -102,7 +133,7 @@ void get_term_color(int* color);
* @return 0 on success or integer error code less than 0 if
* cursor location is invalid.
*/
-int set_cursor(int row, int col);
+int pts_set_cursor(pts_t* pts, int row, int col);
/** @brief Writes the current position of the cursor
* into the arguments row and col.
@@ -112,51 +143,6 @@ int set_cursor(int row, int col);
* 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(void);
-
-/** @brief Shows the cursor.
- *
- * If the cursor is already shown, the function has no effect.
- *
- * @return Void.
- */
-void show_cursor(void);
-
-/** @brief Clears the entire console.
- *
- * The cursor is reset to the first row and column
- *
- * @return Void.
- */
-void clear_console(void);
-
-/** @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);
+void pts_get_cursor(pts_t* pts, int* row, int* col);
#endif /* _CONSOLE_H */