/* terminfo.c - simple terminfo module */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This file contains various functions dealing with different
* terminal capabilities. For example, vt52 and vt100.
*/
#include <grub/terminfo.h>
GRUB_MOD_LICENSE ("GPLv3+");
/* Get current terminfo name. */
char *
{
}
/* Free *PTR and set *PTR to NULL, to prevent double-free. */
static void
{
*ptr = 0;
}
static void
{
/* Free previously allocated memory. */
}
/* Set current terminfo type. */
const char *str)
{
/* TODO
* Lookup user specified terminfo type. If found, set term variables
* as appropriate. Otherwise return an error.
*
* How should this be done?
* a. A static table included in this module.
* - I do not like this idea.
* b. A table stored in the configuration directory.
* - Users must convert their terminfo settings if we have not already.
* c. Look for terminfo files in the configuration directory.
* + Copying the terminfo files you want to use to the grub
* configuration directory is easier then (b).
* d. Your idea here.
*/
{
return grub_errno;
}
{
return grub_errno;
}
{
data->cursor_off = 0;
ANSI_C0_STR "4%p2%dm");
return grub_errno;
}
{
/* Clear the screen. Using serial console, screen(1) only recognizes the
* ANSI escape sequence. Using video console, Apple Open Firmware
* (version 3.1.1) only recognizes the literal ^L. So use both. */
return grub_errno;
}
{
return grub_errno;
}
}
const char *type)
{
if (err)
return err;
return GRUB_ERR_NONE;
}
{
{
return GRUB_ERR_NONE;
}
}
/* Wrapper for grub_putchar to write strings. */
static void
{
while (*str)
}
{
}
void
grub_uint8_t x, grub_uint8_t y)
{
{
return;
}
else
{
}
}
/* Clear the screen. */
void
{
}
void
const grub_term_color_state state)
{
{
int fg;
int bg;
/* Map from VGA to terminal colors. */
= { 0, /* Black. */
4, /* Blue. */
2, /* Green. */
6, /* Cyan. */
1, /* Red. */
5, /* Magenta. */
3, /* Yellow. */
7, /* White. */
};
switch (state)
{
case GRUB_TERM_COLOR_STANDARD:
case GRUB_TERM_COLOR_NORMAL:
break;
break;
default:
return;
}
return;
}
switch (state)
{
case GRUB_TERM_COLOR_STANDARD:
case GRUB_TERM_COLOR_NORMAL:
break;
break;
default:
break;
}
}
void
{
if (on)
else
}
/* The terminfo version of putchar. */
void
const struct grub_unicode_glyph *c)
{
/* Keep track of the cursor. */
switch (c->base)
{
case '\a':
break;
case '\b':
case 127:
break;
case '\n':
break;
case '\r':
break;
default:
{
}
break;
}
}
{
}
static void
{
int c;
#define CONTINUE_READ \
{ \
/* On 9600 we have to wait up to 12 milliseconds. */ \
start = grub_get_time_ms (); \
do \
if (c == -1) \
return; \
\
(*len)++; \
}
if (c < 0)
{
*len = 0;
return;
}
*len = 1;
keys[0] = c;
if (c != ANSI_C0 && c != '\e')
{
/* Backspace: Ctrl-h. */
if (c == 0x7f)
c = '\b';
if (c < 0x20 && c != '\t' && c!= '\b' && c != '\n' && c != '\r')
*len = 1;
keys[0] = c;
return;
}
{
static struct
{
char key;
unsigned ascii;
}
three_code_table[] =
{
{'4', GRUB_TERM_KEY_DC},
{'A', GRUB_TERM_KEY_UP},
{'B', GRUB_TERM_KEY_DOWN},
{'C', GRUB_TERM_KEY_RIGHT},
{'D', GRUB_TERM_KEY_LEFT},
{'F', GRUB_TERM_KEY_END},
{'H', GRUB_TERM_KEY_HOME},
{'K', GRUB_TERM_KEY_END},
{'P', GRUB_TERM_KEY_DC},
{'?', GRUB_TERM_KEY_PPAGE},
{'/', GRUB_TERM_KEY_NPAGE},
{'@', GRUB_TERM_KEY_INSERT},
};
static struct
{
char key;
unsigned ascii;
}
four_code_table[] =
{
{'1', GRUB_TERM_KEY_HOME},
{'3', GRUB_TERM_KEY_DC},
{'5', GRUB_TERM_KEY_PPAGE},
{'6', GRUB_TERM_KEY_NPAGE}
};
char fx_key[] =
{ 'P', 'Q', 'w', 'x', 't', 'u',
'q', 'r', 'p', 'M', 'A', 'B' };
unsigned fx_code[] =
unsigned i;
if (c == '\e')
{
if (c != '[')
return;
}
for (i = 0; i < ARRAY_SIZE (three_code_table); i++)
if (three_code_table[i].key == c)
{
*len = 1;
return;
}
switch (c)
{
case 'O':
for (i = 0; i < ARRAY_SIZE (fx_key); i++)
if (fx_key[i] == c)
{
*len = 1;
return;
}
return;
case '0':
{
int num = 0;
if (c != '0' && c != '1')
return;
if (c < '0' || c > '9')
return;
num += (c - '0');
return;
if (c != 'q')
return;
*len = 1;
return;
}
default:
for (i = 0; i < ARRAY_SIZE (four_code_table); i++)
if (four_code_table[i].key == c)
{
if (c != '~')
return;
*len = 1;
return;
}
return;
}
}
}
/* The terminfo version of getkey. */
int
{
{
}
{
}
return GRUB_TERM_NO_KEY;
}
{
return GRUB_ERR_NONE;
}
{
return GRUB_ERR_NONE;
}
/* GRUB Command. */
static grub_err_t
print_terminfo (void)
{
>> GRUB_TERM_CODE_TYPE_SHIFT) + 1]
= {
/* VGA and glyph descriptor types are just for completeness,
they are not used on terminfo terminals.
*/
= _("UTF-8"),
= _("UTF-8 visual"),
= "Glyph descriptors",
_("Unknown"), _("Unknown"), _("Unknown")
};
return GRUB_ERR_NONE;
}
{
{0, 0, 0, 0, 0, 0}
};
enum
{
};
static grub_err_t
{
int w = 0, h = 0;
if (argc == 0)
return print_terminfo ();
{
if (grub_errno)
return grub_errno;
if (*ptr != 'x')
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"incorrect geometry specification");
ptr++;
if (grub_errno)
return grub_errno;
}
{
if (w && h)
{
}
if (argc == 1)
return GRUB_ERR_NONE;
}
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no terminal %s found or it's not handled by terminfo",
args[0]);
}
{
N_("[[-a|-u|-v] [-g WxH] TERM [TYPE]]"),
N_("Set terminfo type of TERM to TYPE.\n"),
options);
}
{
}