1/* term.h - definitions for terminal handling */ 2/* 3 * GRUB -- GRand Unified Bootloader 4 * Copyright (C) 2002 Free Software Foundation, Inc. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21#ifndef GRUB_TERM_HEADER 22#define GRUB_TERM_HEADER 1 23 24/* These are used to represent the various color states we use */ 25typedef enum 26{ 27 /* represents the color used to display all text that does not use the user 28 * defined colors below 29 */ 30 COLOR_STATE_STANDARD, 31 /* represents the user defined colors for normal text */ 32 COLOR_STATE_NORMAL, 33 /* represents the user defined colors for highlighted text */ 34 COLOR_STATE_HIGHLIGHT 35} color_state; 36 37#ifndef STAGE1_5 38 39/* Flags for representing the capabilities of a terminal. */ 40/* Some notes about the flags: 41 - These flags are used by higher-level functions but not terminals 42 themselves. 43 - If a terminal is dumb, you may assume that only putchar, getkey and 44 checkkey are called. 45 - Some fancy features (nocursor, setcolor, and highlight) can be set to 46 NULL. */ 47 48/* Set when input characters shouldn't be echoed back. */ 49#define TERM_NO_ECHO (1 << 0) 50/* Set when the editing feature should be disabled. */ 51#define TERM_NO_EDIT (1 << 1) 52/* Set when the terminal cannot do fancy things. */ 53#define TERM_DUMB (1 << 2) 54/* Set when the terminal needs to be initialized. */ 55#define TERM_NEED_INIT (1 << 16) 56 57struct term_entry 58{ 59 /* The name of a terminal. */ 60 const char *name; 61 /* The feature flags defined above. */ 62 unsigned long flags; 63 /* Put a character. */ 64 void (*putchar) (int c); 65 /* Check if any input character is available. */ 66 int (*checkkey) (void); 67 /* Get a character. */ 68 int (*getkey) (void); 69 /* Get the cursor position. The return value is ((X << 8) | Y). */ 70 int (*getxy) (void); 71 /* Go to the position (X, Y). */ 72 void (*gotoxy) (int x, int y); 73 /* Clear the screen. */ 74 void (*cls) (void); 75 /* Set the current color to be used */ 76 void (*setcolorstate) (color_state state); 77 /* Set the normal color and the highlight color. The format of each 78 color is VGA's. */ 79 void (*setcolor) (int normal_color, int highlight_color); 80 /* Turn on/off the cursor. */ 81 int (*setcursor) (int on); 82}; 83 84/* This lists up available terminals. */ 85extern struct term_entry term_table[]; 86/* This points to the current terminal. This is useful, because only 87 a single terminal is enabled normally. */ 88extern struct term_entry *current_term; 89 90#endif /* ! STAGE1_5 */ 91 92/* The console stuff. */ 93extern int console_current_color; 94void console_putchar (int c); 95 96#ifndef STAGE1_5 97int console_checkkey (void); 98int console_getkey (void); 99int console_getxy (void); 100void console_gotoxy (int x, int y); 101void console_cls (void); 102void console_setcolorstate (color_state state); 103void console_setcolor (int normal_color, int highlight_color); 104int console_setcursor (int on); 105#endif 106 107#ifdef SUPPORT_SERIAL 108void serial_putchar (int c); 109int serial_checkkey (void); 110int serial_getkey (void); 111int serial_getxy (void); 112void serial_gotoxy (int x, int y); 113void serial_cls (void); 114void serial_setcolorstate (color_state state); 115#endif 116 117#ifdef SUPPORT_HERCULES 118void hercules_putchar (int c); 119int hercules_getxy (void); 120void hercules_gotoxy (int x, int y); 121void hercules_cls (void); 122void hercules_setcolorstate (color_state state); 123void hercules_setcolor (int normal_color, int highlight_color); 124int hercules_setcursor (int on); 125#endif 126 127#endif /* ! GRUB_TERM_HEADER */ 128