Restrict terminfo to serial

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-24 23:20:43 +01:00
parent 686ff5b4d1
commit 9f0cd916a4
3 changed files with 29 additions and 26 deletions

View file

@ -21,15 +21,17 @@
#include <grub/err.h> #include <grub/err.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/term.h>
char *grub_terminfo_get_current (void); char *grub_terminfo_get_current (void);
grub_err_t grub_terminfo_set_current (const char *); grub_err_t grub_terminfo_set_current (const char *);
void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y); void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y,
void grub_terminfo_cls (void); grub_term_output_t oterm);
void grub_terminfo_reverse_video_on (void); void grub_terminfo_cls (grub_term_output_t oterm);
void grub_terminfo_reverse_video_off (void); void grub_terminfo_reverse_video_on (grub_term_output_t oterm);
void grub_terminfo_cursor_on (void); void grub_terminfo_reverse_video_off (grub_term_output_t oterm);
void grub_terminfo_cursor_off (void); void grub_terminfo_cursor_on (grub_term_output_t oterm);
void grub_terminfo_cursor_off (grub_term_output_t oterm);
#endif /* ! GRUB_TERMINFO_HEADER */ #endif /* ! GRUB_TERMINFO_HEADER */

View file

@ -30,6 +30,7 @@
#define TEXT_WIDTH 80 #define TEXT_WIDTH 80
#define TEXT_HEIGHT 25 #define TEXT_HEIGHT 25
static struct grub_term_output grub_serial_term_output;
static unsigned int xpos, ypos; static unsigned int xpos, ypos;
static unsigned int keep_track = 1; static unsigned int keep_track = 1;
static unsigned int registered = 0; static unsigned int registered = 0;
@ -413,7 +414,7 @@ grub_serial_gotoxy (grub_uint8_t x, grub_uint8_t y)
else else
{ {
keep_track = 0; keep_track = 0;
grub_terminfo_gotoxy (x, y); grub_terminfo_gotoxy (x, y, &grub_serial_term_output);
keep_track = 1; keep_track = 1;
xpos = x; xpos = x;
@ -425,7 +426,7 @@ static void
grub_serial_cls (void) grub_serial_cls (void)
{ {
keep_track = 0; keep_track = 0;
grub_terminfo_cls (); grub_terminfo_cls (&grub_serial_term_output);
keep_track = 1; keep_track = 1;
xpos = ypos = 0; xpos = ypos = 0;
@ -439,10 +440,10 @@ grub_serial_setcolorstate (const grub_term_color_state state)
{ {
case GRUB_TERM_COLOR_STANDARD: case GRUB_TERM_COLOR_STANDARD:
case GRUB_TERM_COLOR_NORMAL: case GRUB_TERM_COLOR_NORMAL:
grub_terminfo_reverse_video_off (); grub_terminfo_reverse_video_off (&grub_serial_term_output);
break; break;
case GRUB_TERM_COLOR_HIGHLIGHT: case GRUB_TERM_COLOR_HIGHLIGHT:
grub_terminfo_reverse_video_on (); grub_terminfo_reverse_video_on (&grub_serial_term_output);
break; break;
default: default:
break; break;
@ -454,9 +455,9 @@ static void
grub_serial_setcursor (const int on) grub_serial_setcursor (const int on)
{ {
if (on) if (on)
grub_terminfo_cursor_on (); grub_terminfo_cursor_on (&grub_serial_term_output);
else else
grub_terminfo_cursor_off (); grub_terminfo_cursor_off (&grub_serial_term_output);
} }
static struct grub_term_input grub_serial_term_input = static struct grub_term_input grub_serial_term_input =

View file

@ -108,52 +108,52 @@ grub_terminfo_set_current (const char *str)
/* Wrapper for grub_putchar to write strings. */ /* Wrapper for grub_putchar to write strings. */
static void static void
putstr (const char *str) putstr (const char *str, grub_term_output_t oterm)
{ {
while (*str) while (*str)
grub_putchar (*str++); grub_putcode (*str++, oterm);
} }
/* Move the cursor to the given position starting with "0". */ /* Move the cursor to the given position starting with "0". */
void void
grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y) grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y, grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.gotoxy, y, x)); putstr (grub_terminfo_tparm (term.gotoxy, y, x), oterm);
} }
/* Clear the screen. */ /* Clear the screen. */
void void
grub_terminfo_cls (void) grub_terminfo_cls (grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.cls)); putstr (grub_terminfo_tparm (term.cls), oterm);
} }
/* Set reverse video mode on. */ /* Set reverse video mode on. */
void void
grub_terminfo_reverse_video_on (void) grub_terminfo_reverse_video_on (grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.reverse_video_on)); putstr (grub_terminfo_tparm (term.reverse_video_on), oterm);
} }
/* Set reverse video mode off. */ /* Set reverse video mode off. */
void void
grub_terminfo_reverse_video_off (void) grub_terminfo_reverse_video_off (grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.reverse_video_off)); putstr (grub_terminfo_tparm (term.reverse_video_off), oterm);
} }
/* Show cursor. */ /* Show cursor. */
void void
grub_terminfo_cursor_on (void) grub_terminfo_cursor_on (grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.cursor_on)); putstr (grub_terminfo_tparm (term.cursor_on), oterm);
} }
/* Hide cursor. */ /* Hide cursor. */
void void
grub_terminfo_cursor_off (void) grub_terminfo_cursor_off (grub_term_output_t oterm)
{ {
putstr (grub_terminfo_tparm (term.cursor_off)); putstr (grub_terminfo_tparm (term.cursor_off), oterm);
} }
/* GRUB Command. */ /* GRUB Command. */