Files
grub/stage2/term.h
T
okuji c18257ea65 2002-12-03 Yoshinori K. Okuji <okuji@enbug.org>
Change the terminal structure a bit, to turn the cursor state
	explicitly. Suggested by Pavel Roskin.

	* stage2/term.h (struct term_entry): Remove the member
	`nocursor' and add `setcursor'.
	[!STAGE1_5] (console_setcursor): New prototype.
	[SUPPORT_HERCULES] (hercules_setcursor): Likewise.
	[!STAGE1_5] (console_nocursor): Removed.
	[SUPPORT_HERCULES] (hercules_nocursor): Likewise.

	* stage2/stage2.c (run_menu): Call setcursor instead of
	nocursor.
	Call setcursor with 1 before starting a boot entry.

	* stage2/shared.h (nocursor): Removed.
	(setcursor): New prototype.

	* stage2/hercules.c (herc_cursor_state): New variable.
	(herc_turn_cursor): Removed.
	(hercules_nocursor): Likewise.
	(hercules_setcursor): New function.

	* stage2/char_io.c (get_cmdline): Turn on the cursor at the
	beginning, and restore it before returning.
	(nocursor): Removed.
	(setcursor): New function.

	* stage2/asm.S (console_cursor_state): New variable.
	(console_cursor_shape): Likewise.
	(console_setcursor): New function.
	(console_nocursor): Removed.

	* grub/asmstub.c (console_setcursor): New function.
	(hercules_setcursor): Likewise.
	(console_nocursor): Removed.
	(hercules_nocursor): Likewise.
2002-12-03 00:02:53 +00:00

128 lines
4.0 KiB
C

/* term.h - definitions for terminal handling */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef GRUB_TERM_HEADER
#define GRUB_TERM_HEADER 1
/* These are used to represent the various color states we use */
typedef enum
{
/* represents the color used to display all text that does not use the user
* defined colors below
*/
COLOR_STATE_STANDARD,
/* represents the user defined colors for normal text */
COLOR_STATE_NORMAL,
/* represents the user defined colors for highlighted text */
COLOR_STATE_HIGHLIGHT
} color_state;
#ifndef STAGE1_5
/* Flags for representing the capabilities of a terminal. */
/* Some notes about the flags:
- These flags are used by higher-level functions but not terminals
themselves.
- If a terminal is dumb, you may assume that only putchar, getkey and
checkkey are called.
- Some fancy features (nocursor, setcolor, and highlight) can be set to
NULL. */
/* Set when input characters shouldn't be echoed back. */
#define TERM_NO_ECHO (1 << 0)
/* Set when the editing feature should be disabled. */
#define TERM_NO_EDIT (1 << 1)
/* Set when the terminal cannot do fancy things. */
#define TERM_DUMB (1 << 2)
/* Set when the terminal needs to be initialized. */
#define TERM_NEED_INIT (1 << 16)
struct term_entry
{
/* The name of a terminal. */
const char *name;
/* The feature flags defined above. */
unsigned long flags;
/* Put a character. */
void (*putchar) (int c);
/* Check if any input character is available. */
int (*checkkey) (void);
/* Get a character. */
int (*getkey) (void);
/* Get the cursor position. The return value is ((X << 8) | Y). */
int (*getxy) (void);
/* Go to the position (X, Y). */
void (*gotoxy) (int x, int y);
/* Clear the screen. */
void (*cls) (void);
/* Set the current color to be used */
void (*setcolorstate) (color_state state);
/* Set the normal color and the highlight color. The format of each
color is VGA's. */
void (*setcolor) (int normal_color, int highlight_color);
/* Turn on/off the cursor. */
int (*setcursor) (int on);
};
/* This lists up available terminals. */
extern struct term_entry term_table[];
/* This points to the current terminal. This is useful, because only
a single terminal is enabled normally. */
extern struct term_entry *current_term;
#endif /* ! STAGE1_5 */
/* The console stuff. */
extern int console_current_color;
void console_putchar (int c);
#ifndef STAGE1_5
int console_checkkey (void);
int console_getkey (void);
int console_getxy (void);
void console_gotoxy (int x, int y);
void console_cls (void);
void console_setcolorstate (color_state state);
void console_setcolor (int normal_color, int highlight_color);
int console_setcursor (int on);
#endif
#ifdef SUPPORT_SERIAL
void serial_putchar (int c);
int serial_checkkey (void);
int serial_getkey (void);
int serial_getxy (void);
void serial_gotoxy (int x, int y);
void serial_cls (void);
void serial_setcolorstate (color_state state);
#endif
#ifdef SUPPORT_HERCULES
void hercules_putchar (int c);
int hercules_getxy (void);
void hercules_gotoxy (int x, int y);
void hercules_cls (void);
void hercules_setcolorstate (color_state state);
void hercules_setcolor (int normal_color, int highlight_color);
int hercules_setcursor (int on);
#endif
#endif /* ! GRUB_TERM_HEADER */