vt100.c
上传用户:tianjinjs
上传日期:2007-01-05
资源大小:309k
文件大小:23k
- /*
- * vt100.c ANSI/VT102 emulator code.
- * This code was integrated to the Minicom communications
- * package, but has been reworked to allow usage as a separate
- * module.
- *
- * It's not a "real" vt102 emulator - it's more than that:
- * somewhere between vt220 and vt420 in commands.
- *
- * This file is part of the minicom communications package,
- * Copyright 1991-1995 Miquel van Smoorenburg.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * // jl 04.09.97 character map conversions in and out
- * jl 06.07.98 use conversion tables with the capture file
- */
- #include "port.h"
- #include "window.h"
- #include "vt100.h"
- #include "config.h"
- #include "configsym.h"
- #include "patchlevel.h"
- #define OLD 0
- /*
- * The global variable esc_s holds the escape sequence status:
- * 0 - normal
- * 1 - ESC
- * 2 - ESC [
- * 3 - ESC [ ?
- * 4 - ESC (
- * 5 - ESC )
- * 6 - ESC #
- * 7 - ESC P
- */
- static int esc_s = 0;
- #define ESC 27
- /* Structure to hold escape sequences. */
- struct escseq {
- int code;
- char *vt100_st;
- char *vt100_app;
- char *ansi;
- };
- /* Escape sequences for different terminal types. */
- static struct escseq vt_keys[] = {
- #ifndef _DGUX_SOURCE
- { K_F1, "OP", "OP", "OP" },
- { K_F2, "OQ", "OQ", "OQ" },
- { K_F3, "OR", "OR", "OR" },
- { K_F4, "OS", "OS", "OS" },
- { K_F5, "[16~", "[16~", "OT" },
- { K_F6, "[17~", "[17~", "OU" },
- { K_F7, "[18~", "[18~", "OV" },
- { K_F8, "[19~", "[19~", "OW" },
- { K_F9, "[20~", "[20~", "OX" },
- { K_F10, "[21~", "[21~", "OY" },
- { K_F11, "[23~", "[23~", "OY" },
- { K_F12, "[24~", "[24~", "OY" },
- { K_HOME, "[1~", "[1~", "[H" },
- { K_PGUP, "[5~", "[5~", "[V" },
- { K_UP, "[A", "OA", "[A" },
- { K_LT, "[D", "OD", "[D" },
- { K_RT, "[C", "OC", "[C" },
- { K_DN, "[B", "OB", "[B" },
- { K_END, "[4~", "[4~", "[Y" },
- { K_PGDN, "[6~", "[6~", "[U" },
- { K_INS, "[2~", "[2~", "[@" },
- { K_DEL, "[3~", "[3~", "177" },
- { 0, NULL, NULL, NULL }
- #else
- { K_F1, "[17~", "[17~", "OP" },
- { K_F2, "[18~", "[18~", "OQ" },
- { K_F3, "[19~", "[19~", "OR" },
- { K_F4, "[20~", "[20~", "OS" },
- { K_F5, "[21~", "[21~", "OT" },
- { K_F6, "[23~", "[23~", "OU" },
- { K_F7, "[24~", "[24~", "OV" },
- { K_F8, "[25~", "[25~", "OW" },
- { K_F9, "[26~", "[26~", "OX" },
- { K_F10, "[28~", "[28~", "OY" },
- { K_F11, "[29~", "[29~", "OZ" },
- { K_F12, "[31~", "[31~", "OA" },
- { K_HOME, "OP", "OP", "[H" },
- { K_PGUP, "OQ", "OQ", "[V" },
- { K_UP, "[A", "OA", "[A" },
- { K_LT, "[D", "OD", "[D" },
- { K_RT, "[C", "OC", "[C" },
- { K_DN, "[B", "OB", "[B" },
- { K_END, "OR", "OR", "[Y" },
- { K_PGDN, "OS", "OS", "[U" },
- { K_INS, "[1~", "[1~", "[@" },
- { K_DEL, "[3~", "[3~", "177" },
- { 0, NULL, NULL, NULL }
- #endif
- };
- /* Two tables for user-defined character map conversions.
- * defmap.h should contain all characters 0-255 in ascending order
- * to default to no conversion. jl 04.09.1997
- */
- unsigned char vt_inmap[256] = {
- #include "defmap.h"
- };
- unsigned char vt_outmap[256] = {
- #include "defmap.h"
- };
- #if TRANSLATE
- /* Taken from the Linux kernel source: linux/drivers/char/console.c */
- static unsigned char * vt_map[] = {
- /* 8-bit Latin-1 mapped to the PC character set: '.' means non-printable */
- (unsigned char *)
- "................"
- "................"
- " !"#$%&'()*+,-./0123456789:;<=>?"
- "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"
- "`abcdefghijklmnopqrstuvwxyz{|}~."
- "................"
- "................"
- "377255233234376235174 25376376246256252 55376376"
- "370361375376376346 24371376376247257254253376250"
- "376376376376216217222200376220376376376376376376"
- "376245376376376376231376350376376376232376376341"
- "205240203376204206221207212202210211215241214213"
- "376244225242223376224366355227243226201376376230",
- /* vt100 graphics */
- (unsigned char *)
- "................"
- "