2
* GRUB -- GRand Unified Bootloader
3
* Copyright (C) 2002,2003,2005 Free Software Foundation, Inc.
5
* GRUB is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with GRUB; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
#ifndef GRUB_TERM_HEADER
21
#define GRUB_TERM_HEADER 1
24
#include <grub/symbol.h>
25
#include <grub/types.h>
27
/* These are used to represent the various color states we use. */
30
/* The color used to display all text that does not use the
31
user defined colors below. */
32
GRUB_TERM_COLOR_STANDARD,
33
/* The user defined colors for normal text. */
34
GRUB_TERM_COLOR_NORMAL,
35
/* The user defined colors for highlighted text. */
36
GRUB_TERM_COLOR_HIGHLIGHT
38
grub_term_color_state;
40
/* Flags for representing the capabilities of a terminal. */
41
/* Some notes about the flags:
42
- These flags are used by higher-level functions but not terminals
44
- If a terminal is dumb, you may assume that only putchar, getkey and
46
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
49
/* Set when input characters shouldn't be echoed back. */
50
#define GRUB_TERM_NO_ECHO (1 << 0)
51
/* Set when the editing feature should be disabled. */
52
#define GRUB_TERM_NO_EDIT (1 << 1)
53
/* Set when the terminal cannot do fancy things. */
54
#define GRUB_TERM_DUMB (1 << 2)
55
/* Set when the terminal needs to be initialized. */
56
#define GRUB_TERM_NEED_INIT (1 << 16)
59
/* Unicode characters for fancy graphics. */
60
#define GRUB_TERM_DISP_LEFT 0x2190
61
#define GRUB_TERM_DISP_UP 0x2191
62
#define GRUB_TERM_DISP_RIGHT 0x2192
63
#define GRUB_TERM_DISP_DOWN 0x2193
64
#define GRUB_TERM_DISP_HLINE 0x2501
65
#define GRUB_TERM_DISP_VLINE 0x2503
66
#define GRUB_TERM_DISP_UL 0x250F
67
#define GRUB_TERM_DISP_UR 0x2513
68
#define GRUB_TERM_DISP_LL 0x2517
69
#define GRUB_TERM_DISP_LR 0x251B
72
/* Menu-related geometrical constants. */
74
/* FIXME: Ugly way to get them form terminal. */
75
#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8)
76
#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF)
78
/* The number of lines of "GRUB version..." at the top. */
79
#define GRUB_TERM_INFO_HEIGHT 1
81
/* The number of columns/lines between messages/borders/etc. */
82
#define GRUB_TERM_MARGIN 1
84
/* The number of columns of scroll information. */
85
#define GRUB_TERM_SCROLL_WIDTH 1
87
/* The Y position of the top border. */
88
#define GRUB_TERM_TOP_BORDER_Y (GRUB_TERM_MARGIN + GRUB_TERM_INFO_HEIGHT \
91
/* The X position of the left border. */
92
#define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN
94
/* The width of the border. */
95
#define GRUB_TERM_BORDER_WIDTH (GRUB_TERM_WIDTH \
96
- GRUB_TERM_MARGIN * 3 \
97
- GRUB_TERM_SCROLL_WIDTH)
99
/* The number of lines of messages at the bottom. */
100
#define GRUB_TERM_MESSAGE_HEIGHT 8
102
/* The height of the border. */
103
#define GRUB_TERM_BORDER_HEIGHT (GRUB_TERM_HEIGHT \
104
- GRUB_TERM_TOP_BORDER_Y \
105
- GRUB_TERM_MESSAGE_HEIGHT)
107
/* The number of entries shown at a time. */
108
#define GRUB_TERM_NUM_ENTRIES (GRUB_TERM_BORDER_HEIGHT - 2)
110
/* The Y position of the first entry. */
111
#define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1)
113
/* The max column number of an entry. The last "-1" is for a
114
continuation marker. */
115
#define GRUB_TERM_ENTRY_WIDTH (GRUB_TERM_BORDER_WIDTH - 2 \
116
- GRUB_TERM_MARGIN * 2 - 1)
118
/* The standard X position of the cursor. */
119
#define GRUB_TERM_CURSOR_X (GRUB_TERM_LEFT_BORDER_X \
120
+ GRUB_TERM_BORDER_WIDTH \
127
/* The terminal name. */
130
/* Initialize the terminal. */
131
grub_err_t (*init) (void);
133
/* Clean up the terminal. */
134
grub_err_t (*fini) (void);
136
/* Put a character. C is encoded in Unicode. */
137
void (*putchar) (grub_uint32_t c);
139
/* Get the number of columns occupied by a given character C. C is
140
encoded in Unicode. */
141
grub_ssize_t (*getcharwidth) (grub_uint32_t c);
143
/* Check if any input character is available. */
144
int (*checkkey) (void);
146
/* Get a character. */
147
int (*getkey) (void);
149
/* Get the screen size. The return value is ((Width << 8) | Height). */
150
grub_uint16_t (*getwh) (void);
152
/* Get the cursor position. The return value is ((X << 8) | Y). */
153
grub_uint16_t (*getxy) (void);
155
/* Go to the position (X, Y). */
156
void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
158
/* Clear the screen. */
161
/* Set the current color to be used */
162
void (*setcolorstate) (grub_term_color_state state);
164
/* Set the normal color and the highlight color. The format of each
166
void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
168
/* Turn on/off the cursor. */
169
void (*setcursor) (int on);
171
/* Update the screen. */
172
void (*refresh) (void);
174
/* The feature flags defined above. */
177
/* The next terminal. */
178
struct grub_term *next;
180
typedef struct grub_term *grub_term_t;
182
void EXPORT_FUNC(grub_term_register) (grub_term_t term);
183
void EXPORT_FUNC(grub_term_unregister) (grub_term_t term);
184
void EXPORT_FUNC(grub_term_iterate) (int (*hook) (grub_term_t term));
186
grub_err_t EXPORT_FUNC(grub_term_set_current) (grub_term_t term);
187
grub_term_t EXPORT_FUNC(grub_term_get_current) (void);
189
void EXPORT_FUNC(grub_putchar) (int c);
190
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
191
grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code);
192
int EXPORT_FUNC(grub_getkey) (void);
193
int EXPORT_FUNC(grub_checkkey) (void);
194
grub_uint16_t EXPORT_FUNC(grub_getwh) (void);
195
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
196
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
197
void EXPORT_FUNC(grub_cls) (void);
198
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
199
void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
200
grub_uint8_t highlight_color);
201
int EXPORT_FUNC(grub_setcursor) (int on);
202
int EXPORT_FUNC(grub_getcursor) (void);
203
void EXPORT_FUNC(grub_refresh) (void);
204
void EXPORT_FUNC(grub_set_more) (int onoff);
206
/* For convenience. */
207
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
209
#endif /* ! GRUB_TERM_HEADER */