xref: /haiku/headers/private/kernel/boot/platform/generic/text_console.h (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
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_ESCAPE			= 0x1b,
40 	TEXT_CONSOLE_KEY_SPACE			= ' ',
41 
42 	// cursor keys
43 	TEXT_CONSOLE_CURSOR_KEYS_START	= 0x40000000,
44 	TEXT_CONSOLE_KEY_UP				= TEXT_CONSOLE_CURSOR_KEYS_START,
45 	TEXT_CONSOLE_KEY_DOWN,
46 	TEXT_CONSOLE_KEY_LEFT,
47 	TEXT_CONSOLE_KEY_RIGHT,
48 	TEXT_CONSOLE_KEY_PAGE_UP,
49 	TEXT_CONSOLE_KEY_PAGE_DOWN,
50 	TEXT_CONSOLE_KEY_HOME,
51 	TEXT_CONSOLE_KEY_END,
52 	TEXT_CONSOLE_CURSOR_KEYS_END,
53 };
54 
55 #define TEXT_CONSOLE_IS_CURSOR_KEY(key) \
56 	(key >= TEXT_CONSOLE_CURSOR_KEYS_START \
57 	 && key < TEXT_CONSOLE_CURSOR_KEYS_END)
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 extern void console_clear_screen(void);
64 extern int32 console_width(void);
65 extern int32 console_height(void);
66 extern void console_set_cursor(int32 x, int32 y);
67 extern void console_set_color(int32 foreground, int32 background);
68 
69 extern int console_wait_for_key(void);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif	/* GENERIC_TEXT_CONSOLE_H */
76