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.
13enum 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 (on bios_ia32)
24	DARK_GRAY,
25	BRIGHT_BLUE,
26	BRIGHT_GREEN,
27	BRIGHT_CYAN,
28	BRIGHT_RED,
29	MAGENTA,
30	YELLOW,
31	WHITE
32};
33
34enum {
35	// ASCII
36	TEXT_CONSOLE_NO_KEY				= '\0',
37	TEXT_CONSOLE_KEY_RETURN			= '\r',
38	TEXT_CONSOLE_KEY_BACKSPACE		= '\b',
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
60extern "C" {
61#endif
62
63extern void console_clear_screen(void);
64extern int32 console_width(void);
65extern int32 console_height(void);
66extern void console_set_cursor(int32 x, int32 y);
67extern void console_show_cursor(void);
68extern void console_hide_cursor(void);
69extern void console_set_color(int32 foreground, int32 background);
70
71extern int console_wait_for_key(void);
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif	/* GENERIC_TEXT_CONSOLE_H */
78