1 /* 2 * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef GENERIC_TEXT_CONSOLE_H 6 #define GENERIC_TEXT_CONSOLE_H 7 8 9 #include <boot/vfs.h> 10 #include <boot/stdio.h> 11 12 // Standard 16 color palette. Common for BIOS and OpenFirmware. 13 enum console_color { 14 // foreground and background colors 15 BLACK, 16 BLUE, 17 GREEN, 18 CYAN, 19 RED, 20 PURPLE, 21 BROWN, 22 GRAY, 23 // foreground colors only if blinking is enabled (restriction applies 24 // to BIOS only) 25 DARK_GRAY, 26 BRIGHT_BLUE, 27 BRIGHT_GREEN, 28 BRIGHT_CYAN, 29 BRIGHT_RED, 30 MAGENTA, 31 YELLOW, 32 WHITE 33 }; 34 35 enum { 36 // ASCII 37 TEXT_CONSOLE_NO_KEY = '\0', 38 TEXT_CONSOLE_KEY_RETURN = '\r', 39 TEXT_CONSOLE_KEY_BACKSPACE = '\b', 40 TEXT_CONSOLE_KEY_ESCAPE = 0x1b, 41 TEXT_CONSOLE_KEY_SPACE = ' ', 42 43 // cursor keys 44 TEXT_CONSOLE_CURSOR_KEYS_START = 0x40000000, 45 TEXT_CONSOLE_KEY_UP = TEXT_CONSOLE_CURSOR_KEYS_START, 46 TEXT_CONSOLE_KEY_DOWN, 47 TEXT_CONSOLE_KEY_LEFT, 48 TEXT_CONSOLE_KEY_RIGHT, 49 TEXT_CONSOLE_KEY_PAGE_UP, 50 TEXT_CONSOLE_KEY_PAGE_DOWN, 51 TEXT_CONSOLE_KEY_HOME, 52 TEXT_CONSOLE_KEY_END, 53 TEXT_CONSOLE_CURSOR_KEYS_END, 54 }; 55 56 #define TEXT_CONSOLE_IS_CURSOR_KEY(key) \ 57 (key >= TEXT_CONSOLE_CURSOR_KEYS_START \ 58 && key < TEXT_CONSOLE_CURSOR_KEYS_END) 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif 63 64 extern void console_clear_screen(void); 65 extern int32 console_width(void); 66 extern int32 console_height(void); 67 extern void console_set_cursor(int32 x, int32 y); 68 extern void console_show_cursor(void); 69 extern void console_hide_cursor(void); 70 extern void console_set_color(int32 foreground, int32 background); 71 72 extern int console_wait_for_key(void); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* GENERIC_TEXT_CONSOLE_H */ 79