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_term_poll_usb
) (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 (term
) >> 8) & 7);
54 grub_putcode_dumb (' ', term
);
59 (term
->putchar
) (term
, &c
);
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
;
81 static int pending_key
= GRUB_TERM_NO_KEY
;
86 grub_term_input_t term
;
88 if (pending_key
!= GRUB_TERM_NO_KEY
)
91 if (grub_term_poll_usb
)
92 grub_term_poll_usb ();
94 FOR_ACTIVE_TERM_INPUTS(term
)
96 pending_key
= term
->getkey (term
);
97 if (pending_key
!= GRUB_TERM_NO_KEY
)
112 while (pending_key
== GRUB_TERM_NO_KEY
)
118 pending_key
= GRUB_TERM_NO_KEY
;
126 struct grub_term_output
*term
;
128 FOR_ACTIVE_TERM_OUTPUTS(term
)
129 grub_term_refresh (term
);