2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2002,2003,2005,2007,2008,2009 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 3 of the License, or
8 * (at your option) any later version.
10 * GRUB 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, see <http://www.gnu.org/licenses/>.
19 #include <grub/term.h>
22 #include <grub/misc.h>
24 #include <grub/time.h>
26 struct grub_term_output
*grub_term_outputs_disabled
;
27 struct grub_term_input
*grub_term_inputs_disabled
;
28 struct grub_term_output
*grub_term_outputs
;
29 struct grub_term_input
*grub_term_inputs
;
31 void (*grub_newline_hook
) (void) = NULL
;
33 /* Put a Unicode character. */
35 grub_putcode_dumb (grub_uint32_t code
,
36 struct grub_term_output
*term
)
38 struct grub_unicode_glyph c
=
48 if (code
== '\t' && term
->getxy
)
52 n
= 8 - ((term
->getxy () >> 8) & 7);
54 grub_putcode_dumb (' ', term
);
61 grub_putcode_dumb ('\r', term
);
65 grub_xputs_dumb (const char *str
)
69 grub_term_output_t term
;
70 grub_uint32_t code
= *str
;
74 FOR_ACTIVE_TERM_OUTPUTS(term
)
75 grub_putcode_dumb (code
, term
);
79 void (*grub_xputs
) (const char *str
) = grub_xputs_dumb
;
84 grub_term_input_t term
;
90 FOR_ACTIVE_TERM_INPUTS(term
)
92 int key
= term
->checkkey ();
94 return term
->getkey ();
104 grub_term_input_t term
;
106 FOR_ACTIVE_TERM_INPUTS(term
)
108 int key
= term
->checkkey ();
117 grub_getkeystatus (void)
120 grub_term_input_t term
;
122 FOR_ACTIVE_TERM_INPUTS(term
)
124 if (term
->getkeystatus
)
125 status
|= term
->getkeystatus ();
134 struct grub_term_output
*term
;
136 FOR_ACTIVE_TERM_OUTPUTS(term
)
138 if ((term
->flags
& GRUB_TERM_DUMB
) || (grub_env_get ("debug")))
140 grub_putcode_dumb ('\n', term
);
141 grub_term_refresh (term
);
149 grub_setcolorstate (grub_term_color_state state
)
151 struct grub_term_output
*term
;
153 FOR_ACTIVE_TERM_OUTPUTS(term
)
154 grub_term_setcolorstate (term
, state
);
160 struct grub_term_output
*term
;
162 FOR_ACTIVE_TERM_OUTPUTS(term
)
163 grub_term_refresh (term
);